Skip to content

Commit 710a0de

Browse files
[release-1.10] NETOBSERV-2398: Hide Network Traffic tab for some resources when Loki is disabled (#1052)
* hide network traffic tab when loki is not enabled * hide on just pods and services --------- Co-authored-by: Leandro Beretta <[email protected]>
1 parent be7ac91 commit 710a0de

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

web/src/components/netflow-traffic-tab.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { K8sResourceCommon } from '@openshift-console/dynamic-plugin-sdk';
1+
import { FeatureFlagHandler, K8sResourceCommon, SetFeatureFlag } from '@openshift-console/dynamic-plugin-sdk';
22
import {
33
Bullseye,
44
EmptyState,
@@ -230,4 +230,13 @@ export const NetflowTrafficTab: React.FC<NetflowTrafficTabProps> = ({ match, obj
230230
}
231231
};
232232

233+
export const featureFlagHandler: FeatureFlagHandler = (setFeatureFlag: SetFeatureFlag) => {
234+
loadConfig().then(({ config }) => {
235+
if (config) {
236+
const lokiEnabled = config.dataSources.some(ds => ds === 'loki');
237+
setFeatureFlag('NETOBSERV_LOKI_ENABLED', lokiEnabled);
238+
}
239+
});
240+
};
241+
233242
export default NetflowTrafficTab;

web/webpack.config.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ module.exports = {
106106
"handler": { "$codeRef": "networkHealth.featureFlagHandler" }
107107
}
108108
},
109+
{
110+
"type": "console.flag",
111+
"properties": {
112+
"handler": { "$codeRef": "netflowTab.featureFlagHandler" }
113+
}
114+
},
109115
{
110116
type: "console.navigation/href",
111117
properties: {
@@ -172,7 +178,8 @@ module.exports = {
172178
name: "%plugin__netobserv-plugin~Network Traffic%",
173179
"href": "netflow"
174180
}
175-
}
181+
},
182+
"flags": { "required": ["NETOBSERV_LOKI_ENABLED"] }
176183
},
177184
{
178185
type: "console.tab/horizontalNav",
@@ -189,7 +196,8 @@ module.exports = {
189196
name: "%plugin__netobserv-plugin~Network Traffic%",
190197
"href": "netflow"
191198
}
192-
}
199+
},
200+
"flags": { "required": ["NETOBSERV_LOKI_ENABLED"] }
193201
},
194202
{
195203
type: "console.tab/horizontalNav",

0 commit comments

Comments
 (0)