Skip to content

Commit

Permalink
Release v11.0.2 (#2452)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariia-aloshyna committed Apr 19, 2024
1 parent aee9c87 commit ec3a92f
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 22 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change history for ui-inventory

## [11.0.2](https://github.com/folio-org/ui-inventory/tree/v11.0.2) (2024-04-19)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v11.0.1...v11.0.2)

* ECS: Shared instance cannot be edited from member tenant, even with permissions in both Central and member tenants. Fixes UIIN-2845.
* Restricted status displays as Order Closed. Fixes UIIN-2821.
* Add a new "Inventory: Create and download In transit items report" permission. Fixes UIIN-2776.
* Include mod-search permissions to "Inventory: Module is enabled" UI permission. Refs UIIN-2860.

## [11.0.1](https://github.com/folio-org/ui-inventory/tree/v11.0.1) (2024-04-11)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v11.0.0...v11.0.1)

Expand Down
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/inventory",
"version": "11.0.1",
"version": "11.0.2",
"description": "Inventory manager",
"repository": "folio-org/ui-inventory",
"publishConfig": {
Expand Down Expand Up @@ -119,7 +119,9 @@
"search.config.languages.collection.get",
"search.config.languages.item.delete",
"search.index.inventory.reindex.post",
"search.facets.collection.get"
"search.facets.collection.get",
"consortium-search.holdings.collection.get",
"consortium-search.items.collection.get"
]
},
{
Expand Down Expand Up @@ -834,6 +836,14 @@
],
"visible": true
},
{
"permissionName": "ui-inventory.items.create-in-transit-report",
"displayName": "Inventory: Create and download In transit items report",
"subPermissions": [
"circulation.inventory.items-in-transit-report.get"
],
"visible": true
},
{
"permissionName": "ui-inventory.single-record-import",
"displayName": "Inventory: Import single bibliographic records",
Expand Down
4 changes: 2 additions & 2 deletions src/ViewInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ class ViewInstance extends React.Component {
};

hasCentralTenantPerm = (perm) => {
return this.props.centralTenantPermissions.some(({ permissionName }) => permissionName === perm);
return this.props.centralTenantPermissions.has(perm);
}

createActionMenuGetter = (instance, data) => ({ onToggle }) => {
Expand Down Expand Up @@ -1161,7 +1161,7 @@ class ViewInstance extends React.Component {
ViewInstance.propTypes = {
isShared: PropTypes.bool,
canUseSingleRecordImport: PropTypes.bool,
centralTenantPermissions: PropTypes.arrayOf(PropTypes.object).isRequired,
centralTenantPermissions: PropTypes.instanceOf(Set).isRequired,
selectedInstance: PropTypes.object,
centralTenantId: PropTypes.string,
refetchInstance: PropTypes.func,
Expand Down
16 changes: 5 additions & 11 deletions src/ViewInstance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const mockStripes = {
},
};
const defaultProp = {
centralTenantPermissions: [],
centralTenantPermissions: new Set([]),
selectedInstance: instance,
centralTenantId: 'centralTenantId',
consortiumId: 'consortiumId',
Expand Down Expand Up @@ -863,9 +863,7 @@ describe('ViewInstance', () => {
StripesConnectedInstance.prototype.instance.mockImplementation(() => sharedInstance);

renderViewInstance({
centralTenantPermissions: [{
permissionName: 'ui-quick-marc.quick-marc-editor.all',
}],
centralTenantPermissions: new Set(['ui-quick-marc.quick-marc-editor.all']),
isShared: true,
tenantId: 'tenantId',
});
Expand All @@ -886,7 +884,7 @@ describe('ViewInstance', () => {
StripesConnectedInstance.prototype.instance.mockImplementation(() => sharedInstance);

renderViewInstance({
centralTenantPermissions: [],
centralTenantPermissions: new Set([]),
isShared: true,
tenantId: 'tenantId',
});
Expand Down Expand Up @@ -914,9 +912,7 @@ describe('ViewInstance', () => {
};

renderViewInstance({
centralTenantPermissions: [{
permissionName: 'ui-quick-marc.quick-marc-editor.all',
}],
centralTenantPermissions: new Set(['ui-quick-marc.quick-marc-editor.all']),
stripes,
isShared: true,
tenantId: 'tenantId',
Expand Down Expand Up @@ -1082,9 +1078,7 @@ describe('ViewInstance', () => {
describe('when user is in member tenant and instance is shared and has central tenant permission to set record for deletion', () => {
it('should render "Set record for deletion" action item', () => {
renderViewInstance({
centralTenantPermissions: [{
permissionName: 'ui-inventory.instance.set-deletion-and-staff-suppress',
}],
centralTenantPermissions: new Set(['ui-inventory.instance.set-deletion-and-staff-suppress']),
isShared: true,
tenantId: 'tenantId',
});
Expand Down
15 changes: 13 additions & 2 deletions src/ViewInstanceWrapper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';

import { checkIfUserInMemberTenant } from '@folio/stripes/core';
Expand Down Expand Up @@ -42,6 +42,17 @@ const ViewInstanceWrapper = (props) => {
enabled: Boolean(isShared && checkIfUserInMemberTenant(stripes)),
});

const flattenCentralTenantPermissions = useMemo(() => {
// Set is used to collect unique permission names because subPermissions can duplicate
return new Set(centralTenantPermissions?.reduce((acc, currentPermission) => {
return [
...acc,
currentPermission.permissionName,
...currentPermission.subPermissions,
];
}, []));
}, [centralTenantPermissions]);

const mutateInstance = (entity, { onError }) => {
mutateEntity(entity, { onSuccess: refetch, onError });
};
Expand All @@ -59,7 +70,7 @@ const ViewInstanceWrapper = (props) => {
isLoading={isLoading}
isError={isError}
error={error}
centralTenantPermissions={centralTenantPermissions}
centralTenantPermissions={flattenCentralTenantPermissions}
isCentralTenantPermissionsLoading={isCentralTenantPermissionsLoading}
/>
);
Expand Down
7 changes: 6 additions & 1 deletion src/ViewInstanceWrapper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ describe('ViewInstanceWrapper', () => {
it('should fetch the central tenant permissions', () => {
const userPermissions = [{
permissionName: 'ui-quick-marc.quick-marc-editor.all',
subPermissions: ['ui-inventory.instance.create'],
}, {
permissionName: 'ui-inventory.instance.create',
subPermissions: [],
}];
const flattenUserPermissions = new Set(['ui-quick-marc.quick-marc-editor.all', 'ui-inventory.instance.create']);

useInstance.mockReturnValue({
instance: {
Expand All @@ -95,7 +100,7 @@ describe('ViewInstanceWrapper', () => {
enabled: true,
});

expect(ViewInstance.mock.calls[0][0].centralTenantPermissions).toEqual(userPermissions);
expect(ViewInstance.mock.calls[0][0].centralTenantPermissions).toEqual(flattenUserPermissions);
expect(ViewInstance.mock.calls[0][0].isCentralTenantPermissionsLoading).toBeFalsy();
});
});
Expand Down
3 changes: 2 additions & 1 deletion src/components/InstancesList/InstancesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ class InstancesList extends React.Component {
const visibleColumns = this.getVisibleColumns();
const columnMapping = this.getColumnMapping();
const canExportMarc = stripes.hasPerm('ui-data-export.app.enabled');
const canCreateItemsInTransitReport = stripes.hasPerm('ui-inventory.items.create-in-transit-report');

const buildOnClickHandler = onClickHandler => {
return () => {
Expand Down Expand Up @@ -843,7 +844,7 @@ class InstancesList extends React.Component {
icon: 'report',
messageId: 'ui-inventory.exportInProgress',
}) :
!checkIfUserInCentralTenant(stripes) && this.getActionItem({
canCreateItemsInTransitReport && !checkIfUserInCentralTenant(stripes) && this.getActionItem({
id: 'dropdown-clickable-get-report',
icon: 'report',
messageId: 'ui-inventory.inTransitReport',
Expand Down
6 changes: 3 additions & 3 deletions src/components/ItemViewSubheader/ItemViewSubheader.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ const ITEM_STATUS_TRANSLATIONS_ID_MAP = {
[itemStatusesMap.LOST_AND_PAID]: 'ui-inventory.item.status.lostAndPaid.lowercase',
[itemStatusesMap.MISSING]: 'ui-inventory.item.status.missing.lowercase',
[itemStatusesMap.ON_ORDER]: 'ui-inventory.item.status.onOrder.lowercase',
[itemStatusesMap.ORDER_CLOSED]: 'ui-inventory.item.status.paged.lowercase',
[itemStatusesMap.PAGED]: 'ui-inventory.item.status.restricted.lowercase',
[itemStatusesMap.RESTRICTED]: 'ui-inventory.item.status.orderClosed.lowercase',
[itemStatusesMap.ORDER_CLOSED]: 'ui-inventory.item.status.orderClosed.lowercase',
[itemStatusesMap.PAGED]: 'ui-inventory.item.status.paged.lowercase',
[itemStatusesMap.RESTRICTED]: 'ui-inventory.item.status.restricted.lowercase',
[itemStatusesMap.UNAVAILABLE]: 'ui-inventory.item.status.unavailable.lowercase',
[itemStatusesMap.UNKNOWN]: 'ui-inventory.item.status.unknown.lowercase',
[itemStatusesMap.WITHDRAWN]: 'ui-inventory.item.status.withdrawn.lowercase',
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 @@ -752,6 +752,7 @@
"permission.items.mark-long-missing": "Inventory: Mark items long missing",
"permission.items.mark-in-process-non-requestable": "Inventory: Mark items in process (non-requestable)",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"permission.items.create-in-transit-report": "Inventory: Create and download In transit items report",

"moveItems.moveButton": "Move to",
"moveItems.selectAll": "Select/unselect all items for movement",
Expand Down

0 comments on commit ec3a92f

Please sign in to comment.