diff --git a/src/components/InventoryTable/EntityTableToolbar.test.js b/src/components/InventoryTable/EntityTableToolbar.test.js index 8a6b2fcc0..57b853b6e 100644 --- a/src/components/InventoryTable/EntityTableToolbar.test.js +++ b/src/components/InventoryTable/EntityTableToolbar.test.js @@ -330,7 +330,7 @@ describe('EntityTableToolbar', () => { ); wrapper.find('.ins-c-chip-filters button.pf-m-link').last().simulate('click'); const actions = store.getActions(); - expect(actions.length).toBe(4); + expect(actions.length).toBe(3); expect(actions[actions.length - 2]).toMatchObject({ type: 'CLEAR_FILTERS' }); expect(onRefreshData).toHaveBeenCalledWith({ filters: [], page: 1 }); }); diff --git a/src/components/filters/useGroupFilter.js b/src/components/filters/useGroupFilter.js index 44a3d2b98..7890ce2db 100644 --- a/src/components/filters/useGroupFilter.js +++ b/src/components/filters/useGroupFilter.js @@ -4,6 +4,7 @@ import { useEffect, useMemo, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { fetchGroups } from '../../store/inventory-actions'; import { HOST_GROUP_CHIP } from '../../Utilities/index'; +import useFeatureFlag from '../../Utilities/useFeatureFlag'; //for attaching this filter to the redux export const groupFilterState = { groupHostFilter: null }; @@ -31,9 +32,13 @@ export const buildHostGroupChips = (selectedGroups = []) => { const useGroupFilter = (apiParams = []) => { const dispatch = useDispatch(); + const groupsEnabled = useFeatureFlag('hbi.ui.inventory-groups'); + useEffect(() => { - dispatch(fetchGroups(apiParams)); - }, []); + if (groupsEnabled === true) { + dispatch(fetchGroups(apiParams)); + } + }, [groupsEnabled]); //fetched values const fetchedValues = useSelector(({ groups }) => groups?.data?.results); //selected are the groups we selected diff --git a/src/components/filters/useGroupFilter.test.js b/src/components/filters/useGroupFilter.test.js index 0c7e6880a..24b9e8604 100644 --- a/src/components/filters/useGroupFilter.test.js +++ b/src/components/filters/useGroupFilter.test.js @@ -6,6 +6,11 @@ import { createPromise as promiseMiddleware } from 'redux-promise-middleware'; import { mockSystemProfile } from '../../__mocks__/hostApi'; import useGroupFilter from './useGroupFilter'; +jest.mock('../../Utilities/useFeatureFlag', () => ({ + __esModule: true, + default: () => true +})); + describe('useGroupFilter', () => { const mockStore = configureStore([promiseMiddleware()]); beforeEach(() => { diff --git a/src/routes/InventoryTable.js b/src/routes/InventoryTable.js index 5df03787f..d9327a683 100644 --- a/src/routes/InventoryTable.js +++ b/src/routes/InventoryTable.js @@ -326,13 +326,16 @@ const Inventory = ({ onEditOpen(false); }} /> - console.log('data reloaded')} - /> + { + groupsEnabled === true && + console.log('data reloaded')} + /> + } ); };