Skip to content

Commit

Permalink
UIBULKED-553 Show error callouts only when job FAILED
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs committed Oct 28, 2024
1 parent f661fc5 commit dab6989
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, {
useMemo,
useState
} from 'react';
import { buildSearch, useShowCallout } from '@folio/stripes-acq-components';
import { buildSearch } from '@folio/stripes-acq-components';
import { FormattedMessage } from 'react-intl';
import { useHistory, useLocation } from 'react-router-dom';

Expand All @@ -24,12 +24,13 @@ import { useBulkPermissions, useLocationFilters, useSearchParams } from '../../.
import { useBulkOperationStart, useUpload } from '../../../../hooks/api';
import { getIsDisabledByPerm } from '../utils/getIsDisabledByPerm';
import { RootContext } from '../../../../context/RootContext';
import { useErrorMessages } from '../../../../hooks/useErrorMessages';

export const IdentifierTab = () => {
const history = useHistory();
const location = useLocation();
const showCallout = useShowCallout();
const permissions = useBulkPermissions();
const { showErrorMessage } = useErrorMessages();

const {
isFileUploaded,
Expand Down Expand Up @@ -146,7 +147,7 @@ export const IdentifierTab = () => {
});

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

history.replace({
pathname: `/bulk-edit/${id}/preview`,
Expand All @@ -155,13 +156,8 @@ export const IdentifierTab = () => {
}

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

Expand Down
5 changes: 2 additions & 3 deletions src/components/shared/ProgressBar/ProgressBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ export const ProgressBar = () => {
useEffect(() => {
const nextStep = getBulkOperationStep(bulkDetails);

// Show error message if any
showErrorMessage(bulkDetails);

if (nextStep) {
clearIntervalAndRedirect(`/bulk-edit/${id}/preview`, { step: nextStep, progress: null });
}

if (status === JOB_STATUSES.FAILED) {
showErrorMessage(bulkDetails);

clearIntervalAndRedirect('/bulk-edit', '');
}
}, [

Check warning on line 46 in src/components/shared/ProgressBar/ProgressBar.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

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

Check warning on line 46 in src/components/shared/ProgressBar/ProgressBar.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

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

0 comments on commit dab6989

Please sign in to comment.