From 880ab5689cda312826f5bd38b8c98f0d5c2e24ae Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Tue, 12 Sep 2023 16:02:20 -0300 Subject: [PATCH 1/5] fix: selected departments not being displayed due to pagination (#30365) --- .changeset/slimy-cheetahs-heal.md | 5 +++++ .../components/Omnichannel/hooks/useDepartmentsList.ts | 4 ---- .../omnichannel/departments/EditDepartmentWithData.tsx | 2 +- .../omnichannel/additionalForms/DepartmentForwarding.tsx | 7 ++++++- 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .changeset/slimy-cheetahs-heal.md diff --git a/.changeset/slimy-cheetahs-heal.md b/.changeset/slimy-cheetahs-heal.md new file mode 100644 index 000000000000..44233bc87766 --- /dev/null +++ b/.changeset/slimy-cheetahs-heal.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Fixed selected departments not being displayed due to pagination diff --git a/apps/meteor/client/components/Omnichannel/hooks/useDepartmentsList.ts b/apps/meteor/client/components/Omnichannel/hooks/useDepartmentsList.ts index 3b39ea79d42f..fd3c0a29effe 100644 --- a/apps/meteor/client/components/Omnichannel/hooks/useDepartmentsList.ts +++ b/apps/meteor/client/components/Omnichannel/hooks/useDepartmentsList.ts @@ -20,7 +20,6 @@ type DepartmentListItem = { _id: string; label: string; value: string; - _updatedAt: Date; }; export const useDepartmentsList = ( @@ -66,7 +65,6 @@ export const useDepartmentsList = ( _id, label: department.archived ? `${name} [${t('Archived')}]` : name, value: _id, - _updatedAt: new Date(_updatedAt || ''), }; }); @@ -75,7 +73,6 @@ export const useDepartmentsList = ( _id: '', label: t('All'), value: 'all', - _updatedAt: new Date(), }); options.haveNone && @@ -83,7 +80,6 @@ export const useDepartmentsList = ( _id: '', label: t('None'), value: '', - _updatedAt: new Date(), }); return { diff --git a/apps/meteor/client/views/omnichannel/departments/EditDepartmentWithData.tsx b/apps/meteor/client/views/omnichannel/departments/EditDepartmentWithData.tsx index 7f5389d0fbe7..64016d23db23 100644 --- a/apps/meteor/client/views/omnichannel/departments/EditDepartmentWithData.tsx +++ b/apps/meteor/client/views/omnichannel/departments/EditDepartmentWithData.tsx @@ -22,7 +22,7 @@ const EditDepartmentWithData = ({ id, title }: EditDepartmentWithDataProps) => { }); if (isInitialLoading) { - return ; + return ; } if (isError || (id && !data?.department)) { diff --git a/apps/meteor/ee/client/omnichannel/additionalForms/DepartmentForwarding.tsx b/apps/meteor/ee/client/omnichannel/additionalForms/DepartmentForwarding.tsx index 1d93108debf7..ed9a40e4bd0e 100644 --- a/apps/meteor/ee/client/omnichannel/additionalForms/DepartmentForwarding.tsx +++ b/apps/meteor/ee/client/omnichannel/additionalForms/DepartmentForwarding.tsx @@ -28,6 +28,11 @@ export const DepartmentForwarding = ({ departmentId, value = [], handler, label const { phase: departmentsPhase, items: departmentsItems, itemCount: departmentsTotal } = useRecordList(departmentsList); + const options = useMemo(() => { + const pending = value.filter(({ value }) => !departmentsItems.find((dep) => dep.value === value)); + return [...departmentsItems, ...pending]; + }, [departmentsItems, value]); + return ( {t(label)} @@ -41,7 +46,7 @@ export const DepartmentForwarding = ({ departmentId, value = [], handler, label filter={debouncedDepartmentsFilter} setFilter={setDepartmentsFilter} onChange={handler} - options={departmentsItems} + options={options} value={value} placeholder={t('Select_an_option')} endReached={ From f0c8867bb915edbe5a1cf1d8a8b06d9d2082f6d3 Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Tue, 12 Sep 2023 16:48:41 -0300 Subject: [PATCH 2/5] fix: Disabled call to EE tags endpoint when on CE license (#30353) --- .changeset/honest-mirrors-sit.md | 5 +++++ .../Omnichannel/hooks/useLivechatTags.ts | 20 +++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 .changeset/honest-mirrors-sit.md diff --git a/.changeset/honest-mirrors-sit.md b/.changeset/honest-mirrors-sit.md new file mode 100644 index 000000000000..4e4298cb8110 --- /dev/null +++ b/.changeset/honest-mirrors-sit.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Disabled call to tags enterprise endpoint when on community license diff --git a/apps/meteor/client/components/Omnichannel/hooks/useLivechatTags.ts b/apps/meteor/client/components/Omnichannel/hooks/useLivechatTags.ts index 4bd85be40342..ce5704b66482 100644 --- a/apps/meteor/client/components/Omnichannel/hooks/useLivechatTags.ts +++ b/apps/meteor/client/components/Omnichannel/hooks/useLivechatTags.ts @@ -1,6 +1,8 @@ import { useEndpoint } from '@rocket.chat/ui-contexts'; import { useQuery } from '@tanstack/react-query'; +import { useOmnichannel } from '../../../hooks/omnichannel/useOmnichannel'; + type Props = { department?: string; text?: string; @@ -9,13 +11,19 @@ type Props = { export const useLivechatTags = (options: Props) => { const getTags = useEndpoint('GET', '/v1/livechat/tags'); + const { isEnterprise } = useOmnichannel(); const { department, text, viewAll } = options; - return useQuery(['/v1/livechat/tags', text, department], () => - getTags({ - text: text || '', - ...(department && { department }), - viewAll: viewAll ? 'true' : 'false', - }), + return useQuery( + ['/v1/livechat/tags', text, department], + () => + getTags({ + text: text || '', + ...(department && { department }), + viewAll: viewAll ? 'true' : 'false', + }), + { + enabled: isEnterprise, + }, ); }; From 3656fd4f26d39142972774cd009345b03419b832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Jaeger=20Foresti?= <60678893+juliajforesti@users.noreply.github.com> Date: Tue, 12 Sep 2023 16:55:40 -0300 Subject: [PATCH 3/5] chore: a11y color report changes (#30333) --- ee/packages/ui-theming/src/paletteDark.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ee/packages/ui-theming/src/paletteDark.ts b/ee/packages/ui-theming/src/paletteDark.ts index 545fc9f098b8..9898c7fe95f9 100644 --- a/ee/packages/ui-theming/src/paletteDark.ts +++ b/ee/packages/ui-theming/src/paletteDark.ts @@ -120,12 +120,12 @@ export const palette = [ category: 'Button', description: 'Primary Background', list: [ - { name: 'button-background-primary-default', token: '', color: '#3976D1' }, - { name: 'button-background-primary-hover', token: '', color: '#295EAE' }, - { name: 'button-background-primary-press', token: '', color: '#245399' }, - { name: 'button-background-primary-focus', token: '', color: '#3976D1' }, - { name: 'button-background-primary-keyfocus', token: '', color: '#3976D1' }, - { name: 'button-background-primary-disabled', token: '', color: '#1D3963' }, + { name: 'button-background-primary-default', token: '', color: '#095AD2' }, + { name: 'button-background-primary-hover', token: '', color: '#10529E' }, + { name: 'button-background-primary-press', token: '', color: '#01336B' }, + { name: 'button-background-primary-focus', token: '', color: '#095AD2' }, + { name: 'button-background-primary-keyfocus', token: '', color: '#095AD2' }, + { name: 'button-background-primary-disabled', token: '', color: '#012247' }, ], }, { @@ -177,7 +177,7 @@ export const palette = [ list: [ { name: 'button-font-on-primary', token: 'white', color: '#FFFFFF' }, { name: 'button-font-on-secondary', token: 'N400', color: '#E4E7EA' }, - { name: 'button-font-on-secondary-danger', token: '', color: '#C14454' }, + { name: 'button-font-on-secondary-danger', token: '', color: '#FFC1C9' }, { name: 'button-font-on-danger', token: 'white', color: '#FFFFFF' }, { name: 'button-font-on-success', token: 'white', color: '#FFFFFF' }, { name: 'button-font-on-primary-disabled', token: 'N700', color: '#6C727A' }, @@ -185,7 +185,7 @@ export const palette = [ { name: 'button-font-on-secondary-danger-disabled', token: '', - color: '#613339', + color: '#6B0513', }, { name: 'button-font-on-danger-disabled', token: '', color: '#757575' }, { name: 'button-font-on-success-disabled', token: '', color: '#757575' }, From 711bb92ba20af7631128694d99fe038d941cf1b0 Mon Sep 17 00:00:00 2001 From: Douglas Gubert Date: Tue, 12 Sep 2023 17:51:14 -0300 Subject: [PATCH 4/5] chore: Revert "fix: update type of message bridge's create method" (#30355) --- .changeset/loud-bees-smoke.md | 5 ----- apps/meteor/app/apps/server/bridges/messages.ts | 4 ++-- apps/meteor/package.json | 2 +- yarn.lock | 14 +++++++------- 4 files changed, 10 insertions(+), 15 deletions(-) delete mode 100644 .changeset/loud-bees-smoke.md diff --git a/.changeset/loud-bees-smoke.md b/.changeset/loud-bees-smoke.md deleted file mode 100644 index 7b34a0d58af4..000000000000 --- a/.changeset/loud-bees-smoke.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@rocket.chat/meteor': minor ---- - -New helper for Apps to notify users via a Direct Message diff --git a/apps/meteor/app/apps/server/bridges/messages.ts b/apps/meteor/app/apps/server/bridges/messages.ts index 47648e445939..d75a0c244674 100644 --- a/apps/meteor/app/apps/server/bridges/messages.ts +++ b/apps/meteor/app/apps/server/bridges/messages.ts @@ -1,4 +1,4 @@ -import type { IMessage, IDirectMessage } from '@rocket.chat/apps-engine/definition/messages'; +import type { IMessage } from '@rocket.chat/apps-engine/definition/messages'; import type { IRoom } from '@rocket.chat/apps-engine/definition/rooms'; import type { IUser } from '@rocket.chat/apps-engine/definition/users'; import type { ITypingDescriptor } from '@rocket.chat/apps-engine/server/bridges/MessageBridge'; @@ -17,7 +17,7 @@ export class AppMessageBridge extends MessageBridge { super(); } - protected async create(message: IMessage | IDirectMessage, appId: string): Promise { + protected async create(message: IMessage, appId: string): Promise { this.orch.debugLog(`The App ${appId} is creating a new message.`); const convertedMessage = await this.orch.getConverters()?.get('messages').convertAppMessage(message); diff --git a/apps/meteor/package.json b/apps/meteor/package.json index 2e288c8dbd30..4b4d1275656e 100644 --- a/apps/meteor/package.json +++ b/apps/meteor/package.json @@ -225,7 +225,7 @@ "@rocket.chat/account-utils": "workspace:^", "@rocket.chat/agenda": "workspace:^", "@rocket.chat/api-client": "workspace:^", - "@rocket.chat/apps-engine": "1.41.0-alpha.325", + "@rocket.chat/apps-engine": "1.41.0-alpha.312", "@rocket.chat/base64": "workspace:^", "@rocket.chat/cas-validate": "workspace:^", "@rocket.chat/core-services": "workspace:^", diff --git a/yarn.lock b/yarn.lock index 100b3ba60fe7..c598977509bf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7774,9 +7774,9 @@ __metadata: languageName: node linkType: hard -"@rocket.chat/apps-engine@npm:1.41.0-alpha.325": - version: 1.41.0-alpha.325 - resolution: "@rocket.chat/apps-engine@npm:1.41.0-alpha.325" +"@rocket.chat/apps-engine@npm:1.41.0-alpha.312": + version: 1.41.0-alpha.312 + resolution: "@rocket.chat/apps-engine@npm:1.41.0-alpha.312" dependencies: adm-zip: ^0.5.9 cryptiles: ^4.1.3 @@ -7784,11 +7784,11 @@ __metadata: lodash.clonedeep: ^4.5.0 semver: ^5.7.1 stack-trace: 0.0.10 - uuid: ~8.3.2 + uuid: ^3.4.0 vm2: ^3.9.19 peerDependencies: "@rocket.chat/ui-kit": "*" - checksum: 3159b69d1174166bfe1fea13ac51e81bc39ddcabad3a8dcd20e4614d33592b7f93ae45625578d7545c149f52f90e9c30dee92a1bbd3f5830f7bcdc13d19fcef4 + checksum: 003853d3c4d4374ab984474026e4ae657daf4591fe4c375b914aa57c27f576af0fcba66e70c539e056b5d80a1ef655775f6f3a07bf81a36ab6fd438ce464e70f languageName: node linkType: hard @@ -8556,7 +8556,7 @@ __metadata: "@rocket.chat/account-utils": "workspace:^" "@rocket.chat/agenda": "workspace:^" "@rocket.chat/api-client": "workspace:^" - "@rocket.chat/apps-engine": 1.41.0-alpha.325 + "@rocket.chat/apps-engine": 1.41.0-alpha.312 "@rocket.chat/base64": "workspace:^" "@rocket.chat/cas-validate": "workspace:^" "@rocket.chat/core-services": "workspace:^" @@ -38668,7 +38668,7 @@ __metadata: languageName: node linkType: hard -"uuid@npm:^8.0.0, uuid@npm:^8.3.1, uuid@npm:^8.3.2, uuid@npm:~8.3.2": +"uuid@npm:^8.0.0, uuid@npm:^8.3.1, uuid@npm:^8.3.2": version: 8.3.2 resolution: "uuid@npm:8.3.2" bin: From 7137a193a79c544d2d8e26e976e18b545daabcf8 Mon Sep 17 00:00:00 2001 From: Kevin Aleman Date: Tue, 12 Sep 2023 17:02:57 -0600 Subject: [PATCH 5/5] feat: Add flag to disable teams mention via troubleshoot (#30372) --- .changeset/nine-bottles-press.md | 5 +++++ .../app/mentions/server/getMentionedTeamMembers.ts | 12 +++++++++++- apps/meteor/app/mentions/server/server.ts | 4 ++++ .../packages/rocketchat-i18n/i18n/en.i18n.json | 2 ++ apps/meteor/server/lib/spotlight.js | 2 +- apps/meteor/server/settings/troubleshoot.ts | 4 ++++ 6 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .changeset/nine-bottles-press.md diff --git a/.changeset/nine-bottles-press.md b/.changeset/nine-bottles-press.md new file mode 100644 index 000000000000..f9a57fa676ad --- /dev/null +++ b/.changeset/nine-bottles-press.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +feat: Add flag to disable teams mention via troubleshoot page diff --git a/apps/meteor/app/mentions/server/getMentionedTeamMembers.ts b/apps/meteor/app/mentions/server/getMentionedTeamMembers.ts index 1d36400296b4..b1355c90cb93 100644 --- a/apps/meteor/app/mentions/server/getMentionedTeamMembers.ts +++ b/apps/meteor/app/mentions/server/getMentionedTeamMembers.ts @@ -2,6 +2,7 @@ import { Team } from '@rocket.chat/core-services'; import type { IMessage } from '@rocket.chat/core-typings'; import { callbacks } from '../../../lib/callbacks'; +import { settings } from '../../settings/server'; interface IExtraDataForNotification { userMentions: any[]; @@ -9,7 +10,7 @@ interface IExtraDataForNotification { message: IMessage; } -callbacks.add('beforeGetMentions', async (mentionIds: string[], extra?: IExtraDataForNotification) => { +const beforeGetMentions = async (mentionIds: string[], extra?: IExtraDataForNotification) => { const { otherMentions } = extra ?? {}; const teamIds = otherMentions?.filter(({ type }) => type === 'team').map(({ _id }) => _id); @@ -22,4 +23,13 @@ callbacks.add('beforeGetMentions', async (mentionIds: string[], extra?: IExtraDa mentionIds.push(...new Set(members.map(({ userId }) => userId).filter((userId) => !mentionIds.includes(userId)))); return mentionIds; +}; + +settings.watch('Troubleshoot_Disable_Teams_Mention', (value) => { + if (value) { + callbacks.remove('beforeGetMentions', 'before-get-mentions-get-teams'); + return; + } + + callbacks.add('beforeGetMentions', beforeGetMentions, callbacks.priority.MEDIUM, 'before-get-mentions-get-teams'); }); diff --git a/apps/meteor/app/mentions/server/server.ts b/apps/meteor/app/mentions/server/server.ts index a5b0f89526a2..13765e99d856 100644 --- a/apps/meteor/app/mentions/server/server.ts +++ b/apps/meteor/app/mentions/server/server.ts @@ -25,6 +25,10 @@ export class MentionQueries { type: 'user' as const, })); + if (settings.get('Troubleshoot_Disable_Teams_Mention')) { + return taggedUsers; + } + const taggedTeams = teams.map((team) => ({ ...team, type: 'team' as const, diff --git a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json index f3e5e89c80d6..a0f6d0e0c6a8 100644 --- a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json @@ -5178,6 +5178,8 @@ "Troubleshoot_Disable_Statistics_Generator_Alert": "This setting stops the processing all statistics making the info page outdated until someone clicks on the refresh button and may cause other missing information around the system!", "Troubleshoot_Disable_Workspace_Sync": "Disable Workspace Sync", "Troubleshoot_Disable_Workspace_Sync_Alert": "This setting stops the sync of this server with Rocket.Chat's cloud and may cause issues with marketplace and enteprise licenses!", + "Troubleshoot_Disable_Teams_Mention": "Disable Teams mention", + "Troubleshoot_Disable_Teams_Mention_Alert": "This setting disables the teams mention feature. User's won't be able to mention a Team by name in a message and get its members notified.", "True": "True", "Try_now": "Try now", "Try_searching_in_the_marketplace_instead": "Try searching in the Marketplace instead", diff --git a/apps/meteor/server/lib/spotlight.js b/apps/meteor/server/lib/spotlight.js index ae38c903cbe2..62fcdc3a66b4 100644 --- a/apps/meteor/server/lib/spotlight.js +++ b/apps/meteor/server/lib/spotlight.js @@ -144,7 +144,7 @@ export class Spotlight { } async _searchTeams(userId, { text, options, users, mentions }) { - if (!mentions) { + if (!mentions || settings.get('Troubleshoot_Disable_Teams_Mention')) { return users; } diff --git a/apps/meteor/server/settings/troubleshoot.ts b/apps/meteor/server/settings/troubleshoot.ts index ecc0d37dc711..bc1cd1484301 100644 --- a/apps/meteor/server/settings/troubleshoot.ts +++ b/apps/meteor/server/settings/troubleshoot.ts @@ -44,4 +44,8 @@ export const createTroubleshootSettings = () => type: 'boolean', i18nDescription: 'Troubleshoot_Disable_Workspace_Sync_Alert', }); + await this.add('Troubleshoot_Disable_Teams_Mention', false, { + type: 'boolean', + i18nDescription: 'Troubleshoot_Disable_Teams_Mention_Alert', + }); });