Skip to content

Commit

Permalink
Hide OpenShift VA behind a feature flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 committed Jun 18, 2024
1 parent 24026e7 commit b66a7c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/components/RootApp/ScalprumRoot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jest.mock('@unleash/proxy-client-react', () => {
...unleash,
useFlag: () => false,
useFlagsStatus: () => ({ flagsReady: true }),
useFlags: () => [],
};
});

Expand All @@ -54,6 +55,7 @@ import { initializeVisibilityFunctions } from '../../utils/VisibilitySingleton';
import ChromeAuthContext from '../../auth/ChromeAuthContext';
import { useHydrateAtoms } from 'jotai/utils';
import { activeModuleAtom } from '../../state/atoms/activeModuleAtom';
import { useFlags } from '@unleash/proxy-client-react';

Check failure on line 58 in src/components/RootApp/ScalprumRoot.test.js

View workflow job for this annotation

GitHub Actions / lint

'useFlags' is defined but never used

const HydrateAtoms = ({ initialValues, children }) => {
useHydrateAtoms(initialValues);
Expand Down
20 changes: 11 additions & 9 deletions src/components/Routes/VirtualAssistant.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import React, { Fragment } from 'react';
import { Route, Routes } from 'react-router-dom';
import { ScalprumComponent } from '@scalprum/react-core';
import { useFlags } from '@unleash/proxy-client-react';

import './virtual-assistant.scss';

const viableRoutes = [
'/',
'/insights/*',
'/settings/*',
'/subscriptions/overview/*',
'/subscriptions/inventory/*',
'/subscriptions/usage/*',
'/openshift/insights/*',
];
const flaggedRoutes: { [flagName: string]: string } = { 'platform.va.openshift.insights': '/openshift/insights/*' };

const VirtualAssistant = () => {
const viableRoutes = ['/', '/insights/*', '/settings/*', '/subscriptions/overview/*', '/subscriptions/inventory/*', '/subscriptions/usage/*'];

const allFlags = useFlags();
allFlags.forEach((flag) => {
if (flaggedRoutes[flag.name] && flag.enabled) {
viableRoutes.push(flaggedRoutes[flag.name]);
}
});

return (
<Routes>
{viableRoutes.map((route) => (
Expand Down

0 comments on commit b66a7c8

Please sign in to comment.