Skip to content

Commit

Permalink
UIBULKED-581 "Something went wrong" error notification displays (#647)
Browse files Browse the repository at this point in the history
(cherry picked from commit d85b398)
  • Loading branch information
vashjs committed Nov 15, 2024
1 parent 5adfb49 commit 2497875
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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)

Expand Down
17 changes: 14 additions & 3 deletions src/components/BulkEditPane/BulkEditListResult/Preview/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 || [];

Expand Down
5 changes: 2 additions & 3 deletions src/hooks/api/useErrorsPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand All @@ -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,
},
);

Expand Down
2 changes: 0 additions & 2 deletions src/hooks/api/useRecordsPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 2497875

Please sign in to comment.