Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added modal confirmation before pinning message (#31348)
Co-authored-by: Douglas Fabris <27704687+dougfabris@users.noreply.github.com> Co-authored-by: Hugo Costa <20212776+hugocostadev@users.noreply.github.com>
- Loading branch information
1 parent
9c59a87
commit 47331ba
Showing
5 changed files
with
76 additions
and
7 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,5 @@ | ||
--- | ||
"@rocket.chat/meteor": minor | ||
--- | ||
|
||
Added a modal to confirm the intention to pin a message, preventing users from doing it by mistake |
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
45 changes: 45 additions & 0 deletions
45
apps/meteor/client/views/room/modals/PinMessageModal/PinMessageModal.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,45 @@ | ||
import type { MessageQuoteAttachment, IMessage } from '@rocket.chat/core-typings'; | ||
import { Box } from '@rocket.chat/fuselage'; | ||
import { useTranslation, useUserAvatarPath } from '@rocket.chat/ui-contexts'; | ||
import type { ComponentProps, ReactElement } from 'react'; | ||
import React from 'react'; | ||
|
||
import GenericModal from '../../../../components/GenericModal'; | ||
import { QuoteAttachment } from '../../../../components/message/content/attachments/QuoteAttachment'; | ||
import { useUserDisplayName } from '../../../../hooks/useUserDisplayName'; | ||
|
||
type PinMessageModalProps = { message: IMessage } & ComponentProps<typeof GenericModal>; | ||
|
||
const PinMessageModal = ({ message, ...props }: PinMessageModalProps): ReactElement => { | ||
const t = useTranslation(); | ||
const getUserAvatarPath = useUserAvatarPath(); | ||
const displayName = useUserDisplayName(message.u); | ||
const avatarUrl = getUserAvatarPath(message.u.username); | ||
|
||
const attachment = { | ||
author_name: String(displayName), | ||
author_link: '', | ||
author_icon: avatarUrl, | ||
message_link: '', | ||
text: message.msg, | ||
attachments: message.attachments as MessageQuoteAttachment[], | ||
md: message.md, | ||
}; | ||
|
||
return ( | ||
<GenericModal icon='pin' title={t('Pin_Message')} variant='warning' confirmText={t('Yes_pin_message')} {...props}> | ||
<Box mbe={16} is='p'> | ||
{t('Are_you_sure_you_want_to_pin_this_message')} | ||
</Box> | ||
<QuoteAttachment attachment={attachment} /> | ||
<Box is='p' fontScale='c1' mbs={16}> | ||
{t('Pinned_messages_are_visible_to_everyone')} | ||
</Box> | ||
<Box is='p' fontScale='c1'> | ||
{t('Starred_messages_are_only_visible_to_you')} | ||
</Box> | ||
</GenericModal> | ||
); | ||
}; | ||
|
||
export default PinMessageModal; |
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 './PinMessageModal'; |
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