56d392424d
* feat(workspaces): move project, like this * fix(workspaces): use new event * fix(workspaces): add resolver again after merge * chore(workspaces): lint * fix(workspaces): works but is a bit illegal * fix(workspaces): use service update * chore(workspaces): add unit tests * fix(workspaces): use transaction --------- Co-authored-by: Gergő Jedlicska <gergo@jedlicska.com>
15 lines
553 B
TypeScript
15 lines
553 B
TypeScript
import { UserRoleData } from '@/modules/shared/domain/rolesAndScopes/types'
|
|
import { AvailableRoles } from '@speckle/shared'
|
|
import { isUndefined } from 'lodash'
|
|
|
|
export const orderByWeight = <T extends AvailableRoles>(
|
|
roles: T[],
|
|
definitions: UserRoleData<T>[]
|
|
): UserRoleData<T>[] => {
|
|
const roleDefinitions = roles
|
|
.map((role) => definitions.find((definition) => definition.name === role))
|
|
.filter((definition): definition is UserRoleData<T> => !isUndefined(definition))
|
|
|
|
return roleDefinitions.sort((a, b) => b.weight - a.weight)
|
|
}
|