mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 04:59:15 -06:00
8f78b0e7bc
* Chore: Fix typescript strict null errors * Added new limit * Fixed ts issue * fixed tests * trying to fix type inference * Fixing more ts errors * Revert tsconfig option * Fix * Fixed code * More fixes * fix tests * Updated snapshot * Chore: More ts strict null fixes * More fixes in some really messed up azure config components * More fixes, current count: 441 * 419 * More fixes * Fixed invalid initial state in explore * Fixing tests * Fixed tests * Explore fix * More fixes * Progress * Sub 300 * Now at 218 * Progress * Update * Progress * Updated tests * at 159 * fixed tests * Progress * YAy blow 100! at 94 * 10,9,8,7,6,5,4,3,2,1... lift off * Fixed tests * Fixed more type errors Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
33 lines
805 B
TypeScript
33 lines
805 B
TypeScript
import { DashboardAcl, DashboardAclDTO } from 'app/types/acl';
|
|
|
|
export function processAclItems(items: DashboardAclDTO[]): DashboardAcl[] {
|
|
return items.map(processAclItem).sort((a, b) => b.sortRank! - a.sortRank! || a.name!.localeCompare(b.name!));
|
|
}
|
|
|
|
function processAclItem(dto: DashboardAclDTO): DashboardAcl {
|
|
const item = dto as DashboardAcl;
|
|
|
|
item.sortRank = 0;
|
|
|
|
if (item.userId! > 0) {
|
|
item.name = item.userLogin;
|
|
item.sortRank = 10;
|
|
} else if (item.teamId! > 0) {
|
|
item.name = item.team;
|
|
item.sortRank = 20;
|
|
} else if (item.role) {
|
|
item.icon = 'fa fa-fw fa-street-view';
|
|
item.name = item.role;
|
|
item.sortRank = 30;
|
|
if (item.role === 'Editor') {
|
|
item.sortRank += 1;
|
|
}
|
|
}
|
|
|
|
if (item.inherited) {
|
|
item.sortRank += 100;
|
|
}
|
|
|
|
return item;
|
|
}
|