Skip to content
Snippets Groups Projects
Unverified Commit 9cf7f50f authored by Guilherme Gazzo's avatar Guilherme Gazzo Committed by GitHub
Browse files

[FIX] Adjust read only toggle on create channel based on permissions (#27318)

parent 69f70427
No related branches found
No related tags found
No related merge requests found
import { Box, Modal, Button, TextInput, Icon, Field, ToggleSwitch, FieldGroup } from '@rocket.chat/fuselage';
import { useDebouncedCallback } from '@rocket.chat/fuselage-hooks';
import { useSetting, useTranslation, TranslationKey, useEndpoint } from '@rocket.chat/ui-contexts';
import { useSetting, useTranslation, TranslationKey, useEndpoint, usePermission } from '@rocket.chat/ui-contexts';
import React, { ReactElement, useEffect, useMemo, useState } from 'react';
import { useHasLicenseModule } from '../../../ee/client/hooks/useHasLicenseModule';
......@@ -58,6 +58,7 @@ const CreateChannel = ({
}: CreateChannelProps): ReactElement => {
const t = useTranslation();
const e2eEnabled = useSetting('E2E_Enable');
const canSetReadOnly = usePermission('set-readonly');
const namesValidation = useSetting('UTF8_Channel_Names_Validation');
const allowSpecialNames = useSetting('UI_Allow_room_names_with_special_chars');
const federationEnabled = useSetting('Federation_Matrix_enabled');
......@@ -175,7 +176,11 @@ const CreateChannel = ({
: t('All_users_in_the_channel_can_write_new_messages')}
</Field.Description>
</Box>
<ToggleSwitch checked={values.readOnly} disabled={values.broadcast || values.federated} onChange={handlers.handleReadOnly} />
<ToggleSwitch
checked={values.readOnly}
disabled={!canSetReadOnly || values.broadcast || values.federated}
onChange={handlers.handleReadOnly}
/>
</Box>
</Field>
<Field>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment