From a1b2140940c18e4b49be6d23e0910840348aa2bc Mon Sep 17 00:00:00 2001 From: Joel Takvorian Date: Fri, 12 Sep 2025 09:31:26 +0200 Subject: [PATCH 1/2] NETOBSERV-2400: Implement alerts feature gate --- web/src/components/health/network-health.tsx | 12 +++++++++++- web/src/model/config.ts | 3 ++- web/webpack.config.ts | 12 ++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/web/src/components/health/network-health.tsx b/web/src/components/health/network-health.tsx index 95bce61d5..ef76cfb57 100644 --- a/web/src/components/health/network-health.tsx +++ b/web/src/components/health/network-health.tsx @@ -1,4 +1,4 @@ -import { AlertStates, Rule } from '@openshift-console/dynamic-plugin-sdk'; +import { AlertStates, FeatureFlagHandler, Rule, SetFeatureFlag } from '@openshift-console/dynamic-plugin-sdk'; import { Button, Flex, FlexItem, PageSection, Tab, Tabs, TextVariants, Title } from '@patternfly/react-core'; import { SyncAltIcon } from '@patternfly/react-icons'; import * as _ from 'lodash'; @@ -18,6 +18,7 @@ import { HealthGlobal } from './health-global'; import { buildStats, isSilenced } from './health-helper'; import { HealthSummary } from './health-summary'; import { HealthTabTitle } from './tab-title'; +import { loadConfig } from '../../utils/config'; import './health.css'; @@ -175,5 +176,14 @@ export const NetworkHealth: React.FC<{}> = ({}) => { ); }; +export const featureFlagHandler: FeatureFlagHandler = (setFeatureFlag: SetFeatureFlag) => { + loadConfig().then(({ config }) => { + if (config) { + const enabled = config.features.includes('experimentalAlertsHealth'); + setFeatureFlag('NETOBSERV_NETWORK_HEALTH', enabled); + } + }); +}; + NetworkHealth.displayName = 'NetworkHealth'; export default NetworkHealth; diff --git a/web/src/model/config.ts b/web/src/model/config.ts index 471ef300f..32e951bf3 100644 --- a/web/src/model/config.ts +++ b/web/src/model/config.ts @@ -14,7 +14,8 @@ export type Feature = | 'udnMapping' | 'packetTranslation' | 'networkEvents' - | 'ipsec'; + | 'ipsec' + | 'experimentalAlertsHealth'; export type Config = { buildVersion: string; diff --git a/web/webpack.config.ts b/web/webpack.config.ts index 404d1c805..a3cbda90a 100644 --- a/web/webpack.config.ts +++ b/web/webpack.config.ts @@ -100,6 +100,12 @@ module.exports = { }, }, extensions: [ + { + "type": "console.flag", + "properties": { + "handler": { "$codeRef": "networkHealth.featureFlagHandler" } + } + }, { type: "console.navigation/href", properties: { @@ -108,7 +114,8 @@ module.exports = { "section": "observe", name: "%plugin__netobserv-plugin~Network Health%", "href": "/network-health" - } + }, + "flags": { "required": ["NETOBSERV_NETWORK_HEALTH"] } }, { type: "console.navigation/href", @@ -147,7 +154,8 @@ module.exports = { component: { "$codeRef": "networkHealth.default" } - } + }, + "flags": { "required": ["NETOBSERV_NETWORK_HEALTH"] } }, { type: "console.tab/horizontalNav", From 15e9fff23a5c562dd737097ad3d51fe97f708678 Mon Sep 17 00:00:00 2001 From: Joel Takvorian Date: Mon, 22 Sep 2025 14:42:18 +0200 Subject: [PATCH 2/2] fix linter --- web/src/components/health/network-health.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/components/health/network-health.tsx b/web/src/components/health/network-health.tsx index ef76cfb57..8b8502c8c 100644 --- a/web/src/components/health/network-health.tsx +++ b/web/src/components/health/network-health.tsx @@ -7,6 +7,7 @@ import * as React from 'react'; import { useTranslation } from 'react-i18next'; import { SilenceMatcher } from '../../api/alert'; import { getAlerts, getSilencedAlerts } from '../../api/routes'; +import { loadConfig } from '../../utils/config'; import { getHTTPErrorDetails } from '../../utils/errors'; import { localStorageHealthRefreshKey, useLocalStorage } from '../../utils/local-storage-hook'; import { usePoll } from '../../utils/poll-hook'; @@ -18,7 +19,6 @@ import { HealthGlobal } from './health-global'; import { buildStats, isSilenced } from './health-helper'; import { HealthSummary } from './health-summary'; import { HealthTabTitle } from './tab-title'; -import { loadConfig } from '../../utils/config'; import './health.css';