Skip to content

Commit

Permalink
fix: hide register workspace option for non-admin users (#28154)
Browse files Browse the repository at this point in the history
  • Loading branch information
csuadev authored Feb 24, 2023
1 parent af9cdbf commit b45c41d
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OptionTitle } from '@rocket.chat/fuselage';
import { useTranslation, useRoute, useMethod, useSetModal } from '@rocket.chat/ui-contexts';
import { useTranslation, useRoute, useMethod, useSetModal, useRole } from '@rocket.chat/ui-contexts';
import { useQuery } from '@tanstack/react-query';
import { FlowRouter } from 'meteor/kadira:flow-router';
import type { FC } from 'react';
Expand Down Expand Up @@ -27,6 +27,7 @@ const AdministrationModelList: FC<AdministrationModelListProps> = ({ accountBoxI
const shouldShowEmoji = isFullyFeature(tabType);
const label = getUpgradeTabLabel(tabType);
const hasInfoPermission = userHasAllPermission(INFO_PERMISSIONS);
const isAdmin = useRole('admin');
const setModal = useSetModal();

const checkCloudRegisterStatus = useMethod('cloud:checkRegisterStatus');
Expand Down Expand Up @@ -62,18 +63,20 @@ const AdministrationModelList: FC<AdministrationModelListProps> = ({ accountBoxI
}}
/>
)}
<ListItem
icon='cloud-plus'
text={workspaceRegistered ? t('Registration') : t('Register')}
action={(): void => {
if (workspaceRegistered) {
cloudRoute.push({ context: '/' });
onDismiss();
return;
}
handleRegisterWorkspaceClick();
}}
/>
{isAdmin && (
<ListItem
icon='cloud-plus'
text={workspaceRegistered ? t('Registration') : t('Register')}
action={(): void => {
if (workspaceRegistered) {
cloudRoute.push({ context: '/' });
onDismiss();
return;
}
handleRegisterWorkspaceClick();
}}
/>
)}
{showWorkspace && (
<ListItem
icon='cog'
Expand Down

0 comments on commit b45c41d

Please sign in to comment.