diff --git a/src/SmartComponents/Advisories/Advisories.js b/src/SmartComponents/Advisories/Advisories.js index 6d27e2de..6144d2fb 100644 --- a/src/SmartComponents/Advisories/Advisories.js +++ b/src/SmartComponents/Advisories/Advisories.js @@ -100,7 +100,8 @@ const Advisories = () => { { endpoint: ID_API_ENDPOINTS.advisories, queryParams, - selectionDispatcher: selectAdvisoryRow + selectionDispatcher: selectAdvisoryRow, + totalItems: metadata?.total_items } ); diff --git a/src/SmartComponents/AdvisorySystems/AdvisorySystems.js b/src/SmartComponents/AdvisorySystems/AdvisorySystems.js index 0052b406..95709551 100644 --- a/src/SmartComponents/AdvisorySystems/AdvisorySystems.js +++ b/src/SmartComponents/AdvisorySystems/AdvisorySystems.js @@ -102,7 +102,8 @@ const AdvisorySystems = ({ advisoryName }) => { { endpoint: ID_API_ENDPOINTS.advisorySystems(advisoryName), queryParams, - selectionDispatcher: systemSelectAction + selectionDispatcher: systemSelectAction, + totalItems } ); diff --git a/src/SmartComponents/PackageSystems/PackageSystems.js b/src/SmartComponents/PackageSystems/PackageSystems.js index 7c1a6b07..4ba3ac2b 100644 --- a/src/SmartComponents/PackageSystems/PackageSystems.js +++ b/src/SmartComponents/PackageSystems/PackageSystems.js @@ -100,7 +100,8 @@ const PackageSystems = ({ packageName }) => { queryParams, selectionDispatcher: systemSelectAction, constructFilename, - apiResponseTransformer: filterRemediatablePackageSystems + apiResponseTransformer: filterRemediatablePackageSystems, + totalItems } ); diff --git a/src/SmartComponents/PatchSet/PatchSet.js b/src/SmartComponents/PatchSet/PatchSet.js index d18ff445..2ce399f9 100644 --- a/src/SmartComponents/PatchSet/PatchSet.js +++ b/src/SmartComponents/PatchSet/PatchSet.js @@ -106,7 +106,8 @@ const PatchSet = () => { { endpoint: ID_API_ENDPOINTS.templates, queryParams, - selectionDispatcher: selectPatchSetRow + selectionDispatcher: selectPatchSetRow, + totalItems: metadata.total_items } ); diff --git a/src/SmartComponents/SystemPackages/SystemPackages.js b/src/SmartComponents/SystemPackages/SystemPackages.js index ef1f274d..511ffb7f 100644 --- a/src/SmartComponents/SystemPackages/SystemPackages.js +++ b/src/SmartComponents/SystemPackages/SystemPackages.js @@ -78,7 +78,8 @@ const SystemPackages = ({ handleNoSystemData, inventoryId, shouldRefresh }) => { queryParams, selectionDispatcher: selectSystemPackagesRow, constructFilename, - transformKey + transformKey, + totalItems: metadata?.total_items } ); diff --git a/src/SmartComponents/Systems/SystemsMainContent.js b/src/SmartComponents/Systems/SystemsMainContent.js index 74214d1d..dac67ac8 100644 --- a/src/SmartComponents/Systems/SystemsMainContent.js +++ b/src/SmartComponents/Systems/SystemsMainContent.js @@ -58,7 +58,11 @@ const SystemsMainContent = () => { return ( - + {isRemediationOpen && { const { fetchBatched } = useFetchBatched(); - return useCallback((queryParams) => - fetchBatched( - (__, pagination) => fetchIDs(endpoint, { ...queryParams, ...pagination }), + return useCallback(async (queryParams) => { + const response = await fetchBatched( + (filter) => fetchIDs(endpoint, filter), + queryParams, totalItems, - queryParams - ) - .then(response => - apiResponseTransformer ? apiResponseTransformer(response) : response - ), + 100 + ); + + const aggregatedResponse = response.flatMap(({ data, ids }) => + data ? + data.flatMap(({ id }) => id) + : ids + ); + return apiResponseTransformer ? apiResponseTransformer(aggregatedResponse) : aggregatedResponse; + }, [totalItems, endpoint]); }; const useCreateSelectedRow = (transformKey, constructFilename) => useCallback((rows, toSelect = []) => { - const { ids, data } = rows; - const shouldUseOnlyIDs = Array.isArray(ids); - const items = shouldUseOnlyIDs ? ids : data; + const items = rows; items.forEach((item) => { - const id = shouldUseOnlyIDs ? item : item.id; - //expanded rows does not have ID and should be disabled for selection if (!(isObject(item) && item.isExpandedRow)) { toSelect.push( { - id: transformKey ? transformKey(item) : id, - selected: constructFilename ? constructFilename(item) : id + id: transformKey ? transformKey(item) : item, + selected: constructFilename ? constructFilename(item) : item } ); } @@ -86,7 +88,6 @@ const createSelectors = ( }; const selectAll = (fetchIDs, queryParams) => { - queryParams.offset = 0; return fetchIDs(queryParams).then(response => { if (Array.isArray(response.data)) { let rowsToSelect = response.data.filter(row => row.status !== 'Applicable');