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

Release v12.0.11 #2724

Merged
merged 3 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/inventory",
"version": "12.0.10",
"version": "12.0.11",
"description": "Inventory manager",
"repository": "folio-org/ui-inventory",
"publishConfig": {
Expand Down
27 changes: 22 additions & 5 deletions src/views/ItemView.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,15 +540,28 @@ const ItemView = props => {
goBack();
};

const resetFormAndCloseModal = () => {
setTargetTenant({});
setUpdateOwnershipData({});
setIsConfirmUpdateOwnershipModalOpen(false);
};

const showErrorMessage = () => {
calloutContext.sendCallout({
type: 'error',
message: <FormattedMessage id="ui-inventory.communicationProblem" />,
});

setTargetTenant({});
setUpdateOwnershipData({});
setIsConfirmUpdateOwnershipModalOpen(false);
resetFormAndCloseModal();
};

const showReferenceDataError = () => {
calloutContext.sendCallout({
type: 'error',
message: <FormattedMessage id="ui-inventory.updateOwnership.items.message.error" />,
});

resetFormAndCloseModal();
};

const createNewHoldingForlocation = async (itemId, targetLocation, targetTenantId) => {
Expand Down Expand Up @@ -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();
}
}
}
};
Expand Down
36 changes: 34 additions & 2 deletions src/views/ItemView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(<ItemViewSetup />, 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(<ItemViewSetup />, translationsProperties);
Expand Down
1 change: 1 addition & 0 deletions translations/ui-inventory/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@
"updateOwnership.items.modal.heading": "Update ownership of items",
"updateOwnership.items.modal.message": "Would you like to update ownership of Item <strong>{itemHrid}</strong> from <strong>{currentTenant}</strong> to <strong>{targetTenant}</strong>?",
"updateOwnership.item.message.success": "Ownership of item <strong>{itemHrid}</strong> has been successfully updated to <strong>{targetTenantName}</strong>",
"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",
Expand Down
Loading