Skip to content

Commit 2a44364

Browse files
committed
made btn disable for immutablePermissions depending on putUserProfilePermissions perm
1 parent cad7ac1 commit 2a44364

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/components/PermissionsManagement/PermissionListItem.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ function PermissionListItem(props) {
2323
depth,
2424
setPermissions,
2525
darkMode,
26-
authUser,
2726
setRemovedDefaultPermissions,
2827
removedDefaultPermissions,
2928
} = props;
@@ -54,8 +53,7 @@ function PermissionListItem(props) {
5453
setinfoRoleModal(!infoRoleModal);
5554
};
5655
const togglePermission = permissionKey => {
57-
// Default perms can only be managed by Owner role. if logged in user is Owner, default perms are editable
58-
// Add/Delete buttons are only enabled for default perms if logged in user is Owner
56+
// Default perms can only be managed (Add/Delete) by users with "putUserProfilePermissions" perm.
5957
if (immutablePermissions.includes(permissionKey)) {
6058
if (!removedDefaultPermissions?.includes(permissionKey)) {
6159
// deleteing default perm
@@ -225,7 +223,8 @@ function PermissionListItem(props) {
225223
}}
226224
disabled={
227225
!props.hasPermission('putRole') ||
228-
(immutablePermissions.includes(permission) && authUser.role !== 'Owner')
226+
(immutablePermissions.includes(permission) &&
227+
!props.hasPermission('putUserProfilePermissions'))
229228
}
230229
style={darkMode ? boxStyleDark : boxStyle}
231230
>
@@ -278,7 +277,7 @@ function PermissionListItem(props) {
278277
);
279278
}
280279

281-
const mapStateToProps = state => ({ roles: state.role.roles, authUser: state.auth.user });
280+
const mapStateToProps = state => ({ roles: state.role.roles });
282281

283282
const mapDispatchToProps = dispatch => ({
284283
hasPermission: permission => dispatch(hasPermission(permission)),

0 commit comments

Comments
 (0)