-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ESSNTL-5206): Group-level RBAC and actions (#1950)
Implements https://issues.redhat.com/browse/ESSNTL-5206. - Do additional RBAC check on the group level if a selected host is in a group. - Enable the bulk Delete button is user has inventory:hosts:write for all systems selected. Also, if the selected hosts are in a group, then calculate the minimal RBAC required permissions accordingly. --------- Co-authored-by: Aleksandr Voznesenskii <[email protected]>
- Loading branch information
Showing
5 changed files
with
316 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* This module contains Button and DropdownItem components wrapped by RBAC checks. | ||
*/ | ||
import React from 'react'; | ||
import { usePermissionsWithContext } from '@redhat-cloud-services/frontend-components-utilities/RBACHook'; | ||
import { Button, DropdownItem, Tooltip } from '@patternfly/react-core'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export const ActionButton = ({ | ||
requiredPermissions, | ||
noAccessTooltip, | ||
checkAll, | ||
...props | ||
}) => { | ||
const { hasAccess: enabled } = usePermissionsWithContext( | ||
requiredPermissions, | ||
checkAll | ||
); | ||
|
||
return enabled ? ( | ||
<Button {...props} /> | ||
) : ( | ||
<Tooltip content={noAccessTooltip}> | ||
<Button {...props} isAriaDisabled /> | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
ActionButton.propTypes = { | ||
requiredPermissions: PropTypes.array, | ||
noAccessTooltip: PropTypes.string, | ||
checkAll: PropTypes.bool, | ||
}; | ||
|
||
ActionButton.defaultProps = { | ||
checkAll: false, | ||
}; | ||
|
||
export const ActionDropdownItem = ({ | ||
requiredPermissions, | ||
noAccessTooltip, | ||
...props | ||
}) => { | ||
const { hasAccess: enabled } = usePermissionsWithContext(requiredPermissions); | ||
|
||
return enabled ? ( | ||
<DropdownItem {...props} /> | ||
) : ( | ||
<DropdownItem {...props} isAriaDisabled tooltip={noAccessTooltip} /> | ||
); | ||
}; | ||
|
||
ActionDropdownItem.propTypes = { | ||
requiredPermissions: PropTypes.array, | ||
noAccessTooltip: PropTypes.string, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.