From 38c26ec05268a43d6a43aadf462134ebeebfd294 Mon Sep 17 00:00:00 2001 From: Fredrik Strand Oseberg Date: Wed, 23 Feb 2022 13:47:32 +0100 Subject: [PATCH] fix: set admin permission (#736) --- .../environments/EnvironmentList/EnvironmentList.tsx | 6 +++++- frontend/src/hooks/api/getters/useUiConfig/defaultValue.ts | 2 +- frontend/src/interfaces/uiConfig.ts | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/component/environments/EnvironmentList/EnvironmentList.tsx b/frontend/src/component/environments/EnvironmentList/EnvironmentList.tsx index 691946e0de..8041053b15 100644 --- a/frontend/src/component/environments/EnvironmentList/EnvironmentList.tsx +++ b/frontend/src/component/environments/EnvironmentList/EnvironmentList.tsx @@ -19,6 +19,8 @@ import EnvironmentListItem from './EnvironmentListItem/EnvironmentListItem'; import { mutate } from 'swr'; import EnvironmentToggleConfirm from './EnvironmentToggleConfirm/EnvironmentToggleConfirm'; import useProjectRolePermissions from '../../../hooks/api/getters/useProjectRolePermissions/useProjectRolePermissions'; +import { ADMIN } from 'component/providers/AccessProvider/permissions'; +import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; const EnvironmentList = () => { const defaultEnv = { @@ -30,6 +32,7 @@ const EnvironmentList = () => { protected: false, }; const { environments, refetch } = useEnvironments(); + const { uiConfig } = useUiConfig(); const { refetch: refetchProjectRolePermissions } = useProjectRolePermissions(); @@ -161,7 +164,6 @@ const EnvironmentList = () => { const navigateToCreateEnvironment = () => { history.push('/environments/create'); }; - return ( { maxWidth="700px" tooltip="Add environment" Icon={Add} + permission={ADMIN} + disabled={!Boolean(uiConfig.flags.EEA)} > Add Environment diff --git a/frontend/src/hooks/api/getters/useUiConfig/defaultValue.ts b/frontend/src/hooks/api/getters/useUiConfig/defaultValue.ts index f25ba0a13c..6aaf1154f7 100644 --- a/frontend/src/hooks/api/getters/useUiConfig/defaultValue.ts +++ b/frontend/src/hooks/api/getters/useUiConfig/defaultValue.ts @@ -5,7 +5,7 @@ export const defaultValue = { version: '3.x', environment: '', slogan: 'The enterprise ready feature toggle service.', - flags: { P: false, C: false, E: false, RE: false }, + flags: { P: false, C: false, E: false, RE: false, EEA: false }, links: [ { value: 'Documentation', diff --git a/frontend/src/interfaces/uiConfig.ts b/frontend/src/interfaces/uiConfig.ts index 862c2297fd..34b99c5e60 100644 --- a/frontend/src/interfaces/uiConfig.ts +++ b/frontend/src/interfaces/uiConfig.ts @@ -24,6 +24,8 @@ export interface IFlags { P: boolean; E: boolean; RE: boolean; + EEA?: boolean; + OIDC?: boolean; } export interface IVersionInfo {