From db6ec118e5dffde3fd02fc5f1d8e0123de94484e Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Tue, 17 Dec 2024 18:35:56 +0000 Subject: [PATCH] Explicit paging for list of failed records (#84) Fixes UIHAADM-141. --- CHANGELOG.md | 1 + src/routes/RecordsRoute.js | 12 +++++++++++- src/views/Records/Records.js | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66dbdee..67157e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Update permission names to encompass logfile-deletion threshold. Fixes UIHAADM-135. * Set up internationalization for permission names. Fixes UIHAADM-138. * Add Settings page for log-file time-deletion threshold. Fixes UIHAADM-136. +* Explicit paging for list of failed records. Fixes UIHAADM-141. ## [2.1.0](https://github.com/folio-org/ui-harvester-admin/tree/v2.1.0) (2024-02-28) diff --git a/src/routes/RecordsRoute.js b/src/routes/RecordsRoute.js index 81057a1..f4f1ca6 100644 --- a/src/routes/RecordsRoute.js +++ b/src/routes/RecordsRoute.js @@ -19,7 +19,13 @@ const RecordsRoute = ({ stripes, resources, mutator, children }) => { source.update({ resources, mutator }, 'reportTitles'); } - const handleNeedMoreData = () => source.fetchMore(RESULT_COUNT_INCREMENT); + const handleNeedMoreData = (_askAmount, index, _firstIndex, _direction) => { + if (index >= 0) { + source.fetchOffset(index); + } else { + source.fetchMore(RESULT_COUNT_INCREMENT); + } + }; const hasLoaded = resources.records.hasLoaded; const error = resources.records.failed ? resources.records.failed.message : undefined; @@ -45,13 +51,17 @@ const RecordsRoute = ({ stripes, resources, mutator, children }) => { RecordsRoute.manifest = Object.freeze({ query: {}, resultCount: { initialValue: INITIAL_RESULT_COUNT }, + resultOffset: { initialValue: 0 }, records: { type: 'okapi', path: 'harvester-admin/previous-jobs/failed-records', throwErrors: false, records: 'failedRecords', recordsRequired: '%{resultCount}', + resultOffset: '%{resultOffset}', perRequest: RESULT_COUNT_INCREMENT, + resultDensity: 'sparse', + accumulate: 'true', params: { // Modify the query-function to remove unwanted asterisks after ID searches query: (queryParams, pathComponents, rv, logger) => { diff --git a/src/views/Records/Records.js b/src/views/Records/Records.js index aa7d315..04dd7c7 100644 --- a/src/views/Records/Records.js +++ b/src/views/Records/Records.js @@ -2,7 +2,7 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage, useIntl } from 'react-intl'; import { AppIcon } from '@folio/stripes/core'; -import { MenuSection, Button, Icon, LoadingPane, Paneset, Pane, MultiColumnList, ErrorModal, exportToCsv } from '@folio/stripes/components'; +import { MenuSection, Button, Icon, LoadingPane, Paneset, Pane, MultiColumnList, ErrorModal, exportToCsv, MCLPagingTypes } from '@folio/stripes/components'; import { ColumnManager, SearchAndSortQuery } from '@folio/stripes/smart-components'; import parseSort from '../../util/parseSort'; import { errors2react, errors2string } from '../../util/summarizeErrors'; @@ -113,7 +113,6 @@ function Records({ updateQuery({ _path: `${packageInfo.stripes.route}/records/${rec.id}` })} />