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-581 "Something went wrong" error notification displays #647

Merged
merged 5 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -3,6 +3,7 @@
## In progress
* [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-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
1 change: 0 additions & 1 deletion src/hooks/useConfirmChanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export const useConfirmChanges = ({

const closePreviewModal = () => {
setIsPreviewModalOpened(false);
queryClient.resetQueries(BULK_OPERATION_DETAILS_KEY);
};

const confirmChanges = (payload) => {
Expand Down
Loading