From 9e2bee07513d43a9f91b1ac3c437e0b154126f6a Mon Sep 17 00:00:00 2001 From: gabriellsh <40830821+gabriellsh@users.noreply.github.com> Date: Thu, 26 Oct 2023 18:11:09 -0300 Subject: [PATCH 1/4] chore: Disable pre intent if on development environment. (#29118) --- apps/meteor/app/api/server/v1/cloud.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/meteor/app/api/server/v1/cloud.ts b/apps/meteor/app/api/server/v1/cloud.ts index 55b3f85882755..d904d40d84ff1 100644 --- a/apps/meteor/app/api/server/v1/cloud.ts +++ b/apps/meteor/app/api/server/v1/cloud.ts @@ -71,6 +71,10 @@ API.v1.addRoute( return API.v1.unauthorized(); } + if (process.env.NODE_ENV === 'development') { + return API.v1.success({ offline: true }); + } + return API.v1.success({ offline: !(await registerPreIntentWorkspaceWizard()) }); }, }, From ffa62c5e472c3839b2902934e7e7eafe1229de3d Mon Sep 17 00:00:00 2001 From: Kevin Aleman Date: Thu, 26 Oct 2023 15:30:53 -0600 Subject: [PATCH 2/4] fix: `onlyAvailable` property wrong type (#30748) --- .../client/components/AutoCompleteAgent.tsx | 2 +- .../Omnichannel/hooks/useAgentsList.ts | 2 +- apps/meteor/tests/data/users.helper.js | 16 +++-- .../end-to-end/api/livechat/01-agents.ts | 66 ++++++++++++++++++- packages/rest-typings/src/v1/omnichannel.ts | 2 +- 5 files changed, 77 insertions(+), 11 deletions(-) diff --git a/apps/meteor/client/components/AutoCompleteAgent.tsx b/apps/meteor/client/components/AutoCompleteAgent.tsx index f2cbebe469202..059ac4251cc89 100644 --- a/apps/meteor/client/components/AutoCompleteAgent.tsx +++ b/apps/meteor/client/components/AutoCompleteAgent.tsx @@ -27,7 +27,7 @@ const AutoCompleteAgent = ({ haveAll = false, haveNoAgentsSelectedOption = false, excludeId, - showIdleAgents = false, + showIdleAgents = true, onlyAvailable = false, withTitle = false, onChange, diff --git a/apps/meteor/client/components/Omnichannel/hooks/useAgentsList.ts b/apps/meteor/client/components/Omnichannel/hooks/useAgentsList.ts index e2f6f80f23556..ef00a6c0b81d9 100644 --- a/apps/meteor/client/components/Omnichannel/hooks/useAgentsList.ts +++ b/apps/meteor/client/components/Omnichannel/hooks/useAgentsList.ts @@ -29,7 +29,7 @@ export const useAgentsList = ( const reload = useCallback(() => setItemsList(new RecordList()), []); const getAgents = useEndpoint('GET', '/v1/livechat/users/agent'); - const { text, onlyAvailable = false, showIdleAgents = false, excludeId, haveAll, haveNoAgentsSelectedOption } = options; + const { text, onlyAvailable = false, showIdleAgents = true, excludeId, haveAll, haveNoAgentsSelectedOption } = options; useComponentDidUpdate(() => { options && reload(); diff --git a/apps/meteor/tests/data/users.helper.js b/apps/meteor/tests/data/users.helper.js index 82ab8446547d0..d69b0413ae0b8 100644 --- a/apps/meteor/tests/data/users.helper.js +++ b/apps/meteor/tests/data/users.helper.js @@ -1,3 +1,4 @@ +import { UserStatus } from '@rocket.chat/core-typings'; import { api, credentials, request } from './api-data'; import { password } from './user'; @@ -34,12 +35,9 @@ export const login = (username, password) => }); export const deleteUser = async (user) => - request - .post(api('users.delete')) - .set(credentials) - .send({ - userId: user._id, - }); + request.post(api('users.delete')).set(credentials).send({ + userId: user._id, + }); export const getUserByUsername = (username) => new Promise((resolve) => { @@ -86,3 +84,9 @@ export const setUserActiveStatus = (userId, activeStatus = true) => }) .end(resolve); }); + +export const setUserStatus = (overrideCredentials = credentials, status = UserStatus.ONLINE) => + request.post(api('users.setStatus')).set(overrideCredentials).send({ + message: '', + status, + }); diff --git a/apps/meteor/tests/end-to-end/api/livechat/01-agents.ts b/apps/meteor/tests/end-to-end/api/livechat/01-agents.ts index 6f9120ea90949..044cdf498a887 100644 --- a/apps/meteor/tests/end-to-end/api/livechat/01-agents.ts +++ b/apps/meteor/tests/end-to-end/api/livechat/01-agents.ts @@ -1,4 +1,4 @@ -import type { ILivechatAgent, ILivechatDepartment, IUser } from '@rocket.chat/core-typings'; +import { UserStatus, type ILivechatAgent, type ILivechatDepartment, type IUser } from '@rocket.chat/core-typings'; import { expect } from 'chai'; import { after, before, describe, it } from 'mocha'; import type { Response } from 'supertest'; @@ -16,7 +16,7 @@ import { } from '../../../data/livechat/rooms'; import { updatePermission, updateSetting } from '../../../data/permissions.helper'; import { password } from '../../../data/user'; -import { createUser, deleteUser, getMe, login } from '../../../data/users.helper'; +import { createUser, deleteUser, getMe, login, setUserStatus } from '../../../data/users.helper'; describe('LIVECHAT - Agents', function () { this.retries(0); @@ -114,6 +114,68 @@ describe('LIVECHAT - Agents', function () { expect(res.body.users.every((u: { statusLivechat: string }) => u.statusLivechat === 'available')).to.be.true; }); }); + it('should return an array of available/unavailable agents when onlyAvailable is false', async () => { + await request + .get(api('livechat/users/agent')) + .set(credentials) + .expect('Content-Type', 'application/json') + .query({ onlyAvailable: false }) + .expect(200) + .expect((res: Response) => { + expect(res.body).to.have.property('success', true); + expect(res.body.users).to.be.an('array'); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('count'); + expect( + res.body.users.every( + (u: { statusLivechat: string }) => !u.statusLivechat || ['available', 'not-available'].includes(u.statusLivechat), + ), + ).to.be.true; + }); + }); + + it('should return offline agents when showIdleAgents is true', async () => { + await setUserStatus(agent2.credentials, UserStatus.OFFLINE); + await request + .get(api('livechat/users/agent')) + .set(credentials) + .expect('Content-Type', 'application/json') + .query({ showIdleAgents: true }) + .expect(200) + .expect((res: Response) => { + expect(res.body).to.have.property('success', true); + expect(res.body.users).to.be.an('array'); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('count'); + expect( + res.body.users.every( + (u: { status: UserStatus }) => + !u.status || [UserStatus.ONLINE, UserStatus.OFFLINE, UserStatus.AWAY, UserStatus.BUSY].includes(u.status), + ), + ).to.be.true; + }); + }); + + it('should return only online agents when showIdleAgents is false', async () => { + await setUserStatus(agent2.credentials, UserStatus.ONLINE); + await request + .get(api('livechat/users/agent')) + .set(credentials) + .expect('Content-Type', 'application/json') + .query({ showIdleAgents: false }) + .expect(200) + .expect((res: Response) => { + expect(res.body).to.have.property('success', true); + expect(res.body.users).to.be.an('array'); + expect(res.body).to.have.property('offset'); + expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('count'); + expect(res.body.users.every((u: { status: UserStatus }) => u.status !== UserStatus.OFFLINE)).to.be.true; + }); + }); + it('should return an array of managers', async () => { await updatePermission('view-livechat-manager', ['admin']); await updatePermission('manage-livechat-agents', ['admin']); diff --git a/packages/rest-typings/src/v1/omnichannel.ts b/packages/rest-typings/src/v1/omnichannel.ts index ea341a3ae15d5..fcdbf17bb94d4 100644 --- a/packages/rest-typings/src/v1/omnichannel.ts +++ b/packages/rest-typings/src/v1/omnichannel.ts @@ -765,7 +765,7 @@ const LivechatUsersManagerGETSchema = { nullable: true, }, onlyAvailable: { - type: 'string', + type: 'boolean', nullable: true, }, excludeId: { From e3a475d26e58f7083aa5e3e4b5517cb10d05ea34 Mon Sep 17 00:00:00 2001 From: Yash Rajpal <58601732+yash-rajpal@users.noreply.github.com> Date: Fri, 27 Oct 2023 03:50:19 +0530 Subject: [PATCH 3/4] regression: Modal region for setup wizard (#30762) --- apps/meteor/client/views/setupWizard/SetupWizardRoute.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/meteor/client/views/setupWizard/SetupWizardRoute.tsx b/apps/meteor/client/views/setupWizard/SetupWizardRoute.tsx index 82d9438513f7e..2bc6c4f8a8200 100644 --- a/apps/meteor/client/views/setupWizard/SetupWizardRoute.tsx +++ b/apps/meteor/client/views/setupWizard/SetupWizardRoute.tsx @@ -4,6 +4,7 @@ import type { ReactElement } from 'react'; import React from 'react'; import { useTranslation, I18nextProvider } from 'react-i18next'; +import ModalRegion from '../modal/ModalRegion'; import SetupWizardPage from './SetupWizardPage'; import { useBodyPosition } from './hooks/useBodyPosition'; import { useRouteLock } from './hooks/useRouteLock'; @@ -26,6 +27,7 @@ export const SetupWizardRoute = (): ReactElement | null => { + From 270d16a5136492699af8b6d12ec4927a0d814685 Mon Sep 17 00:00:00 2001 From: csuadev <72958726+csuadev@users.noreply.github.com> Date: Thu, 26 Oct 2023 20:03:28 -0500 Subject: [PATCH 4/4] chore: hide marketplace categories when hidden property comes as true (#30752) --- .../client/views/marketplace/hooks/useCategories.ts | 12 +++++++----- apps/meteor/ee/client/apps/@types/IOrchestrator.ts | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/meteor/client/views/marketplace/hooks/useCategories.ts b/apps/meteor/client/views/marketplace/hooks/useCategories.ts index 4a457a1460461..bf7a022f2ae32 100644 --- a/apps/meteor/client/views/marketplace/hooks/useCategories.ts +++ b/apps/meteor/client/views/marketplace/hooks/useCategories.ts @@ -21,11 +21,13 @@ export const useCategories = (): [CategoryDropDownGroups, selectedCategoriesList try { const fetchedCategories = await AppClientOrchestratorInstance.getCategories(); - const mappedCategories = fetchedCategories.map((currentCategory) => ({ - id: currentCategory.id, - label: currentCategory.title, - checked: false, - })); + const mappedCategories = fetchedCategories + .filter((currentCategory) => !currentCategory.hidden) + .map((currentCategory) => ({ + id: currentCategory.id, + label: currentCategory.title, + checked: false, + })); setCategories([ { diff --git a/apps/meteor/ee/client/apps/@types/IOrchestrator.ts b/apps/meteor/ee/client/apps/@types/IOrchestrator.ts index 246fd18326c48..ac2642161c2ef 100644 --- a/apps/meteor/ee/client/apps/@types/IOrchestrator.ts +++ b/apps/meteor/ee/client/apps/@types/IOrchestrator.ts @@ -23,6 +23,7 @@ export interface IAppExternalURL { export interface ICategory { createdDate: Date; description: string; + hidden: boolean; id: string; modifiedDate: Date; title: string;