fix sorting of users and groups
This commit is contained in:
parent
5226f7389b
commit
d2284c2f0a
|
@ -12,7 +12,12 @@
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import { groups, licensing, apps, users, auth, admin } from "stores/portal"
|
import { groups, licensing, apps, users, auth, admin } from "stores/portal"
|
||||||
import { fetchData, Constants, Utils } from "@budibase/frontend-core"
|
import {
|
||||||
|
fetchData,
|
||||||
|
Constants,
|
||||||
|
Utils,
|
||||||
|
RoleUtils,
|
||||||
|
} from "@budibase/frontend-core"
|
||||||
import { sdk } from "@budibase/shared-core"
|
import { sdk } from "@budibase/shared-core"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import GroupIcon from "../../../portal/users/groups/_components/GroupIcon.svelte"
|
import GroupIcon from "../../../portal/users/groups/_components/GroupIcon.svelte"
|
||||||
|
@ -132,16 +137,29 @@
|
||||||
isAppBuilder,
|
isAppBuilder,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.sort((a, b) => {
|
.sort(sortRoles)
|
||||||
const roleA = a.role
|
}
|
||||||
const roleB = b.role
|
|
||||||
if (roleA === undefined && roleB !== undefined) {
|
const sortRoles = (a, b) => {
|
||||||
return 1
|
const roleA = a.role
|
||||||
} else if (roleA !== undefined && roleB === undefined) {
|
const roleB = b.role
|
||||||
return -1
|
|
||||||
}
|
const priorityA = RoleUtils.getRolePriority(roleA)
|
||||||
return 0
|
const priorityB = RoleUtils.getRolePriority(roleB)
|
||||||
})
|
|
||||||
|
if (roleA === undefined && roleB !== undefined) {
|
||||||
|
return 1
|
||||||
|
} else if (roleA !== undefined && roleB === undefined) {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priorityA < priorityB) {
|
||||||
|
return 1
|
||||||
|
} else if (priorityA > priorityB) {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
const debouncedUpdateFetch = Utils.debounce(searchUsers, 250)
|
const debouncedUpdateFetch = Utils.debounce(searchUsers, 250)
|
||||||
|
@ -251,6 +269,7 @@
|
||||||
return nameMatch
|
return nameMatch
|
||||||
})
|
})
|
||||||
.map(enrichGroupRole)
|
.map(enrichGroupRole)
|
||||||
|
.sort(sortRoles)
|
||||||
}
|
}
|
||||||
|
|
||||||
const enrichGroupRole = group => {
|
const enrichGroupRole = group => {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { Roles } from "../constants"
|
import { Roles } from "../constants"
|
||||||
|
|
||||||
const RolePriorities = {
|
const RolePriorities = {
|
||||||
[Roles.ADMIN]: 4,
|
[Roles.ADMIN]: 5,
|
||||||
|
[Roles.CREATOR]: 4,
|
||||||
[Roles.POWER]: 3,
|
[Roles.POWER]: 3,
|
||||||
[Roles.BASIC]: 2,
|
[Roles.BASIC]: 2,
|
||||||
[Roles.PUBLIC]: 1,
|
[Roles.PUBLIC]: 1,
|
||||||
|
@ -13,8 +14,8 @@ const RoleColours = {
|
||||||
[Roles.PUBLIC]: "var(--spectrum-global-color-static-blue-400)",
|
[Roles.PUBLIC]: "var(--spectrum-global-color-static-blue-400)",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getRolePriority = roleId => {
|
export const getRolePriority = role => {
|
||||||
return RolePriorities[roleId] ?? 0
|
return RolePriorities[role] ?? 0
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getRoleColour = roleId => {
|
export const getRoleColour = roleId => {
|
||||||
|
|
Loading…
Reference in New Issue