Skip to content

Commit

Permalink
fix(ESSNTL-4494): Fix group column and filter
Browse files Browse the repository at this point in the history
  • Loading branch information
gkarat authored Sep 1, 2023
1 parent f54054c commit 72c1e57
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 50 deletions.
39 changes: 0 additions & 39 deletions src/PresentationalComponents/Filters/GroupsFilter.js

This file was deleted.

8 changes: 2 additions & 6 deletions src/SmartComponents/Systems/Systems.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ import { useOnSelect, ID_API_ENDPOINTS } from '../../Utilities/useOnSelect';
import { combineReducers } from 'redux';
import { systemsColumnsMerger } from '../../Utilities/SystemsHelpers';
import { useChrome } from '@redhat-cloud-services/frontend-components/useChrome';
import useGroupsFilter from '../../PresentationalComponents/Filters/GroupsFilter';
import useFeatureFlag from '../../Utilities/useFeatureFlag';

const Systems = () => {
const store = useStore();
Expand Down Expand Up @@ -85,7 +83,6 @@ const Systems = () => {
apply(decodedParams);
return () => dispatch(clearInventoryReducer());
}, []);
const groupsEnabled = useFeatureFlag('hbi.ui.inventory-groups');

const showRemediationModal = useCallback(async (data) => {
const resolvedData = await data;
Expand All @@ -112,8 +109,7 @@ const Systems = () => {
const [deleteFilters] = useRemoveFilter({ search, ...filter }, apply, systemsListDefaultFilters);

const osFilterConfig = useOsVersionFilter(filter?.os, apply);
const groupsFilterConfig = useGroupsFilter(filter?.group_name, apply, groupsEnabled);
const filterConfig = buildFilterConfig(search, filter, apply, osFilterConfig, groupsFilterConfig, groupsEnabled);
const filterConfig = buildFilterConfig(search, filter, apply, osFilterConfig);

const activeFiltersConfig = buildActiveFiltersConfig(filter, search, deleteFilters);

Expand Down Expand Up @@ -168,7 +164,7 @@ const Systems = () => {
isFullView
autoRefresh
initialLoading
hideFilters={{ all: true, tags: false }}
hideFilters={{ all: true, tags: false, hostGroupFilter: false }}
columns={(defaultColumns) => systemsColumnsMerger(defaultColumns, systemsListColumns)}
showTags
customFilters={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ exports[`Systems.js should match the snapshot 1`] = `
hideFilters={
Object {
"all": true,
"hostGroupFilter": false,
"tags": false,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Utilities/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ export const encodeParams = (parameters, shouldTranslateKeys) => {
return result;
};

let { filter, systemProfile = {}, ...allParams } = parameters;
let { filter, systemProfile = {}, group_name, ...allParams } = parameters;

allParams = { ...allParams, ...flattenFilters(filter) };
allParams = { ...allParams, ...flattenFilters({ ...filter, ...(group_name ? { group_name } : {}) }) };
let params = [];
Object.keys(allParams).forEach(key => {
const argKey = encodeURIComponent(key);
Expand Down
5 changes: 5 additions & 0 deletions src/Utilities/Hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ export const useGetEntities = (fetchApi, apply, config, setSearchParams, applyMe
page,
perPage,
...patchParams,
filter: {
...patchParams.filter,
...(Array.isArray(filters.hostGroupFilter) && filters.hostGroupFilter.length > 0
? { group_name: filters.hostGroupFilter }
: {}) },
selectedTags: [...activeTags, ...selectedTags],
sort,
...id && { id } || {},
Expand Down
5 changes: 2 additions & 3 deletions src/Utilities/SystemsHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { defaultCompoundSortValues } from './constants';
import { patchSetDetailColumns } from '../SmartComponents/PatchSetDetail/PatchSetDetailAssets';
import { InsightsLink } from '@redhat-cloud-services/frontend-components/InsightsLink';

export const buildFilterConfig = (search, filter, apply, osFilterConfig, groupsFilterConfig, isGroupsEnabled) => {
export const buildFilterConfig = (search, filter, apply, osFilterConfig) => {
return {
items: [
searchFilter(
Expand All @@ -23,8 +23,7 @@ export const buildFilterConfig = (search, filter, apply, osFilterConfig, groupsF
),
staleFilter(apply, filter),
systemsUpdatableFilter(apply, filter),
...osFilterConfig,
...(isGroupsEnabled ? [groupsFilterConfig] : [])
...osFilterConfig
]
};
};
Expand Down

0 comments on commit 72c1e57

Please sign in to comment.