From 24b9421eb44481edcfbaa007d1b4300ca38f621b Mon Sep 17 00:00:00 2001 From: Robb Hamilton Date: Mon, 18 Nov 2024 14:41:41 -0500 Subject: [PATCH] Add Console Plugins nav item --- .../console-app/console-extensions.json | 17 +++++++++++++++++ frontend/packages/console-app/package.json | 3 ++- frontend/packages/console-app/src/consts.ts | 1 + .../src/hooks/useCanGetConsoleOperatorConfig.ts | 17 +++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 frontend/packages/console-app/src/hooks/useCanGetConsoleOperatorConfig.ts diff --git a/frontend/packages/console-app/console-extensions.json b/frontend/packages/console-app/console-extensions.json index a941276f970..25a21c77a70 100644 --- a/frontend/packages/console-app/console-extensions.json +++ b/frontend/packages/console-app/console-extensions.json @@ -2018,5 +2018,22 @@ "component": { "$codeRef": "consolePluginProxyDetail" }, "sortWeight": 5 } + }, + { + "type": "console.flag/hookProvider", + "properties": { + "handler": { "$codeRef": "getConsoleOperatorConfigFlag" } + } + }, + { + "type": "console.navigation/href", + "properties": { + "perspective": "admin", + "section": "administration", + "id": "consoleplugins", + "name": "%console-app~Console Plugins%", + "href": "/k8s/cluster/operator.openshift.io~v1~Console/cluster/console-plugins" + }, + "flags": { "required": ["FLAG_CAN_GET_CONSOLE_OPERATOR_CONFIG"] } } ] diff --git a/frontend/packages/console-app/package.json b/frontend/packages/console-app/package.json index 84fabb20d73..156fba0bd98 100644 --- a/frontend/packages/console-app/package.json +++ b/frontend/packages/console-app/package.json @@ -57,7 +57,8 @@ "consolePluginEnabledStatusDetail": "src/components/console-operator/ConsolePluginEnabledStatusDetail", "consolePluginCSPStatusDetail": "src/components/console-operator/ConsolePluginCSPStatusDetail", "consolePluginBackendDetail": "src/components/console-operator/ConsolePluginBackendDetail", - "consolePluginProxyDetail": "src/components/console-operator/ConsolePluginProxyDetail" + "consolePluginProxyDetail": "src/components/console-operator/ConsolePluginProxyDetail", + "getConsoleOperatorConfigFlag": "src/hooks/useCanGetConsoleOperatorConfig" } } } diff --git a/frontend/packages/console-app/src/consts.ts b/frontend/packages/console-app/src/consts.ts index 4838ca49ebc..75b461bbc39 100644 --- a/frontend/packages/console-app/src/consts.ts +++ b/frontend/packages/console-app/src/consts.ts @@ -5,3 +5,4 @@ export const HIDE_USER_WORKLOAD_NOTIFICATIONS_USER_SETTINGS_KEY = export const FLAG_DEVELOPER_PERSPECTIVE = 'DEVELOPER_PERSPECTIVE'; export const ACM_PERSPECTIVE_ID = 'acm'; export const ADMIN_PERSPECTIVE_ID = 'admin'; +export const FLAG_CAN_GET_CONSOLE_OPERATOR_CONFIG = 'FLAG_CAN_GET_CONSOLE_OPERATOR_CONFIG'; diff --git a/frontend/packages/console-app/src/hooks/useCanGetConsoleOperatorConfig.ts b/frontend/packages/console-app/src/hooks/useCanGetConsoleOperatorConfig.ts new file mode 100644 index 00000000000..d7f855b9e83 --- /dev/null +++ b/frontend/packages/console-app/src/hooks/useCanGetConsoleOperatorConfig.ts @@ -0,0 +1,17 @@ +import { SetFeatureFlag, useAccessReview } from '@console/dynamic-plugin-sdk'; +import { ConsoleOperatorConfigModel } from '@console/internal/models'; +import { CONSOLE_OPERATOR_CONFIG_NAME } from '@console/shared/src'; +import { FLAG_CAN_GET_CONSOLE_OPERATOR_CONFIG } from '../consts'; + +const useCanGetConsoleOperatorConfig = (setFeatureFlag: SetFeatureFlag) => { + const canGetConsoleOperatorConfig = useAccessReview({ + group: ConsoleOperatorConfigModel.apiGroup, + resource: ConsoleOperatorConfigModel.plural, + verb: 'get', + name: CONSOLE_OPERATOR_CONFIG_NAME, + }); + + setFeatureFlag(FLAG_CAN_GET_CONSOLE_OPERATOR_CONFIG, canGetConsoleOperatorConfig[0]); +}; + +export default useCanGetConsoleOperatorConfig;