Skip to content

Commit

Permalink
Check for null id when hosts are ungroupped
Browse files Browse the repository at this point in the history
  • Loading branch information
gkarat committed Aug 13, 2023
1 parent fab5588 commit c7ac49a
Showing 1 changed file with 13 additions and 26 deletions.
39 changes: 13 additions & 26 deletions src/routes/InventoryTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import { manageEdgeInventoryUrlName } from '../Utilities/edge';
import { resolveRelPath } from '../Utilities/path';
import {
GENERAL_GROUPS_WRITE_PERMISSION,
GENERAL_HOSTS_WRITE_PERMISSIONS,
NO_MODIFY_GROUPS_TOOLTIP_MESSAGE,
NO_MODIFY_HOSTS_TOOLTIP_MESSAGE,
NO_MODIFY_HOST_TOOLTIP_MESSAGE,
Expand Down Expand Up @@ -108,13 +107,9 @@ export const calculatePagination = (searchParams, page, perPage) => {
};

const BulkDeleteButton = ({ selectedSystems, ...props }) => {
const requiredPermissions = selectedSystems.every(
({ groups }) => groups.length > 0
)
? selectedSystems.map(({ groups }) =>
REQUIRED_PERMISSION_TO_MODIFY_HOST_IN_GROUP(groups[0].id)
)
: [GENERAL_HOSTS_WRITE_PERMISSIONS];
const requiredPermissions = selectedSystems.map(({ groups }) =>
REQUIRED_PERMISSION_TO_MODIFY_HOST_IN_GROUP(groups?.[0]?.id ?? null)
);

return (
<ActionButton
Expand Down Expand Up @@ -303,15 +298,11 @@ const Inventory = ({
setCurrentSystem(row);
onEditOpen(() => true);
}}
requiredPermissions={
row.groups.length > 0
? [
REQUIRED_PERMISSION_TO_MODIFY_HOST_IN_GROUP(
row.groups[0].id
),
]
: ['inventory:hosts:write']
}
requiredPermissions={[
REQUIRED_PERMISSION_TO_MODIFY_HOST_IN_GROUP(
row.groups?.[0]?.id ?? null
),
]}
noAccessTooltip={NO_MODIFY_HOST_TOOLTIP_MESSAGE}
>
Edit
Expand All @@ -329,15 +320,11 @@ const Inventory = ({
setCurrentSystem(row);
handleModalToggle(() => true);
}}
requiredPermissions={
row.groups.length > 0
? [
REQUIRED_PERMISSION_TO_MODIFY_HOST_IN_GROUP(
row.groups[0].id
),
]
: ['inventory:hosts:write']
}
requiredPermissions={[
REQUIRED_PERMISSION_TO_MODIFY_HOST_IN_GROUP(
row.groups?.[0]?.id ?? null
),
]}
noAccessTooltip={NO_MODIFY_HOST_TOOLTIP_MESSAGE}
>
Delete
Expand Down

0 comments on commit c7ac49a

Please sign in to comment.