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-210: Improve user errors for invalid data - IncorrectTokenCountException error #476

Merged
merged 5 commits into from
Feb 14, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
* [UIBULKED-351](https://issues.folio.org/browse/UIBULKED-351) Hide Query tab
* [UIBULKED-276](https://issues.folio.org/browse/UIBULKED-276) Rename "Instance" column for holdings records preview
* [UIBULKED-352](https://issues.folio.org/browse/UIBULKED-352) Localize numbers displayed in bulk edit
* [UIBULKED-210](https://issues.folio.org/browse/UIBULKED-210) Improve user errors for invalid data - IncorrectTokenCountException error.


## [3.0.5](https://github.com/folio-org/ui-bulk-edit/tree/v3.0.5) (2023-03-22)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import {
CRITERIA,
EDITING_STEPS,
ERRORS,
IDENTIFIER_FILTERS,
JOB_STATUSES,
TRANSLATION_SUFFIX
Expand Down Expand Up @@ -99,7 +100,7 @@
setIsFileUploaded(false);
setVisibleColumns(null);
setInAppCommitted(false);
}, [location.search]);

Check warning on line 103 in src/components/BulkEditList/BulkEditListSidebar/IdentifierTab/IdentifierTab.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useCallback has missing dependencies: 'history', 'setInAppCommitted', 'setIsFileUploaded', and 'setVisibleColumns'. Either include them or remove the dependency array

Check warning on line 103 in src/components/BulkEditList/BulkEditListSidebar/IdentifierTab/IdentifierTab.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useCallback has missing dependencies: 'history', 'setInAppCommitted', 'setIsFileUploaded', and 'setVisibleColumns'. Either include them or remove the dependency array

const handleCapabilityChange = (e) => {
history.replace({
Expand Down Expand Up @@ -133,11 +134,12 @@
identifierType: recordIdentifier,
});

const { status } = await bulkOperationStart({
const { status, errorMessage } = await bulkOperationStart({
id,
step: EDITING_STEPS.UPLOAD,
});

if (errorMessage.includes(ERRORS.TOKEN)) throw Error(ERRORS.TOKEN);
if (status === JOB_STATUSES.FAILED) throw Error();

history.replace({
Expand All @@ -147,10 +149,17 @@

setIsFileUploaded(true);
} catch ({ message }) {
showCallout({
message: <FormattedMessage id="ui-bulk-edit.error.uploadedFile" />,
type: 'error',
});
if (message === ERRORS.TOKEN) {
showCallout({
message: <FormattedMessage id="ui-bulk-edit.error.incorrectFormatted" values={{ fileName:fileToUpload.name }} />,
type: 'error',
});
} else {
showCallout({
message: <FormattedMessage id="ui-bulk-edit.error.uploadedFile" />,
type: 'error',
});
}
}
};

Expand Down
4 changes: 4 additions & 0 deletions src/constants/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export const CRITERIA = {
LOGS: 'logs',
};

export const ERRORS = {
TOKEN: 'Incorrect number of tokens found in record'
};

export const TYPE_OF_PROGRESS = {
INITIAL: 'initial',
PROCESSED: 'processed',
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 @@ -140,6 +140,7 @@

"error.uploadedFile": "Fail to upload file",
"error.sww": "Something went wrong",
"error.incorrectFormatted": "{fileName}: is formatted incorrectly. Please correct the formatting and upload the file again.",

"category.loanType": "Loan type",
"category.location": "Location",
Expand Down
Loading