From d360856abe9411895a6c4cc30ed0e7393699cc26 Mon Sep 17 00:00:00 2001
From: Muslimjon <59481011+mkholjuraev@users.noreply.github.com>
Date: Tue, 14 Feb 2023 19:22:14 +0100
Subject: [PATCH] chore(RHIF-169): hide system update method filter untill API
is ready (#1764)
---
.../InventoryTable/EntityTableToolbar.js | 8 +++++++-
.../InventoryTable/EntityTableToolbar.test.js | 16 ++++++++++++++++
.../InventoryTable/InventoryTable.test.js | 4 ++++
.../InventoryTableInitialLoading.test.js | 1 +
src/routes/InventoryTable.test.js | 1 +
5 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/components/InventoryTable/EntityTableToolbar.js b/src/components/InventoryTable/EntityTableToolbar.js
index 88f9b5bd6..95f6b486f 100644
--- a/src/components/InventoryTable/EntityTableToolbar.js
+++ b/src/components/InventoryTable/EntityTableToolbar.js
@@ -43,6 +43,7 @@ import {
updateMethodFilterState
} from '../filters';
import useOperatingSystemFilter from '../filters/useOperatingSystemFilter';
+import useFeatureFlag from '../../Utilities/useFeatureFlag';
/**
* Table toolbar used at top of inventory table.
@@ -100,6 +101,8 @@ const EntityTableToolbar = ({
const [osFilterConfig, osFilterChips, osFilterValue, setOsFilterValue] = useOperatingSystemFilter();
const [updateMethodConfig, updateMethodChips, updateMethodValue, setUpdateMethodValue] = useUpdateMethodFilter(reducer);
+ const isUpdateMethodEnabled = useFeatureFlag('hbi.ui.system-update-method');
+
const {
tagsFilter,
tagsChip,
@@ -127,7 +130,10 @@ const EntityTableToolbar = ({
operatingSystem: !(hideFilters.all && hideFilters.operatingSystem !== false) && !hideFilters.operatingSystem,
tags: !(hideFilters.all && hideFilters.tags !== false) && !hideFilters.tags,
rhcdFilter: !(hideFilters.all && hideFilters.rhcdFilter !== false) && !hideFilters.rhcdFilter,
- updateMethodFilter: !(hideFilters.all && hideFilters.updateMethodFilter !== false) && !hideFilters.updateMethodFilter
+ //hides the filter untill API is ready. JIRA: RHIF-169
+ updateMethodFilter: isUpdateMethodEnabled &&
+ !(hideFilters.all && hideFilters.updateMethodFilter !== false)
+ && !hideFilters.updateMethodFilter
};
/**
diff --git a/src/components/InventoryTable/EntityTableToolbar.test.js b/src/components/InventoryTable/EntityTableToolbar.test.js
index 8fc6c7650..4e0ea53af 100644
--- a/src/components/InventoryTable/EntityTableToolbar.test.js
+++ b/src/components/InventoryTable/EntityTableToolbar.test.js
@@ -10,8 +10,10 @@ import toJson from 'enzyme-to-json';
import { mockTags, mockSystemProfile } from '../../__mocks__/hostApi';
import TitleColumn from './TitleColumn';
import debounce from 'lodash/debounce';
+import useFeatureFlag from '../../Utilities/useFeatureFlag';
jest.mock('lodash/debounce');
+jest.mock('../../Utilities/useFeatureFlag');
describe('EntityTableToolbar', () => {
let initialState;
@@ -92,6 +94,8 @@ describe('EntityTableToolbar', () => {
});
describe('DOM', () => {
+ useFeatureFlag.mockReturnValue(true);
+
it('should render correctly - no data', () => {
const store = mockStore({
entities: {
@@ -386,4 +390,16 @@ describe('EntityTableToolbar', () => {
expect(toJson(wrapper.find('Test Reset Filter'))).toBeFalsy();
});
});
+
+ describe('System update method filter', () => {
+ it('Should hide the filter when flag is disabled', () => {
+ useFeatureFlag.mockReturnValue(false);
+ const store = mockStore(initialState);
+ const wrapper = mount(
+
+ );
+ expect(toJson(wrapper.find('System Update Method'))).toBeFalsy();
+ });
+ });
});
diff --git a/src/components/InventoryTable/InventoryTable.test.js b/src/components/InventoryTable/InventoryTable.test.js
index 6c2cb1edf..64d25be34 100644
--- a/src/components/InventoryTable/InventoryTable.test.js
+++ b/src/components/InventoryTable/InventoryTable.test.js
@@ -12,6 +12,9 @@ import toJson from 'enzyme-to-json';
import { ConditionalFilter } from '@redhat-cloud-services/frontend-components/ConditionalFilter';
import * as loadSystems from '../../Utilities/sharedFunctions';
import { mockSystemProfile } from '../../__mocks__/hostApi';
+import useFeatureFlag from '../../Utilities/useFeatureFlag';
+
+jest.mock('../../Utilities/useFeatureFlag');
describe('InventoryTable', () => {
let initialState;
@@ -208,6 +211,7 @@ describe('InventoryTable', () => {
});
it('should disable only one filter', () => {
+ useFeatureFlag.mockReturnValue(true);
const store = mockStore(initialState);
const wrapper = mount(
diff --git a/src/components/InventoryTable/InventoryTableInitialLoading.test.js b/src/components/InventoryTable/InventoryTableInitialLoading.test.js
index 0594fcd8c..e5370a8dc 100644
--- a/src/components/InventoryTable/InventoryTableInitialLoading.test.js
+++ b/src/components/InventoryTable/InventoryTableInitialLoading.test.js
@@ -16,6 +16,7 @@ import debounce from 'lodash/debounce';
import { mockSystemProfile } from '../../__mocks__/hostApi';
jest.mock('lodash/debounce');
+jest.mock('../../Utilities/useFeatureFlag');
describe('InventoryTable - initial loading', () => {
let initialState;
diff --git a/src/routes/InventoryTable.test.js b/src/routes/InventoryTable.test.js
index 14c2b4868..ad3166c63 100644
--- a/src/routes/InventoryTable.test.js
+++ b/src/routes/InventoryTable.test.js
@@ -36,6 +36,7 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
on: jest.fn()
})
}));
+jest.mock('../Utilities/useFeatureFlag');
describe('InventoryTable', () => {
let mockStore;