MCPcopy Create free account
hub / github.com/bytebase/bytebase / sortRoles

Function sortRoles

frontend/src/utils/iam/role.ts:7–18  ·  view source on GitHub ↗
(roles: string[])

Source from the content-addressed store, hash-verified

5};
6
7export const sortRoles = (roles: string[]) => {
8 return roles.sort((a, b) => {
9 const priority = (role: string) => {
10 const presetRoleIndex = PRESET_ROLES.indexOf(role);
11 if (presetRoleIndex !== -1) {
12 return presetRoleIndex;
13 }
14 return PRESET_ROLES.length + roles.indexOf(role);
15 };
16 return priority(a) - priority(b);
17 });
18};

Callers 3

MemberTableFunction · 0.90
MemberTableByRoleFunction · 0.90
ProfilePageFunction · 0.90

Calls 1

priorityFunction · 0.70

Tested by

no test coverage detected