diff --git a/CHANGELOG.md b/CHANGELOG.md
index 45f12bd11..00aa24292 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# Change history for ui-inventory
+## [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.
+
## [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/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": {
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..03bb939c6 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 the record 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..cd4227e2d 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 the record contains local-specific reference data.",
"consortialHoldings": "Consortial holdings",
"instanceData": "Administrative data",
"instanceHrid": "Instance HRID",