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 2 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 @@ -92,6 +92,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 @@ -21,7 +21,7 @@
JOB_STATUSES,
TRANSLATION_SUFFIX,
EDITING_STEPS,
FILTERS,
FILTERS, ERRORS,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz move to the next line - common codestyle

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved!

} from '../../../constants';
import { RootContext } from '../../../context/RootContext';
import {
Expand Down Expand Up @@ -95,7 +95,7 @@

const applyFiltersAdapter = (callBack) => ({ name, values }) => callBack(name, values);

const adaptedApplyFilters = useCallback(

Check warning on line 98 in src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead

Check warning on line 98 in src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead
applyFiltersAdapter(applyFilters),
[applyFilters],
);
Expand Down Expand Up @@ -185,7 +185,7 @@
setVisibleColumns(null);
setIsFileUploaded(false);
setInAppCommitted(false);
}, [location.search]);

Check warning on line 188 in src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useCallback has missing dependencies: 'criteria', 'handleChange', 'history', 'initialCapabilities', 'logFilters', 'setInAppCommitted', 'setIsFileUploaded', and 'setVisibleColumns'. Either include them or remove the dependency array. If 'setIsFileUploaded' changes too often, find the parent component that defines it and wrap that definition in useCallback

Check warning on line 188 in src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useCallback has missing dependencies: 'criteria', 'handleChange', 'history', 'initialCapabilities', 'logFilters', 'setInAppCommitted', 'setIsFileUploaded', and 'setVisibleColumns'. Either include them or remove the dependency array. If 'setIsFileUploaded' changes too often, find the parent component that defines it and wrap that definition in useCallback

const uploadFileFlow = async (fileToUpload) => {
try {
Expand All @@ -195,11 +195,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 @@ -209,10 +210,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 All @@ -228,7 +236,7 @@
const messagePrefix = recordIdentifier ? `.${recordIdentifier}` : '';

return <FormattedMessage id={`ui-bulk-edit.uploaderSubTitle${TRANSLATION_SUFFIX[capabilities]}${messagePrefix}`} />;
}, [recordIdentifier]);

Check warning on line 239 in src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useMemo has a missing dependency: 'capabilities'. Either include it or remove the dependency array

Check warning on line 239 in src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useMemo has a missing dependency: 'capabilities'. Either include it or remove the dependency array

useEffect(() => {
if (isFileUploaded || !recordIdentifier || initialFileName) {
Expand All @@ -236,7 +244,7 @@
} else {
setIsDropZoneDisabled(false);
}
}, [isFileUploaded, recordIdentifier]);

Check warning on line 247 in src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useEffect has a missing dependency: 'initialFileName'. Either include it or remove the dependency array

Check warning on line 247 in src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useEffect has a missing dependency: 'initialFileName'. Either include it or remove the dependency array

useEffect(() => {
const identifier = search.get('identifier');
Expand All @@ -248,7 +256,7 @@
if (initialCapabilities) {
handleChange(initialCapabilities, 'capabilities');
}
}, [location.search]);

Check warning on line 259 in src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useEffect has missing dependencies: 'handleChange', 'initialCapabilities', and 'search'. Either include them or remove the dependency array

Check warning on line 259 in src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useEffect has missing dependencies: 'handleChange', 'initialCapabilities', and 'search'. Either include them or remove the dependency array

const renderCapabilities = () => (
<Capabilities
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