Skip to content

Commit

Permalink
UIBULKED-588 Add additional conditions for preview showing (#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs authored Jan 31, 2025
1 parent c4032c0 commit 19a098a
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ export const BulkEditPreviewModalList = ({
showErrorMessage(error);
onPreviewError();
},
onSettled: onPreviewSettled,
onSuccess: onPreviewSettled,
},
...pagination,
});
18 changes: 11 additions & 7 deletions src/components/BulkEditPane/BulkEditListResult/Preview/Preview.js
Original file line number Diff line number Diff line change
@@ -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';
@@ -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
@@ -80,7 +83,7 @@ export const Preview = ({ id, title, isInitial, bulkDetails }) => {
id,
step,
errorType,
enabled: isPreviewEnabled,
enabled: isErrorsPreviewEnabled,
...errorsPagination,
});

@@ -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
@@ -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',
1 change: 1 addition & 0 deletions translations/ui-bulk-edit/en.json
Original file line number Diff line number Diff line change
@@ -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",

0 comments on commit 19a098a

Please sign in to comment.