From 49ea816f5c55cb26e2f990b7cad4ccfec5bbe651 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 25 Aug 2020 09:10:15 -0300 Subject: [PATCH] [IMPROVEMENT] Show "Chats in Progress" group (#2425) --- app/i18n/locales/en.js | 1 + app/i18n/locales/pt-BR.js | 1 + app/views/RoomsListView/index.js | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js index ef35a18a..b5d48749 100644 --- a/app/i18n/locales/en.js +++ b/app/i18n/locales/en.js @@ -339,6 +339,7 @@ export default { Offline: 'Offline', Oops: 'Oops!', Omnichannel: 'Omnichannel', + Open_Livechats: 'Chats in Progress', Omnichannel_enable_alert: 'You\'re not available on Omnichannel. Would you like to be available?', Onboarding_description: 'A workspace is your team or organization’s space to collaborate. Ask the workspace admin for address to join or create one for your team.', Onboarding_join_workspace: 'Join a workspace', diff --git a/app/i18n/locales/pt-BR.js b/app/i18n/locales/pt-BR.js index 792498fc..5ba23d79 100644 --- a/app/i18n/locales/pt-BR.js +++ b/app/i18n/locales/pt-BR.js @@ -315,6 +315,7 @@ export default { No_available_agents_to_transfer: 'Nenhum agente disponível para transferência', Offline: 'Offline', Omnichannel: 'Omnichannel', + Open_Livechats: 'Bate-papos em Andamento', Omnichannel_enable_alert: 'Você não está disponível no Omnichannel. Você quer ficar disponível?', Oops: 'Ops!', Onboarding_description: 'Workspace é o espaço de colaboração do seu time ou organização. Peça um convite ou o endereço ao seu administrador ou crie uma workspace para o seu time.', diff --git a/app/views/RoomsListView/index.js b/app/views/RoomsListView/index.js index 8f75eeb0..17413540 100644 --- a/app/views/RoomsListView/index.js +++ b/app/views/RoomsListView/index.js @@ -73,10 +73,12 @@ const DISCUSSIONS_HEADER = 'Discussions'; const CHANNELS_HEADER = 'Channels'; const DM_HEADER = 'Direct_Messages'; const GROUPS_HEADER = 'Private_Groups'; +const OMNICHANNEL_HEADER = 'Open_Livechats'; const QUERY_SIZE = 20; const filterIsUnread = s => (s.unread > 0 || s.alert) && !s.hideUnreadStatus; const filterIsFavorite = s => s.f; +const filterIsOmnichannel = s => s.t === 'l'; const shouldUpdateProps = [ 'searchText', @@ -110,7 +112,8 @@ class RoomsListView extends React.Component { id: PropTypes.string, username: PropTypes.string, token: PropTypes.string, - statusLivechat: PropTypes.string + statusLivechat: PropTypes.string, + roles: PropTypes.object }), server: PropTypes.string, searchText: PropTypes.string, @@ -414,7 +417,8 @@ class RoomsListView extends React.Component { sortBy, showUnread, showFavorites, - groupByType + groupByType, + user } = this.props; const db = database.active; @@ -461,6 +465,13 @@ class RoomsListView extends React.Component { */ const chatsOrder = data.map(item => item.rid); + const isOmnichannelAgent = user?.roles?.includes('livechat-agent'); + if (isOmnichannelAgent) { + const omnichannel = chats.filter(s => filterIsOmnichannel(s)); + chats = chats.filter(s => !filterIsOmnichannel(s)); + tempChats = this.addRoomsGroup(omnichannel, OMNICHANNEL_HEADER, tempChats); + } + // unread if (showUnread) { const unread = chats.filter(s => filterIsUnread(s)); @@ -485,7 +496,7 @@ class RoomsListView extends React.Component { tempChats = this.addRoomsGroup(channels, CHANNELS_HEADER, tempChats); tempChats = this.addRoomsGroup(privateGroup, GROUPS_HEADER, tempChats); tempChats = this.addRoomsGroup(direct, DM_HEADER, tempChats); - } else if (showUnread || showFavorites) { + } else if (showUnread || showFavorites || isOmnichannelAgent) { tempChats = this.addRoomsGroup(chats, CHATS_HEADER, tempChats); } else { tempChats = chats;