From dab69896991dd6b8a9a26cac4b70f16a15167b7b Mon Sep 17 00:00:00 2001 From: vashjs Date: Mon, 28 Oct 2024 09:32:11 +0100 Subject: [PATCH] UIBULKED-553 Show error callouts only when job FAILED --- .../IdentifierTab/IdentifierTab.js | 16 ++++++---------- src/components/shared/ProgressBar/ProgressBar.js | 5 ++--- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/components/BulkEditPane/BulkEditListSidebar/IdentifierTab/IdentifierTab.js b/src/components/BulkEditPane/BulkEditListSidebar/IdentifierTab/IdentifierTab.js index 52f2f920..1a7bcf6f 100644 --- a/src/components/BulkEditPane/BulkEditListSidebar/IdentifierTab/IdentifierTab.js +++ b/src/components/BulkEditPane/BulkEditListSidebar/IdentifierTab/IdentifierTab.js @@ -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'; @@ -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, @@ -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`, @@ -155,13 +156,8 @@ export const IdentifierTab = () => { } setIsFileUploaded(true); - } catch ({ message }) { - if (message === ERRORS.TOKEN) { - showCallout({ - message: , - type: 'error', - }); - } + } catch (error) { + showErrorMessage(error); } }; diff --git a/src/components/shared/ProgressBar/ProgressBar.js b/src/components/shared/ProgressBar/ProgressBar.js index f764ff48..fe046070 100644 --- a/src/components/shared/ProgressBar/ProgressBar.js +++ b/src/components/shared/ProgressBar/ProgressBar.js @@ -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', ''); } }, [