From 81f1ddf9f5267ea4f6221301ed048a139e14c88d Mon Sep 17 00:00:00 2001 From: UladzislauKutarkin <72550466+UladzislauKutarkin@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:39:42 +0400 Subject: [PATCH 1/5] UIBULKED-575: Fix "Something went wrong" toast notifications when starting bulk edit (#635) --- CHANGELOG.md | 1 + .../BulkEditInApp/BulkEditInApp.js | 17 ++++++++------- .../ContentUpdatesForm/ValuesColumn.js | 21 ++++++++++--------- src/hooks/api/useBulkOperationTenants.js | 1 + 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88d16865..4386ee1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ * [UIBULKED-572](https://folio-org.atlassian.net/browse/UIBULKED-572) Include additional field to 'actions'. * [UIBULKED-497](https://folio-org.atlassian.net/browse/UIBULKED-497) "Are you sure" preview displays outdated values after User changed selection on bulk edit form and clicked "Confirm changes". * [UIBULKED-557](https://folio-org.atlassian.net/browse/UIBULKED-557) Add hover effect to improve text visibility in dropdowns in Bulk Edit in-app form. +* [UIBULKED-575](https://folio-org.atlassian.net/browse/UIBULKED-575) Fix "Something went wrong" toast notifications when starting bulk edit. ## [4.1.4](https://github.com/folio-org/ui-bulk-edit/tree/v4.1.4) (2024-05-29) diff --git a/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/BulkEditInApp.js b/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/BulkEditInApp.js index 2687b2ca..03c89cb7 100644 --- a/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/BulkEditInApp.js +++ b/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/BulkEditInApp.js @@ -9,7 +9,10 @@ import { Loading, Layout, } from '@folio/stripes/components'; -import { useStripes } from '@folio/stripes/core'; +import { + checkIfUserInCentralTenant, + useStripes, +} from '@folio/stripes/core'; import { BulkEditInAppTitle } from './BulkEditInAppTitle/BulkEditInAppTitle'; import { ContentUpdatesForm } from './ContentUpdatesForm/ContentUpdatesForm'; @@ -42,10 +45,8 @@ export const BulkEditInApp = ({ onContentUpdatesChanged, }) => { const { title } = useContext(RootContext); - const { user, okapi } = useStripes(); - const centralTenant = user?.user?.consortium?.centralTenantId; - const tenantId = okapi.tenant; - const isCentralTenant = tenantId === centralTenant; + const stripes = useStripes(); + const isCentralTenant = checkIfUserInCentralTenant(stripes); const { formatMessage } = useIntl(); const { currentRecordType } = useSearchParams(); @@ -56,12 +57,12 @@ export const BulkEditInApp = ({ const isHoldingsRecordType = currentRecordType === CAPABILITIES.HOLDING; const isInstanceRecordType = currentRecordType === CAPABILITIES.INSTANCE; + const { data: tenants, isLoading } = useBulkOperationTenants(bulkOperationId); const { itemNotes, isItemNotesLoading } = useItemNotes({ enabled: isItemRecordType }); const { holdingsNotes, isHoldingsNotesLoading } = useHoldingsNotes({ enabled: isHoldingsRecordType }); const { instanceNotes, isInstanceNotesLoading } = useInstanceNotes({ enabled: isInstanceRecordType }); - const { data: tenants } = useBulkOperationTenants(bulkOperationId); - const { notesEsc: itemNotesEsc, isFetching: isItemsNotesEscLoading } = useItemNotesEsc(tenants, 'option', { enabled: isItemRecordType && Boolean(tenants?.length) }); - const { notesEsc: holdingsNotesEsc, isFetching: isHoldingsNotesEscLoading } = useHoldingsNotesEsc(tenants, 'option', { enabled: isHoldingsRecordType && (Boolean(tenants?.length)) }); + const { notesEsc: itemNotesEsc, isFetching: isItemsNotesEscLoading } = useItemNotesEsc(tenants, 'option', { enabled: isItemRecordType && isCentralTenant && !isLoading }); + const { notesEsc: holdingsNotesEsc, isFetching: isHoldingsNotesEscLoading } = useHoldingsNotesEsc(tenants, 'option', { enabled: isHoldingsRecordType && isCentralTenant && !isLoading }); const options = useMemo(() => ({ [CAPABILITIES.ITEM]: getItemsOptions(formatMessage, removeDuplicatesByValue(isCentralTenant ? itemNotesEsc : itemNotes, tenants)), diff --git a/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ValuesColumn.js b/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ValuesColumn.js index b15effd1..2be55c0d 100644 --- a/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ValuesColumn.js +++ b/src/components/BulkEditPane/BulkEditListResult/BulkEditInApp/ContentUpdatesForm/ValuesColumn.js @@ -2,7 +2,10 @@ import React from 'react'; import { useIntl } from 'react-intl'; import PropTypes from 'prop-types'; -import { useStripes } from '@folio/stripes/core'; +import { + checkIfUserInCentralTenant, + useStripes, +} from '@folio/stripes/core'; import { Datepicker, Select, @@ -61,15 +64,13 @@ import { } from '../../../../../utils/helpers'; export const ValuesColumn = ({ action, allActions, actionIndex, onChange, option }) => { - const { user, okapi } = useStripes(); + const stripes = useStripes(); const { formatMessage } = useIntl(); const { currentRecordType, } = useSearchParams(); const { id: bulkOperationId } = usePathParams('/bulk-edit/:id'); - const centralTenant = user?.user?.consortium?.centralTenantId; - const tenantId = okapi.tenant; - const isCentralTenant = tenantId === centralTenant; + const isCentralTenant = checkIfUserInCentralTenant(stripes); const isUserCapability = currentRecordType === CAPABILITIES.USER; const isItemCapability = currentRecordType === CAPABILITIES.ITEM; @@ -82,13 +83,13 @@ export const ValuesColumn = ({ action, allActions, actionIndex, onChange, option const { itemNotes, usItemNotesLoading } = useItemNotes({ enabled: isItemCapability }); const { instanceNotes, isInstanceNotesLoading } = useInstanceNotes({ enabled: isInstanceCapability }); const { data: tenants } = useBulkOperationTenants(bulkOperationId); - const { notesEsc: itemsNotes, isFetching: isItemsNotesEscLoading } = useItemNotesEsc(tenants, 'action', { enabled: isItemCapability && Boolean(tenants?.length) }); - const { notesEsc: holdingsNotesEsc, isFetching: isHoldingsNotesEscLoading } = useHoldingsNotesEsc(tenants, 'action', { enabled: isHoldingsCapability && Boolean(tenants?.length) }); - const { locationsEsc, isFetching: isLocationEscLoading } = useLocationEsc(tenants, { enabled: Boolean(tenants?.length) }); - const { escData: loanTypesEsc, isFetching: isLoanTypesEscLoading } = useLoanTypesEsc(tenants, { enabled: Boolean(tenants?.length) }); + const { notesEsc: itemsNotes, isFetching: isItemsNotesEscLoading } = useItemNotesEsc(tenants, 'action', { enabled: isItemCapability && isCentralTenant }); + const { notesEsc: holdingsNotesEsc, isFetching: isHoldingsNotesEscLoading } = useHoldingsNotesEsc(tenants, 'action', { enabled: isHoldingsCapability && isCentralTenant }); + const { locationsEsc, isFetching: isLocationEscLoading } = useLocationEsc(tenants, { enabled: isCentralTenant }); + const { escData: loanTypesEsc, isFetching: isLoanTypesEscLoading } = useLoanTypesEsc(tenants, { enabled: isCentralTenant }); const { electronicAccessRelationships, isElectronicAccessLoading } = useElectronicAccessRelationships({ enabled: isHoldingsCapability }); - const { escData: urlRelationshipsEsc, isFetching: isElectronicAccessEscLoading } = useElectronicAccessEsc(tenants, { enabled: Boolean(tenants?.length) }); + const { escData: urlRelationshipsEsc, isFetching: isElectronicAccessEscLoading } = useElectronicAccessEsc(tenants, { enabled: isCentralTenant }); // exclude from second action the first action value const filteredElectronicAccessRelationships = electronicAccessRelationships.filter(item => actionIndex === 0 || item.value !== allActions[0]?.value); const filteredElectronicAccessRelationshipsEsc = urlRelationshipsEsc?.filter(item => actionIndex === 0 || item.value !== allActions[0]?.value); diff --git a/src/hooks/api/useBulkOperationTenants.js b/src/hooks/api/useBulkOperationTenants.js index e15b7a39..25068fa6 100644 --- a/src/hooks/api/useBulkOperationTenants.js +++ b/src/hooks/api/useBulkOperationTenants.js @@ -12,6 +12,7 @@ export const useBulkOperationTenants = (id, options = {}) => { queryKey: [namespace], queryFn: () => ky.get(`bulk-operations/used-tenants/${id}`).json(), keepPreviousData: true, + enabled: !!id, ...options, }); From c3b47728af778fa3904e7b736b74d3e0c4ae56ba Mon Sep 17 00:00:00 2001 From: Vadym Shchekotilin <86330150+vashjs@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:53:01 +0100 Subject: [PATCH 2/5] UIBULKED-553 Remove redundant error handling (#636) --- .../BulkEditInAppPreviewModal/BulkEditPreviewModal.js | 2 +- .../BulkEditManualUploadModal/BulkEditManualUploadModal.js | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModal.js b/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModal.js index ef901a46..c571eee0 100644 --- a/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModal.js +++ b/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModal.js @@ -45,7 +45,7 @@ export const BulkEditPreviewModal = ({ id: bulkDetails?.id, approach: APPROACHES.IN_APP, step: EDITING_STEPS.COMMIT, - }).then(showErrorMessage); + }); onChangesCommited(); diff --git a/src/components/BulkEditPane/BulkEditListResult/BulkEditManualUploadModal/BulkEditManualUploadModal.js b/src/components/BulkEditPane/BulkEditListResult/BulkEditManualUploadModal/BulkEditManualUploadModal.js index fc2a9d7c..369dc632 100644 --- a/src/components/BulkEditPane/BulkEditListResult/BulkEditManualUploadModal/BulkEditManualUploadModal.js +++ b/src/components/BulkEditPane/BulkEditListResult/BulkEditManualUploadModal/BulkEditManualUploadModal.js @@ -25,7 +25,6 @@ import { import { useBulkOperationDelete } from '../../../../hooks/api/useBulkOperationDelete'; import { ListFileUploader } from '../../../shared/ListFileUploader'; import { useSearchParams } from '../../../../hooks/useSearchParams'; -import { useErrorMessages } from '../../../../hooks/useErrorMessages'; const BulkEditManualUploadModal = ({ operationId, @@ -39,7 +38,6 @@ const BulkEditManualUploadModal = ({ const callout = useShowCallout(); const controller = useRef(null); const { identifier, criteria } = useSearchParams(); - const { showErrorMessage } = useErrorMessages(); const { fileUpload } = useUpload(); const { bulkOperationStart } = useBulkOperationStart(); @@ -104,7 +102,7 @@ const BulkEditManualUploadModal = ({ id: operationId, step: EDITING_STEPS.COMMIT, approach: APPROACHES.MANUAL, - }).then(showErrorMessage); + }); setCountOfRecords(committedNumOfRecords); From 5ac625666193bd62a28113bea0c715cbca989900 Mon Sep 17 00:00:00 2001 From: Vadym Shchekotilin <86330150+vashjs@users.noreply.github.com> Date: Wed, 30 Oct 2024 22:43:50 +0100 Subject: [PATCH 3/5] * Bump "@folio/stripes-acq-components" version to v6.0.0 (#637) --- CHANGELOG.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4386ee1f..14fa06db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,7 @@ * [UIBULKED-497](https://folio-org.atlassian.net/browse/UIBULKED-497) "Are you sure" preview displays outdated values after User changed selection on bulk edit form and clicked "Confirm changes". * [UIBULKED-557](https://folio-org.atlassian.net/browse/UIBULKED-557) Add hover effect to improve text visibility in dropdowns in Bulk Edit in-app form. * [UIBULKED-575](https://folio-org.atlassian.net/browse/UIBULKED-575) Fix "Something went wrong" toast notifications when starting bulk edit. +* Bump "@folio/stripes-acq-components" version to v6.0.0 ## [4.1.4](https://github.com/folio-org/ui-bulk-edit/tree/v4.1.4) (2024-05-29) diff --git a/package.json b/package.json index 338adfd1..46923478 100644 --- a/package.json +++ b/package.json @@ -226,7 +226,7 @@ "testing-library-selector": "^0.2.1" }, "dependencies": { - "@folio/stripes-acq-components": "^5.0.0", + "@folio/stripes-acq-components": "^6.0.0", "file-saver": "^2.0.5", "history": "^5.1.0", "lodash": "^4.17.5", From be373edb321b5a033c20af7864e618c179f2fd78 Mon Sep 17 00:00:00 2001 From: Vadym Shchekotilin <86330150+vashjs@users.noreply.github.com> Date: Thu, 31 Oct 2024 10:57:23 +0100 Subject: [PATCH 4/5] UIBULKED-553 Remove .json() converting as backend doesn't return JSON (#638) --- src/hooks/api/useBulkOperationDelete.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hooks/api/useBulkOperationDelete.js b/src/hooks/api/useBulkOperationDelete.js index e7234049..a514de28 100644 --- a/src/hooks/api/useBulkOperationDelete.js +++ b/src/hooks/api/useBulkOperationDelete.js @@ -8,10 +8,9 @@ export const useBulkOperationDelete = (mutationOptions = {}) => { const { mutateAsync: bulkOperationDelete, isLoading } = useMutation({ mutationFn: async ({ operationId }) => { - return ky.post(`bulk-operations/${operationId}/cancel`).json(); + return ky.post(`bulk-operations/${operationId}/cancel`); }, onError: showErrorMessage, - onSuccess: showErrorMessage, ...mutationOptions, }); From 9e393f3e28419ef33e3c75c12385679c5aa25272 Mon Sep 17 00:00:00 2001 From: Vadym Shchekotilin <86330150+vashjs@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:07:33 +0100 Subject: [PATCH 5/5] Release 4.2.0 (#639) --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14fa06db..0873f240 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change history for ui-bulk-edit ## In progress + +## [4.2.0](https://github.com/folio-org/ui-bulk-edit/tree/v4.2.0) (2024-10-31) + * [UIBULKED-441](https://issues.folio.org/browse/UIBULKED-441) Bulk edit form enhancements - part 1. * [UIBULKED-442](https://issues.folio.org/browse/UIBULKED-442) Bulk edit form enhancements - part 2. * [UIBULKED-465](https://issues.folio.org/browse/UIBULKED-465) Local approach - Incorrect numbers of changed records and errors are displayed on Confirmation screen diff --git a/package.json b/package.json index 46923478..c23640b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@folio/bulk-edit", - "version": "4.1.4", + "version": "4.2.0", "description": "Description for bulk edit", "main": "index.js", "repository": "",