Skip to content

Commit a1b2140

Browse files
committed
NETOBSERV-2400: Implement alerts feature gate
1 parent c7c88cf commit a1b2140

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

web/src/components/health/network-health.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AlertStates, Rule } from '@openshift-console/dynamic-plugin-sdk';
1+
import { AlertStates, FeatureFlagHandler, Rule, SetFeatureFlag } from '@openshift-console/dynamic-plugin-sdk';
22
import { Button, Flex, FlexItem, PageSection, Tab, Tabs, TextVariants, Title } from '@patternfly/react-core';
33
import { SyncAltIcon } from '@patternfly/react-icons';
44
import * as _ from 'lodash';
@@ -18,6 +18,7 @@ import { HealthGlobal } from './health-global';
1818
import { buildStats, isSilenced } from './health-helper';
1919
import { HealthSummary } from './health-summary';
2020
import { HealthTabTitle } from './tab-title';
21+
import { loadConfig } from '../../utils/config';
2122

2223
import './health.css';
2324

@@ -175,5 +176,14 @@ export const NetworkHealth: React.FC<{}> = ({}) => {
175176
);
176177
};
177178

179+
export const featureFlagHandler: FeatureFlagHandler = (setFeatureFlag: SetFeatureFlag) => {
180+
loadConfig().then(({ config }) => {
181+
if (config) {
182+
const enabled = config.features.includes('experimentalAlertsHealth');
183+
setFeatureFlag('NETOBSERV_NETWORK_HEALTH', enabled);
184+
}
185+
});
186+
};
187+
178188
NetworkHealth.displayName = 'NetworkHealth';
179189
export default NetworkHealth;

web/src/model/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export type Feature =
1414
| 'udnMapping'
1515
| 'packetTranslation'
1616
| 'networkEvents'
17-
| 'ipsec';
17+
| 'ipsec'
18+
| 'experimentalAlertsHealth';
1819

1920
export type Config = {
2021
buildVersion: string;

web/webpack.config.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ module.exports = {
100100
},
101101
},
102102
extensions: [
103+
{
104+
"type": "console.flag",
105+
"properties": {
106+
"handler": { "$codeRef": "networkHealth.featureFlagHandler" }
107+
}
108+
},
103109
{
104110
type: "console.navigation/href",
105111
properties: {
@@ -108,7 +114,8 @@ module.exports = {
108114
"section": "observe",
109115
name: "%plugin__netobserv-plugin~Network Health%",
110116
"href": "/network-health"
111-
}
117+
},
118+
"flags": { "required": ["NETOBSERV_NETWORK_HEALTH"] }
112119
},
113120
{
114121
type: "console.navigation/href",
@@ -147,7 +154,8 @@ module.exports = {
147154
component: {
148155
"$codeRef": "networkHealth.default"
149156
}
150-
}
157+
},
158+
"flags": { "required": ["NETOBSERV_NETWORK_HEALTH"] }
151159
},
152160
{
153161
type: "console.tab/horizontalNav",

0 commit comments

Comments
 (0)