mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* remove fallback from backend * add: displayname logic to frontend * Update public/app/core/components/RolePicker/utils.ts Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com> * add: fetchTeamRoles and return earlier * refactor: change to const --------- Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>
22 lines
821 B
TypeScript
22 lines
821 B
TypeScript
import { Role } from 'app/types';
|
|
|
|
export const isNotDelegatable = (role: Role) => {
|
|
return role.delegatable !== undefined && !role.delegatable;
|
|
};
|
|
|
|
// 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:admin -> datasources admin
|
|
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, ' ');
|
|
role.displayName = newRoleName;
|
|
}
|
|
return role;
|
|
};
|