Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into fix/teamMention
Browse files Browse the repository at this point in the history
* origin:
  refactor: `TeamsChannels` to typescript (#32109)
  fix: search room not reactive after room name changes (#32123)
  test: fix `should edit name of targetChannel` flaky test (#32121)
  fix: UI allowing to mark room as favorite despite room was not a `default` room (#32063)
  chore: Remove duplicated `ChannelDeletionTable` (#32114)
  test(livechat): fix Department flaky test (#32102)
  test(livechat): File upload settings (#32060)
  test: contact center after hook calling wrong endpoint (#32094)
  fix(livechat): registering guest multiple times cause message loss (#32069)
  test: allow csp for livechat tests (#32116)
  chore: Move portals to the portals folder (#32090)
  test: `InitialData.insertAdminUserFromEnv` (#32066)
  fix: `CSP` error right after `setInlineScriptsAllowed` (#32108)
  • Loading branch information
gabriellsh committed Apr 4, 2024
2 parents 21a5196 + aee039b commit cecb6d7
Show file tree
Hide file tree
Showing 100 changed files with 1,135 additions and 819 deletions.
6 changes: 6 additions & 0 deletions .changeset/nine-houses-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
"@rocket.chat/livechat": patch
---

Livechat: A registered user loses their messages if 'registerGuest' is called using the same token.
6 changes: 6 additions & 0 deletions .changeset/pink-ants-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
---

Fixed a UI issue that allowed a user to "mark" a room as favorite even when a room was not default. The Back-End was correctly ignoring the `favorite` property from being updated when the room was not default, but the UI still allowed users to try.
As UI allowed but changes were not saved, this gave the impression that the function was not working.
5 changes: 5 additions & 0 deletions .changeset/sweet-books-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fixed search room not showing the new name room name changes
22 changes: 19 additions & 3 deletions apps/meteor/app/cors/server/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,28 @@ type NextFunction = (err?: any) => void;

const logger = new Logger('CORS');

let templatePromise: Promise<void> | void;

declare module 'meteor/webapp' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace WebApp {
function setInlineScriptsAllowed(allowed: boolean): Promise<void>;
}
}

settings.watch<boolean>(
'Enable_CSP',
Meteor.bindEnvironment((enabled) => {
WebAppInternals.setInlineScriptsAllowed(!enabled);
Meteor.bindEnvironment(async (enabled) => {
templatePromise = WebAppInternals.setInlineScriptsAllowed(!enabled);
}),
);

WebApp.rawConnectHandlers.use((_req: http.IncomingMessage, res: http.ServerResponse, next: NextFunction) => {
WebApp.rawConnectHandlers.use(async (_req: http.IncomingMessage, res: http.ServerResponse, next: NextFunction) => {
if (templatePromise) {
await templatePromise;
templatePromise = void 0;
}

// XSS Protection for old browsers (IE)
res.setHeader('X-XSS-Protection', '1');

Expand All @@ -46,6 +60,8 @@ WebApp.rawConnectHandlers.use((_req: http.IncomingMessage, res: http.ServerRespo
const inlineHashes = [
// Hash for `window.close()`, required by the CAS login popup.
"'sha256-jqxtvDkBbRAl9Hpqv68WdNOieepg8tJSYu1xIy7zT34='",
// Hash for /apps/meteor/packages/rocketchat-livechat/assets/demo.html:25
"'sha256-aui5xYk3Lu1dQcnsPlNZI+qDTdfzdUv3fzsw80VLJgw='",
]
.filter(Boolean)
.join(' ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { lazy, useMemo } from 'react';

import type { RoomToolboxActionConfig } from '../../views/room/contexts/RoomToolboxContext';

const TeamsChannels = lazy(() => import('../../views/teams/contextualBar/channels/TeamsChannels'));
const TeamsChannels = lazy(() => import('../../views/teams/contextualBar/channels'));

export const useTeamChannelsRoomAction = () => {
return useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ import type { ReactElement, ReactNode } from 'react';
import React, { memo, useEffect, useState } from 'react';
import { createPortal } from 'react-dom';

import { createAnchor } from '../../lib/utils/createAnchor';
import { deleteAnchor } from '../../lib/utils/deleteAnchor';
import { createAnchor } from '../lib/utils/createAnchor';
import { deleteAnchor } from '../lib/utils/deleteAnchor';

type ModalPortalProps = {
children?: ReactNode;
};

/**
* @todo: move to portals folder
*/
const ModalPortal = ({ children }: ModalPortalProps): ReactElement => {
const [modalRoot] = useState(() => createAnchor('modal-root'));
useEffect(() => (): void => deleteAnchor(modalRoot), [modalRoot]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createAnchor } from '../lib/utils/createAnchor';
import { deleteAnchor } from '../lib/utils/deleteAnchor';

const TooltipPortal: FC = ({ children }) => {
const [tooltipRoot] = useState(() => createAnchor('react-tooltip'));
const [tooltipRoot] = useState(() => createAnchor('tooltip-root'));
useEffect(() => (): void => deleteAnchor(tooltipRoot), [tooltipRoot]);
return <>{createPortal(children, tooltipRoot)}</>;
};
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/providers/TooltipProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TooltipContext } from '@rocket.chat/ui-contexts';
import type { FC, ReactNode } from 'react';
import React, { useEffect, useMemo, useRef, memo, useCallback, useState } from 'react';

import TooltipPortal from '../components/TooltipPortal';
import TooltipPortal from '../portals/TooltipPortal';

const TooltipProvider: FC = ({ children }) => {
const lastAnchor = useRef<HTMLElement>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { useEncryptedRoomDescription } from '../hooks/useEncryptedRoomDescriptio
type CreateChannelModalProps = {
teamId?: string;
onClose: () => void;
reload?: () => void;
};

type CreateChannelModalPayload = {
Expand All @@ -58,7 +59,7 @@ const getFederationHintKey = (licenseModule: ReturnType<typeof useHasLicenseModu
return 'Federation_Matrix_Federated_Description';
};

const CreateChannelModal = ({ teamId = '', onClose }: CreateChannelModalProps): ReactElement => {
const CreateChannelModal = ({ teamId = '', onClose, reload }: CreateChannelModalProps): ReactElement => {
const t = useTranslation();
const canSetReadOnly = usePermissionWithScopedRoles('set-readonly', ['owner']);
const e2eEnabled = useSetting('E2E_Enable');
Expand Down Expand Up @@ -173,6 +174,7 @@ const CreateChannelModal = ({ teamId = '', onClose }: CreateChannelModalProps):
}

dispatchToastMessage({ type: 'success', message: t('Room_has_been_created') });
reload?.();
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
} finally {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/sidebar/search/SearchList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const useSearchItems = (filterText: string): UseQueryResult<(ISubscription & IRo
const getSpotlight = useMethod('spotlight');

return useQuery(
['sidebar/search/spotlight', name, usernamesFromClient, type, localRooms.map(({ _id }) => _id)],
['sidebar/search/spotlight', name, usernamesFromClient, type, localRooms.map(({ _id, name }) => _id + name)],
async () => {
if (localRooms.length === LIMIT) {
return localRooms;
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/views/admin/rooms/EditRoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const EditRoom = ({ room, onChange, onDelete }: EditRoomProps) => {
canViewReactWhenReadOnly,
} = useEditAdminRoomPermissions(room);

const { roomType, readOnly, archived } = watch();
const { roomType, readOnly, archived, isDefault } = watch();

const changeArchiving = archived !== !!room.archived;

Expand Down Expand Up @@ -324,7 +324,7 @@ const EditRoom = ({ room, onChange, onDelete }: EditRoomProps) => {
name='favorite'
control={control}
render={({ field: { value, ...field } }) => (
<ToggleSwitch id={favoriteField} {...field} disabled={isDeleting} checked={value} />
<ToggleSwitch id={favoriteField} {...field} disabled={isDeleting || !isDefault} checked={value} />
)}
/>
</FieldRow>
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/views/modal/ModalRegion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useModal, useCurrentModal } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React, { lazy, useCallback } from 'react';

import ModalBackdrop from '../../components/modal/ModalBackdrop';
import ModalPortal from '../../components/modal/ModalPortal';
import ModalBackdrop from '../../components/ModalBackdrop';
import ModalPortal from '../../portals/ModalPortal';

const FocusScope = lazy(() => import('react-aria').then((module) => ({ default: module.FocusScope })));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import RoomsAvailableForTeamsAutoComplete from './RoomsAvailableForTeamsAutoComp
type AddExistingModalProps = {
teamId: string;
onClose: () => void;
reload?: () => void;
};

const AddExistingModal = ({ onClose, teamId }: AddExistingModalProps) => {
const AddExistingModal = ({ teamId, onClose, reload }: AddExistingModalProps) => {
const t = useTranslation();
const dispatchToastMessage = useToastMessageDispatch();

Expand All @@ -31,13 +32,14 @@ const AddExistingModal = ({ onClose, teamId }: AddExistingModalProps) => {
});

dispatchToastMessage({ type: 'success', message: t('Channels_added') });
reload?.();
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
} finally {
onClose();
}
},
[addRoomEndpoint, teamId, onClose, dispatchToastMessage, t],
[addRoomEndpoint, teamId, onClose, dispatchToastMessage, reload, t],
);

return (
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit cecb6d7

Please sign in to comment.