Skip to content

Commit

Permalink
console: disable selecting roles without permissions for bulk actions (
Browse files Browse the repository at this point in the history
…close #4178) (#4195)
  • Loading branch information
sobrinho committed Mar 26, 2020
1 parent 84c6b00 commit b53533c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@
- console: add design system base components (#3866)
- docs: add docs for redeliver_event API
- option to reload remote schemas in 'reload_metadata' API (fix #3792, #4117)
- console: disable selecting roles without permissions for bulk actions (close #4178) (#4195)
- console: show remote schema / event trigger intro sections always (#4044)
3 changes: 2 additions & 1 deletion console/src/components/Common/Permissions/TableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ const TableRow = ({
className={styles.cursorPointer}
checked={bulkSection.checked}
data-role={bulkSection.role}
title="Select for bulk actions"
disabled={bulkSection.disableCheckbox}
title={bulkSection.title}
type="checkbox"
/>
{/*{deleteIcon}*/}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,21 @@ class Permissions extends Component {
};

const getPermissionsTableBody = () => {
const rolePermissions = getTablePermissionsByRoles(tableSchema);

const getBulkCheckbox = (role, isNewRole) => {
const dispatchBulkSelect = e => {
const isChecked = e.target.checked;
const selectedRole = e.target.getAttribute('data-role');
dispatch(permSetBulkSelect(isChecked, selectedRole));
};

const disableCheckbox = !Object.keys(rolePermissions).includes(role);

return {
showCheckbox: !(role === 'admin' || isNewRole),
disableCheckbox,
title: disableCheckbox ? 'No permissions exist' : 'Select for bulk actions',
bulkSelect: permissionsState.bulkSelect,
onChange: dispatchBulkSelect,
role,
Expand Down Expand Up @@ -335,8 +341,6 @@ class Permissions extends Component {
const getRoleQueryPermission = queryType => {
let _permission;

const rolePermissions = getTablePermissionsByRoles(tableSchema);

if (role === 'admin') {
_permission = permissionsSymbols.fullAccess;
} else if (!Object.keys(rolePermissions).includes(role)) {
Expand Down

0 comments on commit b53533c

Please sign in to comment.