Skip to content

Commit

Permalink
Explicit paging for list of failed records (#84)
Browse files Browse the repository at this point in the history
Fixes UIHAADM-141.
  • Loading branch information
MikeTaylor authored Dec 17, 2024
1 parent 7524e40 commit db6ec11
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 11 additions & 1 deletion src/routes/RecordsRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions src/views/Records/Records.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -113,7 +113,6 @@ function Records({
<MultiColumnList
autosize
id="list-records"
virtualize
visibleColumns={visibleColumns}
columnMapping={columnMapping}
columnWidths={columnWidths}
Expand All @@ -125,6 +124,7 @@ function Records({
onNeedMoreData={onNeedMoreData}
sortedColumn={sortedColumn}
sortDirection={sortDirection}
pagingType={MCLPagingTypes.PREV_NEXT}
onRowClick={(event, rec) => updateQuery({ _path: `${packageInfo.stripes.route}/records/${rec.id}` })}
/>
<ErrorModal
Expand Down

0 comments on commit db6ec11

Please sign in to comment.