diff --git a/playwright/UI/FilterTypePatch.spec.ts b/playwright/UI/FilterTypePatch.spec.ts
index 16999c796..e0082d5ee 100644
--- a/playwright/UI/FilterTypePatch.spec.ts
+++ b/playwright/UI/FilterTypePatch.spec.ts
@@ -320,8 +320,6 @@ test('Verify filter contents', async ({ page, systems }) => {
{ name: workspaceGroup!, inputType: 'checkbox' },
{ exactMatch: true },
);
- await waitForTableLoad(page);
- await page.locator('td[data-label="Name"]').first().scrollIntoViewIfNeeded();
await expect(
page
.locator('td[data-label="Name"]')
diff --git a/playwright/UI/VerifyExportingFeature.spec.ts b/playwright/UI/VerifyExportingFeature.spec.ts
index b632023cb..473ea24a6 100644
--- a/playwright/UI/VerifyExportingFeature.spec.ts
+++ b/playwright/UI/VerifyExportingFeature.spec.ts
@@ -83,7 +83,7 @@ test.describe('Verify exporting feature', () => {
const { csvData, jsonData } = await exportCsvJson(page);
- expect(csvData.length).toBe(page_count);
+ expect(csvData).toHaveLength(page_count);
const matchingCsvRow = csvData.find((row) => row.id === nameText);
expect(matchingCsvRow).toBeDefined();
@@ -97,7 +97,7 @@ test.describe('Verify exporting feature', () => {
// CSV uses "advisory_type_name" field for type
expect(matchingCsvRow!.advisory_type_name.toLowerCase()).toBe(typeText!.toLowerCase());
- expect(jsonData.length).toBe(page_count);
+ expect(jsonData).toHaveLength(page_count);
// Find matching row in JSON and validate
const matchingJsonRow = jsonData.find((row) => row.id === nameText);
@@ -132,7 +132,7 @@ test.describe('Verify exporting feature', () => {
const { csvData, jsonData } = await exportCsvJson(page);
// After filtering, we should have exactly 1 system
- expect(csvData.length).toBe(1);
+ expect(csvData).toHaveLength(1);
// Verify our created system is in the exported data
const matchingCsvRow = csvData.find((row) => row.display_name === system.name);
@@ -141,7 +141,7 @@ test.describe('Verify exporting feature', () => {
expect(matchingCsvRow!.os).toBe(osText);
expect(matchingCsvRow!.packages_installed).toBe(installedPackagesText);
- expect(jsonData.length).toBe(1);
+ expect(jsonData).toHaveLength(1);
// Find matching row in JSON and validate
const matchingJsonRow = jsonData.find((row) => row.display_name === system.name);
@@ -177,7 +177,7 @@ test.describe('Verify exporting feature', () => {
const { csvData, jsonData } = await exportCsvJson(page);
// Verify row count matches UI count
- expect(csvData.length).toBe(page_count);
+ expect(csvData).toHaveLength(page_count);
const matchingCsvRow = csvData.find((row) => row.name === nameText);
expect(matchingCsvRow).toBeDefined();
@@ -190,7 +190,7 @@ test.describe('Verify exporting feature', () => {
expect(matchingCsvRow!.summary.toLowerCase()).toContain(summaryPrefix.toLowerCase());
expect(matchingCsvRow!.systems_installed).toBe(installedSystemsText);
- expect(jsonData.length).toBe(page_count);
+ expect(jsonData).toHaveLength(page_count);
// Find matching row in JSON and validate
const matchingJsonRow = jsonData.find((row) => row.name === nameText);
diff --git a/src/PresentationalComponents/TableView/TableView.js b/src/PresentationalComponents/TableView/TableView.js
index 988bb9657..e899344ec 100644
--- a/src/PresentationalComponents/TableView/TableView.js
+++ b/src/PresentationalComponents/TableView/TableView.js
@@ -1,9 +1,9 @@
+import PropTypes from 'prop-types';
+import React, { useState, useMemo } from 'react';
import { TableVariant } from '@patternfly/react-table';
import { Table, TableBody, TableHeader } from '@patternfly/react-table/deprecated';
import { PrimaryToolbar } from '@redhat-cloud-services/frontend-components/PrimaryToolbar';
import { SkeletonTable } from '@redhat-cloud-services/frontend-components/SkeletonTable';
-import PropTypes from 'prop-types';
-import React from 'react';
import AsyncRemediationButton from '../../SmartComponents/Remediation/AsyncRemediationButton';
import { arrayFromObj, buildActiveFilterConfig, convertLimitOffset } from '../../Utilities/Helpers';
import { useRemoveFilter, useBulkSelectConfig } from '../../Utilities/hooks';
@@ -39,7 +39,7 @@ const TableView = ({
actionsToggle,
hasColumnManagement,
}) => {
- const [page, perPage] = React.useMemo(
+ const [page, perPage] = useMemo(
() => convertLimitOffset(metadata.limit, metadata.offset),
[metadata.limit, metadata.offset],
);
@@ -48,13 +48,13 @@ const TableView = ({
const selectedCount = selectedRows && arrayFromObj(selectedRows).length;
const { code, hasError, isLoading } = status;
const bulkSelectConfig = useBulkSelectConfig(selectedCount, onSelect, metadata, rows, onCollapse);
- const activeFiltersConfig = React.useMemo(
+ const activeFiltersConfig = useMemo(
() => buildActiveFilterConfig(filter, search, deleteFilters, searchChipLabel, defaultFilters),
[defaultFilters, deleteFilters, filter, search, searchChipLabel],
);
- const [isColumnMgmtModalOpen, setColumnMgmtModalOpen] = React.useState(false);
- const [appliedColumns, setAppliedColumns] = React.useState(columns);
+ const [isColumnMgmtModalOpen, setColumnMgmtModalOpen] = useState(false);
+ const [appliedColumns, setAppliedColumns] = useState(columns);
const shownColumns = hasColumnManagement
? appliedColumns?.filter((column) => column.isShown)
@@ -70,7 +70,7 @@ const TableView = ({
: rows;
return (
-
+ <>
setAppliedColumns(newColumns)}
@@ -85,7 +85,7 @@ const TableView = ({
metadata={metadata}
/>
) : (
-
+ <>
@@ -177,9 +178,9 @@ const TableView = ({
onPerPageSelect={onPerPageSelect}
paginationOUIA={`bottom-${paginationOUIA}`}
/>
-
+ >
)}
-
+ >
);
};
diff --git a/src/PresentationalComponents/TableView/__snapshots__/TableView.test.js.snap b/src/PresentationalComponents/TableView/__snapshots__/TableView.test.js.snap
index c365d3902..2ad9a9874 100644
--- a/src/PresentationalComponents/TableView/__snapshots__/TableView.test.js.snap
+++ b/src/PresentationalComponents/TableView/__snapshots__/TableView.test.js.snap
@@ -354,7 +354,7 @@ exports[`TableView Should open remediation modal 1`] = `
aria-label="Go to previous page"
class="pf-v6-c-button pf-m-plain"
data-action="previous"
- data-ouia-component-id="OUIA-Generated-Button-plain-25"
+ data-ouia-component-id="OUIA-Generated-Button-plain-27"
data-ouia-component-type="PF6/Button"
data-ouia-safe="true"
type="button"
@@ -385,7 +385,7 @@ exports[`TableView Should open remediation modal 1`] = `
aria-label="Go to next page"
class="pf-v6-c-button pf-m-plain"
data-action="next"
- data-ouia-component-id="OUIA-Generated-Button-plain-26"
+ data-ouia-component-id="OUIA-Generated-Button-plain-28"
data-ouia-component-type="PF6/Button"
data-ouia-safe="true"
type="button"
@@ -516,7 +516,7 @@ exports[`TableView Should open remediation modal 1`] = `
aria-label="Go to first page"
class="pf-v6-c-button pf-m-plain"
data-action="first"
- data-ouia-component-id="OUIA-Generated-Button-plain-27"
+ data-ouia-component-id="OUIA-Generated-Button-plain-29"
data-ouia-component-type="PF6/Button"
data-ouia-safe="true"
type="button"
@@ -547,7 +547,7 @@ exports[`TableView Should open remediation modal 1`] = `
aria-label="Go to previous page"
class="pf-v6-c-button pf-m-plain"
data-action="previous"
- data-ouia-component-id="OUIA-Generated-Button-plain-28"
+ data-ouia-component-id="OUIA-Generated-Button-plain-30"
data-ouia-component-type="PF6/Button"
data-ouia-safe="true"
type="button"
@@ -597,7 +597,7 @@ exports[`TableView Should open remediation modal 1`] = `
aria-label="Go to next page"
class="pf-v6-c-button pf-m-plain"
data-action="next"
- data-ouia-component-id="OUIA-Generated-Button-plain-29"
+ data-ouia-component-id="OUIA-Generated-Button-plain-31"
data-ouia-component-type="PF6/Button"
data-ouia-safe="true"
type="button"
@@ -628,7 +628,7 @@ exports[`TableView Should open remediation modal 1`] = `
aria-label="Go to last page"
class="pf-v6-c-button pf-m-plain"
data-action="last"
- data-ouia-component-id="OUIA-Generated-Button-plain-30"
+ data-ouia-component-id="OUIA-Generated-Button-plain-32"
data-ouia-component-type="PF6/Button"
data-ouia-safe="true"
type="button"
@@ -1686,7 +1686,7 @@ exports[`TableView TableView 2`] = `
aria-label="Go to previous page"
class="pf-v6-c-button pf-m-plain"
data-action="previous"
- data-ouia-component-id="OUIA-Generated-Button-plain-19"
+ data-ouia-component-id="OUIA-Generated-Button-plain-21"
data-ouia-component-type="PF6/Button"
data-ouia-safe="true"
type="button"
@@ -1717,7 +1717,7 @@ exports[`TableView TableView 2`] = `
aria-label="Go to next page"
class="pf-v6-c-button pf-m-plain"
data-action="next"
- data-ouia-component-id="OUIA-Generated-Button-plain-20"
+ data-ouia-component-id="OUIA-Generated-Button-plain-22"
data-ouia-component-type="PF6/Button"
data-ouia-safe="true"
type="button"
@@ -1848,7 +1848,7 @@ exports[`TableView TableView 2`] = `
aria-label="Go to first page"
class="pf-v6-c-button pf-m-plain"
data-action="first"
- data-ouia-component-id="OUIA-Generated-Button-plain-21"
+ data-ouia-component-id="OUIA-Generated-Button-plain-23"
data-ouia-component-type="PF6/Button"
data-ouia-safe="true"
type="button"
@@ -1879,7 +1879,7 @@ exports[`TableView TableView 2`] = `
aria-label="Go to previous page"
class="pf-v6-c-button pf-m-plain"
data-action="previous"
- data-ouia-component-id="OUIA-Generated-Button-plain-22"
+ data-ouia-component-id="OUIA-Generated-Button-plain-24"
data-ouia-component-type="PF6/Button"
data-ouia-safe="true"
type="button"
@@ -1929,7 +1929,7 @@ exports[`TableView TableView 2`] = `
aria-label="Go to next page"
class="pf-v6-c-button pf-m-plain"
data-action="next"
- data-ouia-component-id="OUIA-Generated-Button-plain-23"
+ data-ouia-component-id="OUIA-Generated-Button-plain-25"
data-ouia-component-type="PF6/Button"
data-ouia-safe="true"
type="button"
@@ -1960,7 +1960,7 @@ exports[`TableView TableView 2`] = `
aria-label="Go to last page"
class="pf-v6-c-button pf-m-plain"
data-action="last"
- data-ouia-component-id="OUIA-Generated-Button-plain-24"
+ data-ouia-component-id="OUIA-Generated-Button-plain-26"
data-ouia-component-type="PF6/Button"
data-ouia-safe="true"
type="button"
@@ -2439,12 +2439,46 @@ exports[`TableView test table props TableView 1`] = `
data-ouia-safe="true"
>
|
+ >
+
+
{
}, [chrome]);
const dispatch = useDispatch();
- const [firstMount, setFirstMount] = React.useState(true);
+ const [firstMount, setFirstMount] = useState(true);
const advisories = useSelector(({ AdvisoryListStore }) => AdvisoryListStore.rows);
const expandedRows = useSelector(({ AdvisoryListStore }) => AdvisoryListStore.expandedRows);
const queryParams = useSelector(({ AdvisoryListStore }) => AdvisoryListStore?.queryParams);
@@ -63,12 +63,12 @@ const Advisories = () => {
const status = useSelector(({ AdvisoryListStore }) => AdvisoryListStore.status);
const areAllSelected = useSelector(({ SystemsStore }) => SystemsStore?.areAllSelected);
- const rows = React.useMemo(
+ const rows = useMemo(
() => createAdvisoriesRows(advisories, expandedRows, selectedRows),
[advisories, expandedRows, selectedRows],
);
- const [isRemediationLoading, setRemediationLoading] = React.useState(false);
+ const [isRemediationLoading, setRemediationLoading] = useState(false);
useLayoutEffect(() => {
if (firstMount) {
@@ -80,13 +80,28 @@ const Advisories = () => {
}
}, [JSON.stringify(queryParams), firstMount]);
- const onCollapse = React.useCallback((_, rowId, value) =>
- dispatch(
- expandAdvisoryRow({
- rowId: getRowIdByIndexExpandable(advisories, rowId),
- value,
- }),
- ),
+ const onCollapse = useCallback(
+ (_, rowId, value) => {
+ let changes = [];
+ if (rowId === undefined) {
+ // toggle all
+ changes = advisories.map((advisory) => ({
+ rowId: advisory.id,
+ value,
+ }));
+ } else {
+ // toggle single
+ changes = [
+ {
+ rowId: getRowIdByIndexExpandable(advisories, rowId),
+ value,
+ },
+ ];
+ }
+
+ return dispatch(expandAdvisoryRows(changes));
+ },
+ [JSON.stringify(advisories)],
);
const onSelect = useOnSelect(rows, selectedRows, {
@@ -97,10 +112,7 @@ const Advisories = () => {
});
const onSort = useSortColumn(advisoriesColumns, apply, 2);
- const sortBy = React.useMemo(
- () => createSortBy(advisoriesColumns, metadata.sort, 2),
- [metadata.sort],
- );
+ const sortBy = useMemo(() => createSortBy(advisoriesColumns, metadata.sort, 2), [metadata.sort]);
const onExport = useOnExport(
'advisories',
@@ -127,10 +139,10 @@ const Advisories = () => {
);
return (
-
+ <>
+ <>
{intl.formatMessage(messages.titlesPatchAdvisories)}
{
/>
-
+ >
}
headerOUIA='advisories'
/>
@@ -207,7 +219,7 @@ const Advisories = () => {
hasColumnManagement
/>
-
+ >
);
};
diff --git a/src/SmartComponents/SystemAdvisories/SystemAdvisories.js b/src/SmartComponents/SystemAdvisories/SystemAdvisories.js
index 0aa96feb0..e159158a4 100644
--- a/src/SmartComponents/SystemAdvisories/SystemAdvisories.js
+++ b/src/SmartComponents/SystemAdvisories/SystemAdvisories.js
@@ -13,7 +13,7 @@ import { systemAdvisoriesColumns } from '../../PresentationalComponents/TableVie
import {
changeSystemAdvisoryListParams,
clearSystemAdvisoriesStore,
- expandSystemAdvisoryRow,
+ expandSystemAdvisoryRows,
fetchApplicableSystemAdvisories,
selectSystemAdvisoryRow,
} from '../../store/Actions/Actions';
@@ -82,13 +82,26 @@ const SystemAdvisories = ({ handleNoSystemData, inventoryId, shouldRefresh }) =>
}, [shouldRefresh]);
const onCollapse = useCallback(
- (_, rowId, value) =>
- dispatch(
- expandSystemAdvisoryRow({
- rowId: getRowIdByIndexExpandable(advisories, rowId),
+ (_, rowId, value) => {
+ let changes = [];
+ if (rowId === undefined) {
+ // toggle all
+ changes = advisories.map((advisory) => ({
+ rowId: advisory.id,
value,
- }),
- ),
+ }));
+ } else {
+ // toggle single
+ changes = [
+ {
+ rowId: getRowIdByIndexExpandable(advisories, rowId),
+ value,
+ },
+ ];
+ }
+
+ return dispatch(expandSystemAdvisoryRows(changes));
+ },
[JSON.stringify(advisories)],
);
diff --git a/src/SmartComponents/SystemDetail/__snapshots__/SystemDetail.test.js.snap b/src/SmartComponents/SystemDetail/__snapshots__/SystemDetail.test.js.snap
index cad7a9a34..e1ae5c8eb 100644
--- a/src/SmartComponents/SystemDetail/__snapshots__/SystemDetail.test.js.snap
+++ b/src/SmartComponents/SystemDetail/__snapshots__/SystemDetail.test.js.snap
@@ -431,7 +431,7 @@ exports[`SystemDetail.js Should match the snapshot when Package tab is active by
aria-label="Go to previous page"
class="pf-v6-c-button pf-m-plain"
data-action="previous"
- data-ouia-component-id="OUIA-Generated-Button-plain-8"
+ data-ouia-component-id="OUIA-Generated-Button-plain-9"
data-ouia-component-type="PF6/Button"
data-ouia-safe="true"
disabled=""
@@ -463,7 +463,7 @@ exports[`SystemDetail.js Should match the snapshot when Package tab is active by
aria-label="Go to next page"
class="pf-v6-c-button pf-m-plain"
data-action="next"
- data-ouia-component-id="OUIA-Generated-Button-plain-9"
+ data-ouia-component-id="OUIA-Generated-Button-plain-10"
data-ouia-component-type="PF6/Button"
data-ouia-safe="true"
disabled=""
@@ -520,12 +520,46 @@ exports[`SystemDetail.js Should match the snapshot when Package tab is active by
data-ouia-safe="true"
>
| |
+ >
+
+
| |
+ >
+
+
(
export function handlePatchLink(type, name, body, windowLike) {
const loc = windowLike?.location ?? (typeof location !== 'undefined' ? location : { href: '' });
if (loc.href.indexOf('inventory') === -1) {
- console.log('location.href', loc.href);
return {body === undefined ? name : body};
} else {
- console.log('document.baseURI', document.baseURI);
return {body || name};
}
}
diff --git a/src/store/ActionTypes.js b/src/store/ActionTypes.js
index 2b365b064..f7f0afb08 100644
--- a/src/store/ActionTypes.js
+++ b/src/store/ActionTypes.js
@@ -1,9 +1,9 @@
export const FETCH_APPLICABLE_ADVISORIES = 'FETCH_APPLICABLE_ADVISORIES';
-export const EXPAND_ADVISORY_ROW = 'EXPAND_ADVISORY_ROW';
+export const EXPAND_ADVISORY_ROWS = 'EXPAND_ADVISORY_ROWS';
export const SELECT_ADVISORY_ROW = 'SELECT_ADVISORY_ROW';
export const CHANGE_ADVISORY_LIST_PARAMS = 'CHANGE_ADVISORY_LIST_PARAMS';
export const CHANGE_SYSTEM_ADVISORY_LIST_PARAMS = 'CHANGE_SYSTEM_SYSTEMS_LIST_PARAMS';
-export const EXPAND_SYSTEM_ADVISORY_ROW = 'EXPAND_SYSTEM_ADVISORY_ROW';
+export const EXPAND_SYSTEM_ADVISORY_ROWS = 'EXPAND_SYSTEM_ADVISORY_ROWS';
export const FETCH_APPLICABLE_SYSTEM_ADVISORIES = 'FETCH_APPLICABLE_SYSTEM_ADVISORIES';
export const SELECT_SYSTEM_ADVISORY_ROW = 'SELECT_SYSTEM_ADVISORY_ROW';
export const CLEAR_SYSTEM_ADVISORIES = 'CLEAR_SYSTEM_ADVISORIES';
diff --git a/src/store/Actions/Actions.js b/src/store/Actions/Actions.js
index 9821b75c9..9e9f81c1e 100644
--- a/src/store/Actions/Actions.js
+++ b/src/store/Actions/Actions.js
@@ -54,13 +54,13 @@ export const changeAdvisorySystemsParams = (params) => ({
payload: params,
});
-export const expandAdvisoryRow = (rowState) => ({
- type: ActionTypes.EXPAND_ADVISORY_ROW,
+export const expandAdvisoryRows = (rowState) => ({
+ type: ActionTypes.EXPAND_ADVISORY_ROWS,
payload: rowState,
});
-export const expandSystemAdvisoryRow = (rowState) => ({
- type: ActionTypes.EXPAND_SYSTEM_ADVISORY_ROW,
+export const expandSystemAdvisoryRows = (rowState) => ({
+ type: ActionTypes.EXPAND_SYSTEM_ADVISORY_ROWS,
payload: rowState,
});
diff --git a/src/store/Reducers/AdvisoryListStore.js b/src/store/Reducers/AdvisoryListStore.js
index 6c5fb18f0..dcc80db3f 100644
--- a/src/store/Reducers/AdvisoryListStore.js
+++ b/src/store/Reducers/AdvisoryListStore.js
@@ -29,7 +29,7 @@ export const AdvisoryListStore = (state = storeListDefaultsModified, action) =>
case ActionTypes.CHANGE_ADVISORY_LIST_PARAMS:
return changeFilters(newState, action);
- case ActionTypes.EXPAND_ADVISORY_ROW:
+ case ActionTypes.EXPAND_ADVISORY_ROWS:
return expandRows(newState, action);
case ActionTypes.SELECT_ADVISORY_ROW:
diff --git a/src/store/Reducers/AdvisoryListStore.test.js b/src/store/Reducers/AdvisoryListStore.test.js
index 114b8cf33..5a9ea696d 100644
--- a/src/store/Reducers/AdvisoryListStore.test.js
+++ b/src/store/Reducers/AdvisoryListStore.test.js
@@ -7,7 +7,7 @@ import {
} from '../../Utilities/constants';
import {
CHANGE_ADVISORY_LIST_PARAMS,
- EXPAND_ADVISORY_ROW,
+ EXPAND_ADVISORY_ROWS,
FETCH_APPLICABLE_ADVISORIES,
SELECT_ADVISORY_ROW,
} from '../ActionTypes';
@@ -34,14 +34,14 @@ const error = 'Error';
describe('AdvisoryListStore tests', () => {
it.each`
- state | action | result
- ${advisoryListStoreDefaults} | ${{ type: action_fulfilled, payload: fulfilled_payload }} | ${{ ...advisoryListStoreDefaults, metadata: fulfilled_payload.meta, rows: fulfilled_payload.data, status: { code: undefined, isLoading: false, hasError: false }, error: {} }}
- ${advisoryListStoreDefaults} | ${{ type: action_pending, payload: {} }} | ${{ ...advisoryListStoreDefaults, status: { code: undefined, isLoading: true, hasError: false }, error: {} }}
- ${advisoryListStoreDefaults} | ${{ type: EXPAND_ADVISORY_ROW, payload: { rowId: 1, value: true } }} | ${{ ...advisoryListStoreDefaults, expandedRows: { 1: true } }}
- ${advisoryListStoreDefaults} | ${{ type: CHANGE_ADVISORY_LIST_PARAMS, payload: { limit: 10 } }} | ${{ ...advisoryListStoreDefaults, queryParams: { limit: 10, offset: 0 } }}
- ${advisoryListStoreDefaults} | ${{ type: SELECT_ADVISORY_ROW, payload: { id: 1, selected: true } }} | ${{ ...advisoryListStoreDefaults, selectedRows: { 1: true } }}
- ${advisoryListStoreDefaults} | ${{ type: 'NONSENSE', payload: {} }} | ${advisoryListStoreDefaults}
- ${undefined} | ${{ type: 'NONSENSE', payload: {} }} | ${advisoryListStoreDefaults}
+ state | action | result
+ ${advisoryListStoreDefaults} | ${{ type: action_fulfilled, payload: fulfilled_payload }} | ${{ ...advisoryListStoreDefaults, metadata: fulfilled_payload.meta, rows: fulfilled_payload.data, status: { code: undefined, isLoading: false, hasError: false }, error: {} }}
+ ${advisoryListStoreDefaults} | ${{ type: action_pending, payload: {} }} | ${{ ...advisoryListStoreDefaults, status: { code: undefined, isLoading: true, hasError: false }, error: {} }}
+ ${advisoryListStoreDefaults} | ${{ type: EXPAND_ADVISORY_ROWS, payload: [{ rowId: 1, value: true }] }} | ${{ ...advisoryListStoreDefaults, expandedRows: { 1: true } }}
+ ${advisoryListStoreDefaults} | ${{ type: CHANGE_ADVISORY_LIST_PARAMS, payload: { limit: 10 } }} | ${{ ...advisoryListStoreDefaults, queryParams: { limit: 10, offset: 0 } }}
+ ${advisoryListStoreDefaults} | ${{ type: SELECT_ADVISORY_ROW, payload: { id: 1, selected: true } }} | ${{ ...advisoryListStoreDefaults, selectedRows: { 1: true } }}
+ ${advisoryListStoreDefaults} | ${{ type: 'NONSENSE', payload: {} }} | ${advisoryListStoreDefaults}
+ ${undefined} | ${{ type: 'NONSENSE', payload: {} }} | ${advisoryListStoreDefaults}
`('$action', ({ state, action: { type, payload }, result }) => {
const res = AdvisoryListStore(state, { type, payload });
expect(res).toEqual(result);
diff --git a/src/store/Reducers/HelperReducers.js b/src/store/Reducers/HelperReducers.js
index 31878150c..b45befa46 100644
--- a/src/store/Reducers/HelperReducers.js
+++ b/src/store/Reducers/HelperReducers.js
@@ -17,7 +17,7 @@ export const selectRows = (state, action) => {
};
export const expandRows = (state, action) => {
- const expandedUpdated = addOrRemoveItemFromSet(state.expandedRows, [].concat(action.payload));
+ const expandedUpdated = addOrRemoveItemFromSet(state.expandedRows, action.payload);
state = { ...state, expandedRows: expandedUpdated };
return state;
};
diff --git a/src/store/Reducers/SystemAdvisoryListStore.js b/src/store/Reducers/SystemAdvisoryListStore.js
index 50b2cc936..9858dfca3 100644
--- a/src/store/Reducers/SystemAdvisoryListStore.js
+++ b/src/store/Reducers/SystemAdvisoryListStore.js
@@ -24,7 +24,7 @@ export const SystemAdvisoryListStore = (state = storeListDefaults, action) => {
case ActionTypes.CHANGE_SYSTEM_ADVISORY_LIST_PARAMS:
return changeFilters(newState, action);
- case ActionTypes.EXPAND_SYSTEM_ADVISORY_ROW:
+ case ActionTypes.EXPAND_SYSTEM_ADVISORY_ROWS:
return expandRows(newState, action);
case ActionTypes.SELECT_SYSTEM_ADVISORY_ROW:
diff --git a/src/store/Reducers/SystemAdvisoryListStore.test.js b/src/store/Reducers/SystemAdvisoryListStore.test.js
index c62d9088e..07e9e2731 100644
--- a/src/store/Reducers/SystemAdvisoryListStore.test.js
+++ b/src/store/Reducers/SystemAdvisoryListStore.test.js
@@ -8,7 +8,7 @@ import {
import {
CHANGE_SYSTEM_ADVISORY_LIST_PARAMS,
CLEAR_SYSTEM_ADVISORIES,
- EXPAND_SYSTEM_ADVISORY_ROW,
+ EXPAND_SYSTEM_ADVISORY_ROWS,
FETCH_APPLICABLE_SYSTEM_ADVISORIES,
SELECT_SYSTEM_ADVISORY_ROW,
} from '../ActionTypes';
@@ -30,15 +30,15 @@ const error = 'Error';
describe('SystemAdvisoryListStore tests', () => {
it.each`
- state | action | result
- ${storeListDefaults} | ${{ type: action_fulfilled, payload: fulfilled_payload }} | ${{ ...storeListDefaults, metadata: fulfilled_payload.meta, rows: fulfilled_payload.data, status: { code: undefined, isLoading: false, hasError: false }, error: {} }}
- ${storeListDefaults} | ${{ type: action_pending, payload: {} }} | ${{ ...storeListDefaults, status: { code: undefined, isLoading: true, hasError: false }, error: {} }}
- ${storeListDefaults} | ${{ type: EXPAND_SYSTEM_ADVISORY_ROW, payload: { rowId: 1, value: true } }} | ${{ ...storeListDefaults, expandedRows: { 1: true } }}
- ${storeListDefaults} | ${{ type: CHANGE_SYSTEM_ADVISORY_LIST_PARAMS, payload: { limit: 10 } }} | ${{ ...storeListDefaults, queryParams: { limit: 10, offset: 0, page: 1, page_size: 20 } }}
- ${storeListDefaults} | ${{ type: SELECT_SYSTEM_ADVISORY_ROW, payload: { id: 1, selected: true } }} | ${{ ...storeListDefaults, selectedRows: { 1: true } }}
- ${storeListDefaults} | ${{ type: 'NONSENSE', payload: {} }} | ${storeListDefaults}
- ${undefined} | ${{ type: 'NONSENSE', payload: {} }} | ${storeListDefaults}
- ${storeListDefaults} | ${{ type: CLEAR_SYSTEM_ADVISORIES, payload: {} }} | ${storeListDefaults}
+ state | action | result
+ ${storeListDefaults} | ${{ type: action_fulfilled, payload: fulfilled_payload }} | ${{ ...storeListDefaults, metadata: fulfilled_payload.meta, rows: fulfilled_payload.data, status: { code: undefined, isLoading: false, hasError: false }, error: {} }}
+ ${storeListDefaults} | ${{ type: action_pending, payload: {} }} | ${{ ...storeListDefaults, status: { code: undefined, isLoading: true, hasError: false }, error: {} }}
+ ${storeListDefaults} | ${{ type: EXPAND_SYSTEM_ADVISORY_ROWS, payload: [{ rowId: 1, value: true }] }} | ${{ ...storeListDefaults, expandedRows: { 1: true } }}
+ ${storeListDefaults} | ${{ type: CHANGE_SYSTEM_ADVISORY_LIST_PARAMS, payload: { limit: 10 } }} | ${{ ...storeListDefaults, queryParams: { limit: 10, offset: 0, page: 1, page_size: 20 } }}
+ ${storeListDefaults} | ${{ type: SELECT_SYSTEM_ADVISORY_ROW, payload: { id: 1, selected: true } }} | ${{ ...storeListDefaults, selectedRows: { 1: true } }}
+ ${storeListDefaults} | ${{ type: 'NONSENSE', payload: {} }} | ${storeListDefaults}
+ ${undefined} | ${{ type: 'NONSENSE', payload: {} }} | ${storeListDefaults}
+ ${storeListDefaults} | ${{ type: CLEAR_SYSTEM_ADVISORIES, payload: {} }} | ${storeListDefaults}
`('$action', ({ state, action: { type, payload }, result }) => {
const res = SystemAdvisoryListStore(state, { type, payload });
expect(res).toEqual(result);
|