From 0973acc77fe464eeae32e5190e05f7689a9043cc Mon Sep 17 00:00:00 2001 From: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Date: Fri, 2 Dec 2022 16:53:20 +0530 Subject: [PATCH] fix(ui): hide elasticSearchIndex page for non-admins (#9077) * fix(ui): hide elasticSearchIndex page for non-admins * address comments * remove unwanted field from children --- .../components/GlobalSetting/GlobalSettingLeftPanel.tsx | 5 ++++- .../main/resources/ui/src/router/GlobalSettingRouter.tsx | 5 +---- .../main/resources/ui/src/utils/GlobalSettingsUtils.tsx | 8 +++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/GlobalSetting/GlobalSettingLeftPanel.tsx b/openmetadata-ui/src/main/resources/ui/src/components/GlobalSetting/GlobalSettingLeftPanel.tsx index 1d6444475e9..a33d109e0a2 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/GlobalSetting/GlobalSettingLeftPanel.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/GlobalSetting/GlobalSettingLeftPanel.tsx @@ -18,6 +18,7 @@ import React, { useMemo } from 'react'; import { useHistory, useParams } from 'react-router-dom'; import { GlobalSettingOptions } from '../../constants/GlobalSettings.constants'; import { TeamType } from '../../generated/entity/teams/team'; +import { useAuth } from '../../hooks/authHooks'; import { getGlobalSettingMenuItem, getGlobalSettingsMenuWithPermission, @@ -34,9 +35,11 @@ const GlobalSettingLeftPanel = () => { const { permissions } = usePermissionProvider(); + const { isAdminUser } = useAuth(); + const menuItems: ItemType[] = useMemo( () => - getGlobalSettingsMenuWithPermission(permissions).reduce( + getGlobalSettingsMenuWithPermission(permissions, isAdminUser).reduce( (acc: ItemType[], curr: MenuList) => { const menuItem = getGlobalSettingMenuItem( curr.category, diff --git a/openmetadata-ui/src/main/resources/ui/src/router/GlobalSettingRouter.tsx b/openmetadata-ui/src/main/resources/ui/src/router/GlobalSettingRouter.tsx index 5dee891ddcf..3289273d91b 100644 --- a/openmetadata-ui/src/main/resources/ui/src/router/GlobalSettingRouter.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/router/GlobalSettingRouter.tsx @@ -234,10 +234,7 @@ const GlobalSettingRouter = () => { { return [ { @@ -218,10 +219,7 @@ export const getGlobalSettingsMenuWithPermission = ( items: [ { label: 'Elasticsearch', - isProtected: userPermissions.hasViewPermissions( - ResourceEntity.ALL, - permissions - ), + isProtected: Boolean(isAdminUser), icon: ( ),