Skip to content

Commit

Permalink
refactor(ESSNTL-3724): Connect /groups to FF (#1762)
Browse files Browse the repository at this point in the history
This makes Inventory hide /groups page component if the feature flag is
set to false.
  • Loading branch information
gkarat authored Feb 8, 2023
1 parent ce854fe commit 3f9d4ce
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/Routes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Route, Redirect, Switch } from 'react-router-dom';
import React, { lazy, Suspense, useMemo } from 'react';
import { EmptyState, EmptyStateBody } from '@patternfly/react-core';
import { InvalidObject } from '@redhat-cloud-services/frontend-components';
import { getSearchParams } from './constants';
import RenderWrapper from './Utilities/Wrapper';
import useFeatureFlag from './Utilities/useFeatureFlag';

const InventoryTable = lazy(() => import('./routes/InventoryTable'));
const InventoryDetail = lazy(() => import('./routes/InventoryDetail'));
Expand All @@ -16,6 +19,8 @@ export const routes = {

export const Routes = () => {
const searchParams = useMemo(() => getSearchParams(), []);
const groupsEnabled = useFeatureFlag('hbi.ui.inventory-groups');

return (
<Suspense fallback="">
<Switch>
Expand All @@ -30,7 +35,22 @@ export const Routes = () => {
/>}
rootClass='inventory'
/>
<Route exact path={routes.groups} component={InventoryGroups} rootClass='inventory' />
<Route
exact
path={routes.groups}
component={
groupsEnabled
? InventoryGroups
: () => (
<EmptyState>
<EmptyStateBody>
<InvalidObject />
</EmptyStateBody>
</EmptyState>
)
}
rootClass="inventory"
/>
<Route exact path={routes.detailWithModal} component={InventoryDetail} rootClass='inventory' />
<Route exact path={routes.detail} component={InventoryDetail} rootClass='inventory' />
<Redirect path="*" to="/" />
Expand Down

0 comments on commit 3f9d4ce

Please sign in to comment.