diff --git a/CHANGELOG.md b/CHANGELOG.md index dc72d371..31a70cff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * [UIBULKED-540](https://folio-org.atlassian.net/browse/UIBULKED-540) Update identifiers names for Item record. * [UIPQB-126](https://folio-org.atlassian.net/browse/UIPQB-126) Use tenant timezone for building queries (adds use of permission `configuration.entries.collection.get`). * [UIBULKED-582](https://folio-org.atlassian.net/browse/UIBULKED-582) Temporarily remove error handling from publish-coordinator related logic. +* [UIBULKED-581](https://folio-org.atlassian.net/browse/UIBULKED-581) "Something went wrong" error notification displays ## [4.2.0](https://github.com/folio-org/ui-bulk-edit/tree/v4.2.0) (2024-10-31) diff --git a/src/components/BulkEditPane/BulkEditListResult/Preview/Preview.js b/src/components/BulkEditPane/BulkEditListResult/Preview/Preview.js index ee6b8151..edb3318a 100644 --- a/src/components/BulkEditPane/BulkEditListResult/Preview/Preview.js +++ b/src/components/BulkEditPane/BulkEditListResult/Preview/Preview.js @@ -24,17 +24,20 @@ import { import { usePagination } from '../../../../hooks/usePagination'; import { useBulkOperationStats } from '../../../../hooks/useBulkOperationStats'; import { NoResultsMessage } from '../NoResultsMessage/NoResultsMessage'; -import { useSearchParams } from '../../../../hooks/useSearchParams'; +import { useSearchParams } from '../../../../hooks'; export const Preview = ({ id, title, isInitial, bulkDetails }) => { const { criteria, queryRecordType, step, - currentRecordType + currentRecordType, + progress, } = useSearchParams(); const totalRecords = step === EDITING_STEPS.COMMIT ? bulkDetails?.processedNumOfRecords : bulkDetails?.matchedNumOfRecords; + const isOtherTabProcessing = progress && criteria !== progress; + const isPreviewEnabled = !isOtherTabProcessing && Boolean(id); const { countOfRecords, @@ -55,10 +58,18 @@ export const Preview = ({ id, title, isInitial, bulkDetails }) => { step, criteria, queryRecordType, + queryOptions: { + enabled: isPreviewEnabled, + }, ...pagination, }); - const { data } = useErrorsPreview({ id }); + const { data } = useErrorsPreview({ + id, + queryOptions: { + enabled: isPreviewEnabled, + }, + }); const errors = data?.errors || []; diff --git a/src/hooks/api/useErrorsPreview.js b/src/hooks/api/useErrorsPreview.js index 21150e7d..a18726ef 100644 --- a/src/hooks/api/useErrorsPreview.js +++ b/src/hooks/api/useErrorsPreview.js @@ -4,7 +4,7 @@ import { useErrorMessages } from '../useErrorMessages'; export const PREVIEW_ERRORS_KEY = 'PREVIEW_ERRORS_KEY'; -export const useErrorsPreview = ({ id }) => { +export const useErrorsPreview = ({ id, queryOptions = {} }) => { const ky = useOkapiKy(); const [namespaceKey] = useNamespace({ key: PREVIEW_ERRORS_KEY }); @@ -13,11 +13,10 @@ export const useErrorsPreview = ({ id }) => { const { data, isLoading } = useQuery( { queryKey: [namespaceKey, id], - cacheTime: 0, - enabled: !!id, queryFn: () => ky.get(`bulk-operations/${id}/errors`, { searchParams: { limit: 10 } }).json(), onError: showErrorMessage, onSuccess: showErrorMessage, + ...queryOptions, }, ); diff --git a/src/hooks/api/useRecordsPreview.js b/src/hooks/api/useRecordsPreview.js index fa15a223..8a2d5510 100644 --- a/src/hooks/api/useRecordsPreview.js +++ b/src/hooks/api/useRecordsPreview.js @@ -32,8 +32,6 @@ export const useRecordsPreview = ({ const { data, refetch, isLoading, dataUpdatedAt, isFetching } = useQuery( { queryKey: [key, namespaceKey, id, step, limit, offset], - cacheTime: 0, - staleTime: 0, keepPreviousData: true, queryFn: () => { return ky.get(`bulk-operations/${id}/preview`, { searchParams: { limit, offset, step } }).json();