Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/omni-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
murtaza98 authored Sep 13, 2023
2 parents ac2dbe2 + 7137a19 commit e765f20
Show file tree
Hide file tree
Showing 17 changed files with 76 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-mirrors-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Disabled call to tags enterprise endpoint when on community license
5 changes: 0 additions & 5 deletions .changeset/loud-bees-smoke.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/nine-bottles-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

feat: Add flag to disable teams mention via troubleshoot page
5 changes: 5 additions & 0 deletions .changeset/slimy-cheetahs-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixed selected departments not being displayed due to pagination
4 changes: 2 additions & 2 deletions apps/meteor/app/apps/server/bridges/messages.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -17,7 +17,7 @@ export class AppMessageBridge extends MessageBridge {
super();
}

protected async create(message: IMessage | IDirectMessage, appId: string): Promise<string> {
protected async create(message: IMessage, appId: string): Promise<string> {
this.orch.debugLog(`The App ${appId} is creating a new message.`);

const convertedMessage = await this.orch.getConverters()?.get('messages').convertAppMessage(message);
Expand Down
12 changes: 11 additions & 1 deletion apps/meteor/app/mentions/server/getMentionedTeamMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ 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[];
otherMentions: any[];
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);
Expand All @@ -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<boolean>('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');
});
4 changes: 4 additions & 0 deletions apps/meteor/app/mentions/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export class MentionQueries {
type: 'user' as const,
}));

if (settings.get<boolean>('Troubleshoot_Disable_Teams_Mention')) {
return taggedUsers;
}

const taggedTeams = teams.map((team) => ({
...team,
type: 'team' as const,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type DepartmentListItem = {
_id: string;
label: string;
value: string;
_updatedAt: Date;
};

export const useDepartmentsList = (
Expand Down Expand Up @@ -66,7 +65,6 @@ export const useDepartmentsList = (
_id,
label: department.archived ? `${name} [${t('Archived')}]` : name,
value: _id,
_updatedAt: new Date(_updatedAt || ''),
};
});

Expand All @@ -75,15 +73,13 @@ export const useDepartmentsList = (
_id: '',
label: t('All'),
value: 'all',
_updatedAt: new Date(),
});

options.haveNone &&
items.unshift({
_id: '',
label: t('None'),
value: '',
_updatedAt: new Date(),
});

return {
Expand Down
20 changes: 14 additions & 6 deletions apps/meteor/client/components/Omnichannel/hooks/useLivechatTags.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
},
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const EditDepartmentWithData = ({ id, title }: EditDepartmentWithDataProps) => {
});

if (isInitialLoading) {
return <FormSkeleton />;
return <FormSkeleton padding='1.5rem 1rem' maxWidth='37.5rem' margin='0 auto' />;
}

if (isError || (id && !data?.department)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Field>
<Field.Label>{t(label)}</Field.Label>
Expand All @@ -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={
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:^",
Expand Down
2 changes: 2 additions & 0 deletions apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/server/lib/spotlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions apps/meteor/server/settings/troubleshoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
});
16 changes: 8 additions & 8 deletions ee/packages/ui-theming/src/paletteDark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
],
},
{
Expand Down Expand Up @@ -177,15 +177,15 @@ 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' },
{ name: 'button-font-on-secondary-disabled', token: 'N700', color: '#6C727A' },
{
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' },
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7774,21 +7774,21 @@ __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
jose: ^4.11.1
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

Expand Down Expand Up @@ -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:^"
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit e765f20

Please sign in to comment.