diff --git a/CHANGELOG.md b/CHANGELOG.md
index 224e97ed..68367e43 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -34,7 +34,7 @@
* [UIBULKED-282](https://issues.folio.org/browse/UIBULKED-282) Files generated more than 30 days ago can be downloaded from the "Logs".
* [UIBULKED-274](https://issues.folio.org/browse/UIBULKED-274) Create reusable permission-select component
* [UIBULKED-311](https://issues.folio.org/browse/UIBULKED-311) Bulk edit actions for notes - duplicate note.
-
+* [UIBULKED-321](https://issues.folio.org/browse/UIBULKED-321) Permissions for editing Inventory records.
## [3.0.5](https://github.com/folio-org/ui-bulk-edit/tree/v3.0.5) (2023-03-22)
diff --git a/package.json b/package.json
index ffbb7afc..c008f761 100644
--- a/package.json
+++ b/package.json
@@ -91,7 +91,8 @@
"permissionName": "ui-bulk-edit.app-view",
"displayName": "Bulk Edit: In app - View inventory records",
"subPermissions": [
- "ui-bulk-edit.view.base"
+ "ui-bulk-edit.view.base",
+ "ui-bulk-edit.edit.base"
],
"visible": true
},
diff --git a/src/components/BulkEditActionMenu/BulkEditActionMenu.js b/src/components/BulkEditActionMenu/BulkEditActionMenu.js
index 37244b7e..8ee3d7af 100644
--- a/src/components/BulkEditActionMenu/BulkEditActionMenu.js
+++ b/src/components/BulkEditActionMenu/BulkEditActionMenu.js
@@ -38,7 +38,8 @@ const BulkEditActionMenu = ({
const {
hasCsvEditPerms,
- hasAnyInAppEditPermissions,
+ hasHoldingsInventoryEdit,
+ hasItemInventoryEdit,
} = perms;
const { id } = usePathParams('/bulk-edit/:id');
@@ -46,6 +47,8 @@ const BulkEditActionMenu = ({
const [fileInfo, setFileInfo] = useState(null);
+ const hasEditPerm = hasHoldingsInventoryEdit || hasItemInventoryEdit;
+
useFileDownload({
id,
fileInfo,
@@ -62,7 +65,7 @@ const BulkEditActionMenu = ({
const isStartBulkCsvActive = hasCsvEditPerms && capability === CAPABILITIES.USER;
const isInitialStep = step === EDITING_STEPS.UPLOAD;
const isStartBulkInAppActive =
- hasAnyInAppEditPermissions
+ hasEditPerm
&& isInitialStep
&& [JOB_STATUSES.DATA_MODIFICATION, JOB_STATUSES.REVIEW_CHANGES].includes(bulkDetails?.status);
diff --git a/src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js b/src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js
index fc4bcc5b..f5418809 100644
--- a/src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js
+++ b/src/components/BulkEditList/BulkEditListFilters/BulkEditListFilters.js
@@ -53,8 +53,8 @@ export const BulkEditListFilters = ({
hasCsvViewPerms,
hasInAppUsersEditPerms,
hasInAppViewPerms,
- hasViewInAppPerms,
hasOnlyViewCsvPerms,
+ hasAnyInventoryWithInAppView,
} = permissions;
const showCallout = useShowCallout();
const history = useHistory();
@@ -235,7 +235,10 @@ export const BulkEditListFilters = ({
const renderListSelect = () => (
@@ -249,7 +252,7 @@ export const BulkEditListFilters = ({
handleDrop={handleDrop}
isDropZoneDisabled={isDropZoneDisabled
||
- getIsDisabledByPerm(capabilities, isDropZoneDisabledPerm, hasOnlyViewCsvPerms, hasViewInAppPerms)}
+ getIsDisabledByPerm(capabilities, isDropZoneDisabledPerm, hasOnlyViewCsvPerms, hasAnyInventoryWithInAppView)}
recordIdentifier={recordIdentifier}
handleDragLeave={handleDragLeave}
handleDragEnter={handleDragEnter}
diff --git a/src/components/BulkEditList/BulkEditListFilters/Capabilities/Capabilities.js b/src/components/BulkEditList/BulkEditListFilters/Capabilities/Capabilities.js
index d3bd1263..9301a07f 100644
--- a/src/components/BulkEditList/BulkEditListFilters/Capabilities/Capabilities.js
+++ b/src/components/BulkEditList/BulkEditListFilters/Capabilities/Capabilities.js
@@ -19,15 +19,17 @@ const Capabilities = ({
>
{capabilitiesFilterOptions?.map(option => (
-
+ !option.hidden && (
+
+ )
))}
diff --git a/src/components/BulkEditList/BulkEditListFilters/utils/getIsDisabledByPerm.js b/src/components/BulkEditList/BulkEditListFilters/utils/getIsDisabledByPerm.js
index b52e1723..8d5a8703 100644
--- a/src/components/BulkEditList/BulkEditListFilters/utils/getIsDisabledByPerm.js
+++ b/src/components/BulkEditList/BulkEditListFilters/utils/getIsDisabledByPerm.js
@@ -9,7 +9,7 @@ export const getIsDisabledByPerm = (capabilities, defaultPerm, csvPerm, inAppVie
case CAPABILITIES.ITEM:
case CAPABILITIES.HOLDING:
if (inAppView) {
- return true;
+ return false;
} else return defaultPerm;
default: return defaultPerm;
diff --git a/src/components/BulkEditList/BulkEditListFilters/utils/getIsDisabledByPerm.test.js b/src/components/BulkEditList/BulkEditListFilters/utils/getIsDisabledByPerm.test.js
index 082cbf34..b05d4036 100644
--- a/src/components/BulkEditList/BulkEditListFilters/utils/getIsDisabledByPerm.test.js
+++ b/src/components/BulkEditList/BulkEditListFilters/utils/getIsDisabledByPerm.test.js
@@ -15,7 +15,7 @@ describe('getIsDisabledByPerm', () => {
csvPerm = false;
inAppPerm = true;
- expect(getIsDisabledByPerm(CAPABILITIES.ITEM, false, csvPerm, inAppPerm)).toBe(true);
+ expect(getIsDisabledByPerm(CAPABILITIES.ITEM, false, csvPerm, inAppPerm)).toBe(false);
});
it('should return correct boolean with default Perm', () => {
diff --git a/src/components/BulkEditLogs/BulkEditLogsActions/BulkEditLogsActions.js b/src/components/BulkEditLogs/BulkEditLogsActions/BulkEditLogsActions.js
index 58626b7c..a039d8e6 100644
--- a/src/components/BulkEditLogs/BulkEditLogsActions/BulkEditLogsActions.js
+++ b/src/components/BulkEditLogs/BulkEditLogsActions/BulkEditLogsActions.js
@@ -20,7 +20,12 @@ import { CAPABILITIES, linkNamesMap } from '../../../constants';
import { useBulkPermissions } from '../../../hooks';
const BulkEditLogsActions = ({ item }) => {
- const { hasUsersViewPerms } = useBulkPermissions();
+ const {
+ hasUsersViewPerms,
+ hasLogItemViewPerms,
+ hasLogHoldingsViewPerms,
+ hasInventoryInstanceViewPerms,
+ } = useBulkPermissions();
const [triggeredFile, setTriggeredFile] = useState(null);
const { refetch } = useFileDownload({
enabled: false,
@@ -80,6 +85,10 @@ const BulkEditLogsActions = ({ item }) => {
), [availableFiles]);
if (item.entityType === CAPABILITIES.USER && !hasUsersViewPerms) return null;
+ if (item.entityType === CAPABILITIES.HOLDING &&
+ (!hasLogHoldingsViewPerms || !hasInventoryInstanceViewPerms)) return null;
+ if (item.entityType === CAPABILITIES.ITEM &&
+ (!hasLogItemViewPerms && !hasInventoryInstanceViewPerms)) return null;
return (
item.expired ?
diff --git a/src/hooks/useBulkPermissions.js b/src/hooks/useBulkPermissions.js
index e21e2497..7cd41f55 100644
--- a/src/hooks/useBulkPermissions.js
+++ b/src/hooks/useBulkPermissions.js
@@ -32,12 +32,20 @@ export const useBulkPermissions = () => {
const isActionMenuShown = hasCsvEditPerms || hasAnyInAppEditPermissions;
const isSelectIdentifiersDisabled = !hasAnyEditPermissions;
const isDropZoneDisabled = !hasAnyEditPermissions;
- const isInventoryRadioDisabled = !hasInAppViewPerms;
const isUserRadioDisabled = !hasCsvViewPerms && !hasInAppUsersEditPerms;
const hasOnlyInAppViewPerms = hasInAppViewPerms && !hasCsvEditPerms && !hasInAppEditPerms && !hasInAppUsersEditPerms;
+ const hasItemInventoryView = hasInAppViewPerms && hasItemsPerms;
+ const hasHoldingsInventoryView = hasInAppViewPerms && hasHoldingsPerms;
+ const hasItemsAndHoldingsInventoryView = hasInAppViewPerms && hasInventoryInstanceViewPerms;
+ const hasItemInventoryEdit = hasInAppEditPerms && hasItemsPerms;
+ const hasHoldingsInventoryEdit = hasInAppEditPerms && hasHoldingsPerms;
+ const hasAnyInventoryWithInAppView = (hasItemInventoryView || hasHoldingsInventoryView
+ || hasItemsAndHoldingsInventoryView) && hasInAppViewPerms;
// Logs perms
const hasLogViewPerms = stripes.hasPerm('ui-bulk-edit.logs.view');
+ const hasLogItemViewPerms = hasLogViewPerms && hasItemsPerms;
+ const hasLogHoldingsViewPerms = hasLogViewPerms && hasHoldingsPerms;
return {
// base
@@ -54,7 +62,6 @@ export const useBulkPermissions = () => {
isActionMenuShown,
isSelectIdentifiersDisabled,
isDropZoneDisabled,
- isInventoryRadioDisabled,
isUserRadioDisabled,
hasOnlyInAppViewPerms,
hasAnyEditPermissions,
@@ -65,5 +72,13 @@ export const useBulkPermissions = () => {
hasUsersViewPerms,
hasOnlyViewCsvPerms,
hasViewInAppPerms,
+ hasItemInventoryEdit,
+ hasHoldingsInventoryEdit,
+ hasItemInventoryView,
+ hasHoldingsInventoryView,
+ hasItemsAndHoldingsInventoryView,
+ hasAnyInventoryWithInAppView,
+ hasLogItemViewPerms,
+ hasLogHoldingsViewPerms,
};
};
diff --git a/src/utils/filters.js b/src/utils/filters.js
index f88ceb16..430e9ab6 100644
--- a/src/utils/filters.js
+++ b/src/utils/filters.js
@@ -9,16 +9,19 @@ export const isCapabilityDisabled = (capabilityValue, view, perms = {}) => {
const {
isUserRadioDisabled,
- isInventoryRadioDisabled,
- hasItemsPerms,
- hasHoldingsPerms,
+ hasItemInventoryView,
+ hasHoldingsInventoryView,
+ hasItemsAndHoldingsInventoryView,
hasUsersPerms,
} = perms;
const capabilitiesMap = {
[CAPABILITIES.USER]: isQuery ? !hasUsersPerms : isUserRadioDisabled,
- [CAPABILITIES.ITEM]: isQuery ? !hasItemsPerms : isInventoryRadioDisabled,
- [CAPABILITIES.HOLDING]: isQuery ? !hasHoldingsPerms : isInventoryRadioDisabled,
+ [CAPABILITIES.ITEM]: hasItemInventoryView ?
+ !hasItemInventoryView : !hasItemsAndHoldingsInventoryView,
+ [CAPABILITIES.HOLDING]: hasHoldingsInventoryView ?
+ !hasHoldingsInventoryView :
+ !hasItemsAndHoldingsInventoryView,
};
return capabilitiesMap[capabilityValue];
@@ -26,13 +29,13 @@ export const isCapabilityDisabled = (capabilityValue, view, perms = {}) => {
export const getCapabilityOptions = (view, perms) => EDIT_CAPABILITIES_OPTIONS.map(capability => ({
...capability,
- disabled: isCapabilityDisabled(capability.value, view, perms),
+ hidden: isCapabilityDisabled(capability.value, view, perms),
}));
export const getDefaultCapabilities = (view, perms) => {
const capabilityOptions = getCapabilityOptions(view, perms);
- return capabilityOptions.find(option => !option.disabled)?.value;
+ return capabilityOptions.find(option => !option.hidden)?.value;
};
export const groupByCategory = (array) => {