From 7b4c54e09de53b5801b1c556c738cddd5f2213ed Mon Sep 17 00:00:00 2001 From: Vadym Shchekotilin <86330150+vashjs@users.noreply.github.com> Date: Wed, 13 Nov 2024 20:33:42 +0100 Subject: [PATCH 1/2] UIBULKED-538 Add translation and filtering logic for new status (follow up) (#646) --- src/utils/helpers.js | 15 ++++++++++++--- src/utils/helpers.test.js | 16 +++++++++++++++- translations/ui-bulk-edit/en.json | 1 + 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/utils/helpers.js b/src/utils/helpers.js index eaf24bc8..4781b2de 100644 --- a/src/utils/helpers.js +++ b/src/utils/helpers.js @@ -2,6 +2,7 @@ import { clone, setWith } from 'lodash'; import { CAPABILITIES, EDIT_CAPABILITIES_OPTIONS, + JOB_STATUSES, LOGS_FILTERS, } from '../constants'; @@ -161,10 +162,18 @@ export const filterByIds = (items, ids) => { }; export const getTransformedLogsFilterValue = (name, values) => { + const getWithDependentValue = (triggerValue, dependentValue) => { + return values.includes(triggerValue) + ? [...new Set([...values, dependentValue])] + : values.filter(value => value !== dependentValue); + }; + if (name === LOGS_FILTERS.CAPABILITY) { - return values.includes(CAPABILITIES.INSTANCE) - ? [...new Set([...values, CAPABILITIES.INSTANCE_MARC])] - : values.filter(value => value !== CAPABILITIES.INSTANCE_MARC); + return getWithDependentValue(CAPABILITIES.INSTANCE, CAPABILITIES.INSTANCE_MARC); + } + + if (name === LOGS_FILTERS.STATUS) { + return getWithDependentValue(JOB_STATUSES.REVIEW_CHANGES, JOB_STATUSES.REVIEWED_NO_MARC_RECORDS); } return values; diff --git a/src/utils/helpers.test.js b/src/utils/helpers.test.js index 37c9b7c3..1f4d7ba2 100644 --- a/src/utils/helpers.test.js +++ b/src/utils/helpers.test.js @@ -4,7 +4,7 @@ import { getTransformedLogsFilterValue, removeDuplicatesByValue } from './helpers'; -import { CAPABILITIES, LOGS_FILTERS } from '../constants'; +import { CAPABILITIES, JOB_STATUSES, LOGS_FILTERS } from '../constants'; describe('customFilter', () => { const dataOptions = [ @@ -265,4 +265,18 @@ describe('getTransformedLogsFilterValue', () => { expect(values).not.toContain(CAPABILITIES.INSTANCE_MARC); expect(result).toContain('userID'); }); + + it('should add REVIEWED_NO_MARC_RECORDS to the array if REVIEW_CHANGES is present', () => { + const values = [JOB_STATUSES.REVIEW_CHANGES]; + const result = getTransformedLogsFilterValue(LOGS_FILTERS.STATUS, values); + expect(result).toContain(JOB_STATUSES.REVIEW_CHANGES); + expect(result).toContain(JOB_STATUSES.REVIEWED_NO_MARC_RECORDS); + }); + + it('should remove REVIEWED_NO_MARC_RECORDS from the array if REVIEW_CHANGES is not present', () => { + const values = ['other_value']; + const result = getTransformedLogsFilterValue(LOGS_FILTERS.STATUS, values); + expect(result).not.toContain(JOB_STATUSES.REVIEWED_NO_MARC_RECORDS); + expect(result).toContain('other_value'); + }); }); diff --git a/translations/ui-bulk-edit/en.json b/translations/ui-bulk-edit/en.json index e1f8d9f2..37f3efb4 100644 --- a/translations/ui-bulk-edit/en.json +++ b/translations/ui-bulk-edit/en.json @@ -471,6 +471,7 @@ "logs.status.SAVING_RECORDS_LOCALLY": "Saving records", "logs.status.DATA_MODIFICATION": "Data modification", "logs.status.REVIEW_CHANGES": "Reviewing changes", + "logs.status.REVIEWED_NO_MARC_RECORDS": "Reviewing changes", "logs.status.COMPLETED": "Completed", "logs.status.COMPLETED_WITH_ERRORS": "Completed with errors", "logs.status.FAILED": "Failed", From d85b398a04cdd9eb5d538f334701c93a8223d49e Mon Sep 17 00:00:00 2001 From: Vadym Shchekotilin <86330150+vashjs@users.noreply.github.com> Date: Wed, 13 Nov 2024 21:22:16 +0100 Subject: [PATCH 2/2] UIBULKED-581 "Something went wrong" error notification displays (#647) --- CHANGELOG.md | 1 + .../BulkEditListResult/Preview/Preview.js | 17 ++++++++++++++--- src/hooks/api/useErrorsPreview.js | 5 ++--- src/hooks/api/useRecordsPreview.js | 2 -- 4 files changed, 17 insertions(+), 8 deletions(-) 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();