Skip to content

Commit

Permalink
fix(OperatingSystemFilter): RHINENG-2912 - Fix OS inventory filter co…
Browse files Browse the repository at this point in the history
…nversion
  • Loading branch information
bastilian committed Jan 19, 2024
1 parent 5e9c2cc commit 30e68b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Components/SmartComponents/SystemsPage/SystemsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const SystemsPage = () => {
};

const doOptOut = useOptOutSystems(onRefreshInventory);
const getEntities = useGetEntities(APIHelper.getSystems, {});
const getEntities = useGetEntities(APIHelper.getSystems, { setUrlParams });

const [columnCounter, setColumnCount] = useState(0);
useEffect(() => setColumnCount(columnCounter + 1), [columns]);
Expand Down Expand Up @@ -184,7 +184,7 @@ const SystemsPage = () => {

<Header title={intl.formatMessage(messages.vulnerabilitySystemsHeader)} showBreadcrumb={false} />
<Main>
<EdgeDevicesWarning/>
<EdgeDevicesWarning />
{isLoadingInventory ? <Spinner centered /> :
hasError && !canReadHostsInventory
? <ErrorHandler code={errorCode} />
Expand Down
14 changes: 12 additions & 2 deletions src/Helpers/Hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ export const useGetEntities = (fetchApi, { id, setUrlParams, createRows }) => {
_items,
{ orderBy, orderDirection, page, per_page: perPage, vulnerabilityParams, filters }
) => {
const osFilter = filters?.osFilter &&
Object.entries(filters.osFilter).flatMap(([, versions]) => {
// TODO This is very naive
return Object.entries(versions)
.filter(([, value]) => value === true)
.map(([osKey]) => {
const osKeyParts = osKey.split('-');
return osKeyParts[osKeyParts.length - 1];
});
});
const params = {
...vulnerabilityParams,
page,
Expand All @@ -65,8 +75,8 @@ export const useGetEntities = (fetchApi, { id, setUrlParams, createRows }) => {
...filters?.hostGroupFilter ? {
group_names: filters.hostGroupFilter.join(',')
} : {},
...filters?.osFilter?.length > 0 ? {
rhel_version: filters.osFilter.map(({ value }) => value).join(',')
...osFilter?.length > 0 ? {
rhel_version: osFilter.join(',')
} : {}
};

Expand Down

0 comments on commit 30e68b1

Please sign in to comment.