From b375a2775b3294e100c8d89b9c1678474986b0a6 Mon Sep 17 00:00:00 2001 From: csuarez Date: Fri, 24 Feb 2023 09:58:33 -0500 Subject: [PATCH] fix: hide register workspace option for non-admin users --- .../AdministrationModelList.tsx | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/apps/meteor/client/components/AdministrationList/AdministrationModelList.tsx b/apps/meteor/client/components/AdministrationList/AdministrationModelList.tsx index e72c12e4c7f2..4ad83507090d 100644 --- a/apps/meteor/client/components/AdministrationList/AdministrationModelList.tsx +++ b/apps/meteor/client/components/AdministrationList/AdministrationModelList.tsx @@ -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'; @@ -27,6 +27,7 @@ const AdministrationModelList: FC = ({ 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'); @@ -62,18 +63,20 @@ const AdministrationModelList: FC = ({ accountBoxI }} /> )} - { - if (workspaceRegistered) { - cloudRoute.push({ context: '/' }); - onDismiss(); - return; - } - handleRegisterWorkspaceClick(); - }} - /> + {isAdmin && ( + { + if (workspaceRegistered) { + cloudRoute.push({ context: '/' }); + onDismiss(); + return; + } + handleRegisterWorkspaceClick(); + }} + /> + )} {showWorkspace && (