Skip to content

Commit

Permalink
fix: THEEDGE-3298 - Remove edge host_type filter from conventional tab (
Browse files Browse the repository at this point in the history
RedHatInsights#1962)

* add host_type filter to remove edge from conventional tab

* add validation to systemUpdate filter

* move the validation to useUpdateMethodFilter

* fix lint

* feat(RHIF-254) Add Zero State to Inventory (RedHatInsights#1951)

* add feature flag to useUpdateMethod and update test snapshot

* update snapshots

* move from splice to filter when value not rpm-ostree

---------

Co-authored-by: Adonis Puente <[email protected]>
  • Loading branch information
2 people authored and bastilian committed Aug 11, 2023
1 parent a02e399 commit 3bbe66d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Utilities/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ export const rhcdOptions = [
{ label: 'Inactive', value: 'nil' },
];

export const updateMethodOptions = [
const initUpdateMethodOptions = [
{ label: 'yum', value: 'yum' },
{ label: 'dnf', value: 'dnf' },
{ label: 'rpm-ostree', value: 'rpm-ostree' },
];

export const updateMethodOptions = initUpdateMethodOptions;

export function filterToGroup(filter = [], valuesKey = 'values') {
return filter.reduce(
(accGroup, group) => ({
Expand Down
4 changes: 4 additions & 0 deletions src/components/filters/useUpdateMethod.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { useUpdateMethodFilter } from './useUpdateMethodFilter';
import { UPDATE_METHOD_KEY, updateMethodOptions } from '../../Utilities';
import { mount } from 'enzyme';

jest.mock('../../Utilities/useFeatureFlag', () => ({
__esModule: true,
default: () => false,
}));
const HookRender = ({ hookAccessor, hookNotify }) => {
const [filter, chip, value, setValue] = useUpdateMethodFilter();
useEffect(() => {
Expand Down
17 changes: 15 additions & 2 deletions src/components/filters/useUpdateMethodFilter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { useState } from 'react';
import { UPDATE_METHOD_KEY, updateMethodOptions } from '../../Utilities/index';
import { useMemo, useState } from 'react';
import {
UPDATE_METHOD_KEY,
updateMethodOptions as defaultUpdateMethodOptions,
} from '../../Utilities/index';
import useFeatureFlag from '../../Utilities/useFeatureFlag';

export const updateMethodFilterState = { updateMethodFilter: null };
export const UPDATE_METHOD_FILTER = 'UPDATE_METHOD_FILTER';
Expand All @@ -12,6 +16,15 @@ export const updateMethodFilterReducer = (_state, { type, payload }) => ({
export const useUpdateMethodFilter = (
[state, dispatch] = [updateMethodFilterState]
) => {
const EdgeParityFilterDeviceEnabled = useFeatureFlag(
'edgeParity.inventory-list-filter'
);
const updateMethodOptions = useMemo(() => {
return EdgeParityFilterDeviceEnabled
? defaultUpdateMethodOptions.filter(({ value }) => value !== 'rpm-ostree')
: defaultUpdateMethodOptions;
}, [EdgeParityFilterDeviceEnabled]);

let [filterStateValue, setStateValue] = useState([]);
const updateMethodValue = dispatch
? state.updateMethodFilter
Expand Down
5 changes: 4 additions & 1 deletion src/routes/InventoryTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ const Inventory = ({
};

const EdgeParityEnabled = useFeatureFlag('edgeParity.inventory-list');

const EdgeParityFilterDeviceEnabled = useFeatureFlag(
'edgeParity.inventory-list-filter'
);
useEffect(() => {
chrome.updateDocumentTitle('Systems | Red Hat Insights');
chrome?.hideGlobalFilter?.(false);
Expand All @@ -242,6 +244,7 @@ const Inventory = ({
...(workloads?.['Microsoft SQL']?.isSelected && {
mssql: 'not_nil',
}),
...(EdgeParityFilterDeviceEnabled && { host_type: 'nil' }),
...(SID?.length > 0 && { sap_sids: SID }),
},
},
Expand Down

0 comments on commit 3bbe66d

Please sign in to comment.