Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIBULKED-588 Add additional conditions for preview showing #682

Merged
merged 4 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const BulkEditPreviewModalList = ({
showErrorMessage(error);
onPreviewError();
},
onSettled: onPreviewSettled,
onSuccess: onPreviewSettled,
},
...pagination,
});
Expand Down
18 changes: 11 additions & 7 deletions src/components/BulkEditPane/BulkEditListResult/Preview/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
CRITERIA,
EDITING_STEPS,
PAGINATION_CONFIG,
ERRORS_PAGINATION_CONFIG
ERRORS_PAGINATION_CONFIG,
JOB_STATUSES
} from '../../../../constants';
import { usePagination } from '../../../../hooks/usePagination';
import { useBulkOperationStats } from '../../../../hooks/useBulkOperationStats';
Expand All @@ -37,17 +38,19 @@ export const Preview = ({ id, title, isInitial, bulkDetails }) => {
progress,
} = useSearchParams();

const totalNumOfRecords = step === EDITING_STEPS.COMMIT ? bulkDetails?.processedNumOfRecords : bulkDetails?.matchedNumOfRecords;
const isOtherTabProcessing = progress && criteria !== progress;
const isPreviewEnabled = !isOtherTabProcessing && Boolean(id);

const {
countOfRecords,
countOfErrors,
countOfWarnings,
visibleColumns,
} = useBulkOperationStats({ bulkDetails, step });

const totalNumOfRecords = step === EDITING_STEPS.COMMIT ? bulkDetails?.processedNumOfRecords : bulkDetails?.matchedNumOfRecords;
const isOtherTabProcessing = progress && criteria !== progress;
const statusesForPreview = [JOB_STATUSES.DATA_MODIFICATION, JOB_STATUSES.COMPLETED, JOB_STATUSES.COMPLETED_WITH_ERRORS];
const isPreviewEnabled = !isOtherTabProcessing && Boolean(id) && statusesForPreview.includes(bulkDetails?.status);
const isErrorsPreviewEnabled = isPreviewEnabled && (countOfErrors > 0 || countOfWarnings > 0);

const { errorType, toggleErrorType } = useErrorType({
countOfErrors,
countOfWarnings
Expand Down Expand Up @@ -80,7 +83,7 @@ export const Preview = ({ id, title, isInitial, bulkDetails }) => {
id,
step,
errorType,
enabled: isPreviewEnabled,
enabled: isErrorsPreviewEnabled,
...errorsPagination,
});

Expand Down Expand Up @@ -156,6 +159,7 @@ Preview.propTypes = {
processedNumOfRecords: PropTypes.number,
matchedNumOfErrors: PropTypes.number,
committedNumOfErrors: PropTypes.number,
fqlQuery: PropTypes.string
fqlQuery: PropTypes.string,
status: PropTypes.string,
}),
};
1 change: 1 addition & 0 deletions src/constants/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const JOB_STATUSES = {
REVIEW_CHANGES: 'REVIEW_CHANGES',
REVIEWED_NO_MARC_RECORDS: 'REVIEWED_NO_MARC_RECORDS',
APPLY_CHANGES: 'APPLY_CHANGES',
APPLY_MARC_CHANGES: 'APPLY_MARC_CHANGES',
SUSPENDED: 'SUSPENDED',
COMPLETED: 'COMPLETED',
COMPLETED_WITH_ERRORS: 'COMPLETED_WITH_ERRORS',
Expand Down
1 change: 1 addition & 0 deletions translations/ui-bulk-edit/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@
"logs.status.COMPLETED_WITH_ERRORS": "Completed with errors",
"logs.status.FAILED": "Failed",
"logs.status.APPLY_CHANGES": "Apply changes",
"logs.status.APPLY_MARC_CHANGES": "Apply changes",
"logs.status.EXECUTING_QUERY": "Executing query",
"logs.status.RETRIEVING_IDENTIFIERS": "Retrieving identifiers",
"logs.status.SAVED_IDENTIFIERS": "Saving identifiers",
Expand Down
Loading