From baf5ec901dcb5b7832dd9a509033b40882e8d1ae Mon Sep 17 00:00:00 2001
From: Oleksandr Hladchenko
<85172747+oleksandrhladchenko1@users.noreply.github.com>
Date: Wed, 22 Jan 2025 18:00:46 +0200
Subject: [PATCH 1/3] UIIN-3195: Display failure message during Update
Ownership action when Item contains Local reference data (#2719)
(cherry picked from commit 55d300104062f82c60d851f03b72a668a548d656)
---
CHANGELOG.md | 4 ++++
src/views/ItemView.js | 27 ++++++++++++++++++-----
src/views/ItemView.test.js | 36 +++++++++++++++++++++++++++++--
translations/ui-inventory/en.json | 1 +
4 files changed, 61 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 45f12bd11..01fd20595 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Change history for ui-inventory
+## [12.0.11] (IN PROGRESS)
+
+* Display failure message during `Update Ownership` action when Item contains Local reference data. Fixes UIIN-3195.
+
## [12.0.10](https://github.com/folio-org/ui-inventory/tree/v12.0.10) (2025-01-20)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v12.0.9...v12.0.10)
diff --git a/src/views/ItemView.js b/src/views/ItemView.js
index b99475ce8..c23e27b68 100644
--- a/src/views/ItemView.js
+++ b/src/views/ItemView.js
@@ -540,15 +540,28 @@ const ItemView = props => {
goBack();
};
+ const resetFormAndCloseModal = () => {
+ setTargetTenant({});
+ setUpdateOwnershipData({});
+ setIsConfirmUpdateOwnershipModalOpen(false);
+ };
+
const showErrorMessage = () => {
calloutContext.sendCallout({
type: 'error',
message: ,
});
- setTargetTenant({});
- setUpdateOwnershipData({});
- setIsConfirmUpdateOwnershipModalOpen(false);
+ resetFormAndCloseModal();
+ };
+
+ const showReferenceDataError = () => {
+ calloutContext.sendCallout({
+ type: 'error',
+ message: ,
+ });
+
+ resetFormAndCloseModal();
};
const createNewHoldingForlocation = async (itemId, targetLocation, targetTenantId) => {
@@ -590,8 +603,12 @@ const ItemView = props => {
targetTenantId: tenantId,
});
showSuccessMessageAndGoBack(item.hrid);
- } catch (e) {
- showErrorMessage();
+ } catch (error) {
+ if (error.response.status === 400) {
+ showReferenceDataError();
+ } else {
+ showErrorMessage();
+ }
}
}
};
diff --git a/src/views/ItemView.test.js b/src/views/ItemView.test.js
index 794271278..14d975efe 100644
--- a/src/views/ItemView.test.js
+++ b/src/views/ItemView.test.js
@@ -377,10 +377,42 @@ describe('ItemView', () => {
expect(screen.queryByText('Linked order line')).not.toBeInTheDocument();
});
- describe('when an error was occured', () => {
+ describe('when error was occured due to local-specific reference data', () => {
it('should show an error message', async () => {
useHoldingMutation.mockClear().mockReturnValue({ mutateHolding: mockMutate });
- useUpdateOwnership.mockClear().mockReturnValue({ updateOwnership: jest.fn().mockRejectedValue() });
+ useUpdateOwnership.mockClear().mockReturnValue({
+ updateOwnership: jest.fn().mockRejectedValue({
+ response: {
+ status: 400,
+ }
+ })
+ });
+ checkIfUserInCentralTenant.mockClear().mockReturnValue(false);
+
+ renderWithIntl(, translationsProperties);
+
+ const updateOwnershipBtn = screen.getByText('Update ownership');
+ fireEvent.click(updateOwnershipBtn);
+
+ act(() => UpdateItemOwnershipModal.mock.calls[0][0].handleSubmit('university', { id: 'locationId' }, 'holdingId'));
+
+ const confirmationModal = screen.getByText('Update ownership of items');
+ fireEvent.click(within(confirmationModal).getByText('confirm'));
+
+ await waitFor(() => expect(screen.queryByText('Item ownership could not be updated because it contains local-specific reference data.')).toBeDefined());
+ });
+ });
+
+ describe('when error was occured', () => {
+ it('should show an error message', async () => {
+ useHoldingMutation.mockClear().mockReturnValue({ mutateHolding: mockMutate });
+ useUpdateOwnership.mockClear().mockReturnValue({
+ updateOwnership: jest.fn().mockRejectedValue({
+ response: {
+ status: 500,
+ },
+ })
+ });
checkIfUserInCentralTenant.mockClear().mockReturnValue(false);
renderWithIntl(, translationsProperties);
diff --git a/translations/ui-inventory/en.json b/translations/ui-inventory/en.json
index 1d90b04fb..3fc99a0be 100644
--- a/translations/ui-inventory/en.json
+++ b/translations/ui-inventory/en.json
@@ -445,6 +445,7 @@
"updateOwnership.items.modal.heading": "Update ownership of items",
"updateOwnership.items.modal.message": "Would you like to update ownership of Item {itemHrid} from {currentTenant} to {targetTenant}?",
"updateOwnership.item.message.success": "Ownership of item {itemHrid} has been successfully updated to {targetTenantName}",
+ "updateOwnership.items.message.error": "Item ownership could not be updated because it contains local-specific reference data.",
"consortialHoldings": "Consortial holdings",
"instanceData": "Administrative data",
"instanceHrid": "Instance HRID",
From bc57838e2df35cbdfed7516d7230d63c200793e8 Mon Sep 17 00:00:00 2001
From: Oleksandr Hladchenko
<85172747+OleksandrHladchenko1@users.noreply.github.com>
Date: Thu, 23 Jan 2025 22:35:17 +0100
Subject: [PATCH 2/3] UIIN-3195: Update translation (#2722)
(cherry picked from commit 9869a36c2aaa5ed7125da592e9b1e8f7dcc1b41b)
---
src/views/ItemView.test.js | 2 +-
translations/ui-inventory/en.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/views/ItemView.test.js b/src/views/ItemView.test.js
index 14d975efe..03bb939c6 100644
--- a/src/views/ItemView.test.js
+++ b/src/views/ItemView.test.js
@@ -399,7 +399,7 @@ describe('ItemView', () => {
const confirmationModal = screen.getByText('Update ownership of items');
fireEvent.click(within(confirmationModal).getByText('confirm'));
- await waitFor(() => expect(screen.queryByText('Item ownership could not be updated because it contains local-specific reference data.')).toBeDefined());
+ await waitFor(() => expect(screen.queryByText('Item ownership could not be updated because the record contains local-specific reference data.')).toBeDefined());
});
});
diff --git a/translations/ui-inventory/en.json b/translations/ui-inventory/en.json
index 3fc99a0be..cd4227e2d 100644
--- a/translations/ui-inventory/en.json
+++ b/translations/ui-inventory/en.json
@@ -445,7 +445,7 @@
"updateOwnership.items.modal.heading": "Update ownership of items",
"updateOwnership.items.modal.message": "Would you like to update ownership of Item {itemHrid} from {currentTenant} to {targetTenant}?",
"updateOwnership.item.message.success": "Ownership of item {itemHrid} has been successfully updated to {targetTenantName}",
- "updateOwnership.items.message.error": "Item ownership could not be updated because it contains local-specific reference data.",
+ "updateOwnership.items.message.error": "Item ownership could not be updated because the record contains local-specific reference data.",
"consortialHoldings": "Consortial holdings",
"instanceData": "Administrative data",
"instanceHrid": "Instance HRID",
From 8769575f5091116cf47f0b77d02fbcb0cf547bd4 Mon Sep 17 00:00:00 2001
From: Mariia_Aloshyna
Date: Fri, 24 Jan 2025 16:53:34 +0200
Subject: [PATCH 3/3] Release v12.0.11
---
CHANGELOG.md | 3 ++-
package.json | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 01fd20595..00aa24292 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
# Change history for ui-inventory
-## [12.0.11] (IN PROGRESS)
+## [12.0.11](https://github.com/folio-org/ui-inventory/tree/v12.0.11) (2025-01-24)
+[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v12.0.10...v12.0.11)
* Display failure message during `Update Ownership` action when Item contains Local reference data. Fixes UIIN-3195.
diff --git a/package.json b/package.json
index 7e8a14cf9..64de091a6 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@folio/inventory",
- "version": "12.0.10",
+ "version": "12.0.11",
"description": "Inventory manager",
"repository": "folio-org/ui-inventory",
"publishConfig": {