From 87de81f8d87574889550322eeb49e5e56982ebcd Mon Sep 17 00:00:00 2001 From: Mikita Siadykh Date: Wed, 23 Oct 2024 13:58:20 +0300 Subject: [PATCH] UIBULKED-545 Clean up permissions (#620) --- CHANGELOG.md | 1 + package.json | 44 +++++++++++-------- .../PermissionsModal/PermissionsModal.test.js | 2 +- src/hooks/useBulkPermissions.js | 12 ++--- 4 files changed, 34 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b8fc4fc..a5b12f31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ * [UIBULKED-559](https://folio-org.atlassian.net/browse/UIBULKED-559) Update subfield validation in MARC form. * [UIBULKED-558](https://folio-org.atlassian.net/browse/UIBULKED-558) Add translation for new "Member" column. * [UIBULKED-556](https://folio-org.atlassian.net/browse/UIBULKED-556) ECS - remove link to affected record in Optimistic error for holdings and items. +* [UIBULKED-545](https://folio-org.atlassian.net/browse/UIBULKED-545) Clean up permissions. ## [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 f835e147..338adfd1 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,9 @@ "subPermissions": [] }, { - "permissionName": "ui-bulk-edit.view.base", + "permissionName": "ui-bulk-edit.base-view.manage", "displayName": "Bulk Edit: View base permissions", + "replaces": ["ui-bulk-edit.view.base"], "visible": false, "subPermissions": [ "module.bulk-edit.enabled", @@ -52,11 +53,12 @@ ] }, { - "permissionName": "ui-bulk-edit.edit.base", + "permissionName": "ui-bulk-edit.base-edit.manage", "displayName": "Bulk Edit: View edit permissions", + "replaces": ["ui-bulk-edit.edit.base"], "visible": false, "subPermissions": [ - "ui-bulk-edit.view.base", + "ui-bulk-edit.base-view.manage", "bulk-operations.item.upload.post", "bulk-operations.item.cancel.post", "bulk-operations.item.content-update.post", @@ -79,41 +81,45 @@ ] }, { - "permissionName": "ui-bulk-edit.view", + "permissionName": "ui-bulk-edit.users.csv.view", "displayName": "Bulk Edit: Local - View user records", + "replaces": ["ui-bulk-edit.view"], "visible": true, "subPermissions": [ - "ui-bulk-edit.view.base", - "ui-bulk-edit.edit.base", + "ui-bulk-edit.base-view.manage", + "ui-bulk-edit.base-edit.manage", "bulk-operations.item.users.get" ] }, { - "permissionName": "ui-bulk-edit.edit", + "permissionName": "ui-bulk-edit.users.csv.edit", "displayName": "Bulk Edit: Local - Edit user records", + "replaces": ["ui-bulk-edit.edit"], "subPermissions": [ - "ui-bulk-edit.view", - "ui-bulk-edit.edit.base", + "ui-bulk-edit.users.csv.view", + "ui-bulk-edit.base-edit.manage", "bulk-operations.item.users.put" ], "visible": true }, { - "permissionName": "ui-bulk-edit.app-view", + "permissionName": "ui-bulk-edit.inventory.view", "displayName": "Bulk Edit: In app - View inventory records", + "replaces": ["ui-bulk-edit.app-view"], "subPermissions": [ - "ui-bulk-edit.view.base", - "ui-bulk-edit.edit.base", + "ui-bulk-edit.base-view.manage", + "ui-bulk-edit.base-edit.manage", "bulk-operations.item.inventory.get" ], "visible": true }, { - "permissionName": "ui-bulk-edit.app-edit", + "permissionName": "ui-bulk-edit.inventory.edit", "displayName": "Bulk Edit: In app - Edit inventory records", + "replaces": ["ui-bulk-edit.app-edit"], "subPermissions": [ - "ui-bulk-edit.app-view", - "ui-bulk-edit.edit.base", + "ui-bulk-edit.inventory.view", + "ui-bulk-edit.base-edit.manage", "inventory-storage.item-note-types.collection.get", "inventory-storage.holdings-note-types.collection.get", "inventory-storage.electronic-access-relationships.collection.get", @@ -122,10 +128,11 @@ "visible": true }, { - "permissionName": "ui-bulk-edit.app-edit.users", + "permissionName": "ui-bulk-edit.users.edit", "displayName": "Bulk edit: In app - Edit user records", + "replaces": ["ui-bulk-edit.app-edit.users"], "subPermissions": [ - "ui-bulk-edit.edit.base", + "ui-bulk-edit.base-edit.manage", "bulk-operations.item.users.get", "bulk-operations.item.users.put" ], @@ -143,8 +150,9 @@ "visible": true }, { - "permissionName": "ui-bulk-edit.query", + "permissionName": "ui-bulk-edit.query.execute", "displayName": "Bulk edit: Can build query", + "replaces": ["ui-bulk-edit.query"], "subPermissions": [ "module.bulk-edit.enabled", "usergroups.item.get", diff --git a/src/components/PermissionsModal/PermissionsModal.test.js b/src/components/PermissionsModal/PermissionsModal.test.js index c87d62de..3e90caca 100644 --- a/src/components/PermissionsModal/PermissionsModal.test.js +++ b/src/components/PermissionsModal/PermissionsModal.test.js @@ -19,7 +19,7 @@ jest.mock('./hooks/useAllPermissions'); const permissions = [ { - 'permissionName': 'ui-bulk-edit.app-edit', + 'permissionName': 'ui-bulk-edit.inventory.edit', 'displayName': 'Bulk Edit: In app - Edit', 'id': 'baa169b5-e36c-47fd-bbd7-10ad10fb9ce8', 'mutable': false, diff --git a/src/hooks/useBulkPermissions.js b/src/hooks/useBulkPermissions.js index b01f0780..28df642a 100644 --- a/src/hooks/useBulkPermissions.js +++ b/src/hooks/useBulkPermissions.js @@ -4,16 +4,16 @@ export const useBulkPermissions = () => { const stripes = useStripes(); // CSV perms - const hasCsvViewPerms = stripes.hasPerm('ui-bulk-edit.view'); - const hasCsvEditPerms = stripes.hasPerm('ui-bulk-edit.edit'); + const hasCsvViewPerms = stripes.hasPerm('ui-bulk-edit.users.csv.view'); + const hasCsvEditPerms = stripes.hasPerm('ui-bulk-edit.users.csv.edit'); // In-app perms - const hasInAppViewPerms = stripes.hasPerm('ui-bulk-edit.app-view'); - const hasInAppEditPerms = stripes.hasPerm('ui-bulk-edit.app-edit'); - const hasInAppUsersEditPerms = stripes.hasPerm('ui-bulk-edit.app-edit.users'); + const hasInAppViewPerms = stripes.hasPerm('ui-bulk-edit.inventory.view'); + const hasInAppEditPerms = stripes.hasPerm('ui-bulk-edit.inventory.edit'); + const hasInAppUsersEditPerms = stripes.hasPerm('uui-bulk-edit.users.edit'); // Query perms - const hasQueryPerms = stripes.hasPerm('ui-bulk-edit.query'); + const hasQueryPerms = stripes.hasPerm('ui-bulk-edit.query.execute'); // Inventory const hasItemsPerms = stripes.hasPerm('ui-inventory.item.edit');