Authorization: Fix filtered role display (#104953)
* handle null or empty group and displayName properties on roles * fix display name bug for fixed roles with a period
This commit is contained in:
@@ -7,21 +7,25 @@ export const isNotDelegatable = (role: Role) => {
|
||||
// addDisplayNameForFixedRole provides a fallback name for fixed roles
|
||||
// this is "incase" a fixed role is introduced but without a displayname set
|
||||
// example: currently this would give:
|
||||
// fixed:datasources:name -> datasources name
|
||||
// fixed:datasources:name -> datasources name
|
||||
// fixed:datasources:admin -> datasources admin
|
||||
// fixed:support.bundles:writer -> support bundles writer
|
||||
export const addDisplayNameForFixedRole = (role: Role) => {
|
||||
const fixedRolePrefix = 'fixed:';
|
||||
if (!role.displayName && role.name.startsWith(fixedRolePrefix)) {
|
||||
let newRoleName = '';
|
||||
let rNameWithoutFixedPrefix = role.name.replace(fixedRolePrefix, '');
|
||||
newRoleName = rNameWithoutFixedPrefix.replace(/:/g, ' ');
|
||||
newRoleName = rNameWithoutFixedPrefix.replace(/[:\\.]/g, ' ');
|
||||
role.displayName = newRoleName;
|
||||
}
|
||||
return role;
|
||||
};
|
||||
|
||||
// Adds a display name for use when the list of roles is filtered
|
||||
// If either group or displayName are undefined, we fall back (see RoleMenuOption.tsx)
|
||||
export const addFilteredDisplayName = (role: Role) => {
|
||||
role.filteredDisplayName = role.group + ':' + role.displayName;
|
||||
if (role.group && role.displayName) {
|
||||
role.filteredDisplayName = role.group + ':' + role.displayName;
|
||||
}
|
||||
return role;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user