-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Omnichannel directory chats filters (#33016)
- Loading branch information
1 parent
f294348
commit 61c8cec
Showing
15 changed files
with
645 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
'@rocket.chat/core-typings': minor | ||
'@rocket.chat/rest-typings': minor | ||
'@rocket.chat/i18n': minor | ||
'@rocket.chat/meteor': minor | ||
--- | ||
|
||
Adds filters options to the omnichannel directory chats tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
apps/meteor/client/views/omnichannel/directory/chats/ChatFilterByText.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { Box, Button, Chip } from '@rocket.chat/fuselage'; | ||
import { useEffectEvent } from '@rocket.chat/fuselage-hooks'; | ||
import { GenericMenu } from '@rocket.chat/ui-client'; | ||
import { useMethod, useRoute, useSetModal, useToastMessageDispatch, useTranslation } from '@rocket.chat/ui-contexts'; | ||
import { useQueryClient } from '@tanstack/react-query'; | ||
import React from 'react'; | ||
|
||
import FilterByText from '../../../../components/FilterByText'; | ||
import GenericModal from '../../../../components/GenericModal'; | ||
import { useChatsFilters } from './useChatsFilters'; | ||
|
||
const ChatFilterByText = () => { | ||
const t = useTranslation(); | ||
const setModal = useSetModal(); | ||
const dispatchToastMessage = useToastMessageDispatch(); | ||
const directoryRoute = useRoute('omnichannel-directory'); | ||
const removeClosedChats = useMethod('livechat:removeAllClosedRooms'); | ||
const queryClient = useQueryClient(); | ||
|
||
const { displayFilters, setFiltersQuery, removeFilter } = useChatsFilters(); | ||
|
||
const handleRemoveAllClosed = useEffectEvent(async () => { | ||
const onDeleteAll = async () => { | ||
try { | ||
await removeClosedChats(); | ||
queryClient.invalidateQueries(['current-chats']); | ||
dispatchToastMessage({ type: 'success', message: t('Chat_removed') }); | ||
} catch (error) { | ||
dispatchToastMessage({ type: 'error', message: error }); | ||
} finally { | ||
setModal(null); | ||
} | ||
}; | ||
|
||
setModal( | ||
<GenericModal | ||
variant='danger' | ||
data-qa-id='current-chats-modal-remove-all-closed' | ||
onConfirm={onDeleteAll} | ||
onCancel={() => setModal(null)} | ||
confirmText={t('Delete')} | ||
/>, | ||
); | ||
}); | ||
|
||
const menuItems = [ | ||
{ | ||
items: [ | ||
{ | ||
id: 'delete-all-closed-chats', | ||
variant: 'danger', | ||
icon: 'trash', | ||
content: t('Delete_all_closed_chats'), | ||
onClick: handleRemoveAllClosed, | ||
} as const, | ||
], | ||
}, | ||
]; | ||
|
||
return ( | ||
<> | ||
<FilterByText onChange={(text) => setFiltersQuery((prevState) => ({ ...prevState, guest: text }))}> | ||
<Button | ||
onClick={() => | ||
directoryRoute.push({ | ||
tab: 'chats', | ||
context: 'filters', | ||
}) | ||
} | ||
icon='customize' | ||
> | ||
{t('Filters')} | ||
</Button> | ||
<GenericMenu placement='bottom-end' detached title={t('More')} sections={menuItems} /> | ||
</FilterByText> | ||
<Box display='flex' flexWrap='wrap' mbe={4}> | ||
{Object.entries(displayFilters).map(([value, label], index) => { | ||
if (!label) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Chip mie={8} mbe={8} key={index} onClick={() => removeFilter(value)}> | ||
{label} | ||
</Chip> | ||
); | ||
})} | ||
</Box> | ||
</> | ||
); | ||
}; | ||
|
||
export default ChatFilterByText; |
Oops, something went wrong.