-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] Option to Join Read-Only Channels (#27488)
Co-authored-by: Guilherme Gazzo <5263975+ggazzo@users.noreply.github.com>
- Loading branch information
1 parent
a0f4950
commit 7c064aa
Showing
6 changed files
with
63 additions
and
11 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 |
---|---|---|
|
@@ -44,4 +44,4 @@ yarn-error.log* | |
.nvmrc | ||
.idea/ | ||
.exrc | ||
.envrc | ||
.envrc |
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
32 changes: 29 additions & 3 deletions
32
apps/meteor/client/views/room/components/body/composer/ComposerReadOnly.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,9 +1,35 @@ | ||
import { MessageFooterCallout } from '@rocket.chat/ui-composer'; | ||
import { useTranslation } from '@rocket.chat/ui-contexts'; | ||
import { Button } from '@rocket.chat/fuselage'; | ||
import { MessageFooterCallout, MessageFooterCalloutContent } from '@rocket.chat/ui-composer'; | ||
import { useEndpoint, useTranslation } from '@rocket.chat/ui-contexts'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import type { ReactElement } from 'react'; | ||
import React from 'react'; | ||
|
||
import { dispatchToastMessage } from '../../../../../lib/toast'; | ||
import { useRoom, useUserIsSubscribed } from '../../../contexts/RoomContext'; | ||
|
||
export const ComposerReadOnly = (): ReactElement => { | ||
const t = useTranslation(); | ||
return <MessageFooterCallout>{t('room_is_read_only')}</MessageFooterCallout>; | ||
const room = useRoom(); | ||
const isSubscribed = useUserIsSubscribed(); | ||
const joinChannel = useEndpoint('POST', '/v1/channels.join'); | ||
|
||
const join = useMutation(() => joinChannel({ roomId: room._id }), { | ||
onError: (error: unknown) => { | ||
dispatchToastMessage({ type: 'error', message: error }); | ||
}, | ||
}); | ||
|
||
return ( | ||
<footer className='rc-message-box footer'> | ||
<MessageFooterCallout> | ||
<MessageFooterCalloutContent>{t('room_is_read_only')}</MessageFooterCalloutContent> | ||
{!isSubscribed && ( | ||
<Button primary onClick={() => join.mutate()} disabled={join.isLoading}> | ||
{t('Join')} | ||
</Button> | ||
)} | ||
</MessageFooterCallout> | ||
</footer> | ||
); | ||
}; |
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