-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Displays chat history on chats contextual bar (#32845)
* wip * test: replace e2e locator
- Loading branch information
1 parent
9bc0675
commit 9397779
Showing
18 changed files
with
55 additions
and
271 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
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
74 changes: 10 additions & 64 deletions
74
apps/meteor/client/views/omnichannel/directory/ChatsContextualBar.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 |
---|---|---|
@@ -1,75 +1,21 @@ | ||
import { Box } from '@rocket.chat/fuselage'; | ||
import { useRoute, useRouteParameter, useTranslation } from '@rocket.chat/ui-contexts'; | ||
import { useRouteParameter, useRouter } from '@rocket.chat/ui-contexts'; | ||
import React from 'react'; | ||
|
||
import { | ||
Contextualbar, | ||
ContextualbarHeader, | ||
ContextualbarIcon, | ||
ContextualbarTitle, | ||
ContextualbarAction, | ||
ContextualbarClose, | ||
} from '../../../components/Contextualbar'; | ||
import Chat from './chats/Chat'; | ||
import ChatInfoDirectory from './chats/contextualBar/ChatInfoDirectory'; | ||
import { RoomEditWithData } from './chats/contextualBar/RoomEdit'; | ||
import { FormSkeleton } from './components'; | ||
import { useOmnichannelRoomInfo } from './hooks/useOmnichannelRoomInfo'; | ||
|
||
const ChatsContextualBar = ({ chatReload }: { chatReload?: () => void }) => { | ||
const t = useTranslation(); | ||
|
||
const directoryRoute = useRoute('omnichannel-directory'); | ||
import ContactHistoryMessagesList from '../contactHistory/MessageList/ContactHistoryMessagesList'; | ||
|
||
const ChatsContextualBar = () => { | ||
const router = useRouter(); | ||
const context = useRouteParameter('context'); | ||
const id = useRouteParameter('id') || ''; | ||
|
||
const openInRoom = () => id && directoryRoute.push({ tab: 'chats', id, context: 'view' }); | ||
|
||
const handleClose = () => directoryRoute.push({ tab: 'chats' }); | ||
|
||
const handleCancel = () => id && directoryRoute.push({ tab: 'chats', id, context: 'info' }); | ||
const id = useRouteParameter('id'); | ||
|
||
const { data: room, isLoading, isError, refetch: reloadInfo } = useOmnichannelRoomInfo(id); | ||
|
||
if (context === 'view' && id) { | ||
return <Chat rid={id} />; | ||
} | ||
|
||
if (isLoading) { | ||
return ( | ||
<Box pi={24}> | ||
<FormSkeleton /> | ||
</Box> | ||
); | ||
} | ||
const handleOpenRoom = () => id && router.navigate(`/live/${id}`); | ||
const handleClose = () => router.navigate('/omnichannel-directory/chats'); | ||
|
||
if (isError || !room) { | ||
return <Box mbs={16}>{t('Room_not_found')}</Box>; | ||
if (context === 'info' && id) { | ||
return <ContactHistoryMessagesList chatId={id} onClose={handleClose} onOpenRoom={handleOpenRoom} />; | ||
} | ||
|
||
return ( | ||
<Contextualbar> | ||
<ContextualbarHeader expanded> | ||
{context === 'info' && ( | ||
<> | ||
<ContextualbarIcon name='info-circled' /> | ||
<ContextualbarTitle>{t('Room_Info')}</ContextualbarTitle> | ||
<ContextualbarAction title={t('View_full_conversation')} name='new-window' onClick={openInRoom} /> | ||
</> | ||
)} | ||
{context === 'edit' && ( | ||
<> | ||
<ContextualbarIcon name='pencil' /> | ||
<ContextualbarTitle>{t('edit-room')}</ContextualbarTitle> | ||
</> | ||
)} | ||
<ContextualbarClose onClick={handleClose} /> | ||
</ContextualbarHeader> | ||
{context === 'info' && <ChatInfoDirectory id={id} room={room} />} | ||
{context === 'edit' && id && <RoomEditWithData id={id} reload={chatReload} reloadInfo={reloadInfo} onClose={handleCancel} />} | ||
</Contextualbar> | ||
); | ||
return null; | ||
}; | ||
|
||
export default ChatsContextualBar; |
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
apps/meteor/client/views/omnichannel/directory/chats/ChatInfo/RoomEdit/index.ts
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 @@ | ||
export { default } from './RoomEditWithData'; |
File renamed without changes.
Oops, something went wrong.