diff --git a/web/src/components/health/network-health.tsx b/web/src/components/health/network-health.tsx index 95bce61d5..8b8502c8c 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'; @@ -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'; @@ -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",