Update user pages to account for creator role
This commit is contained in:
parent
7dfc516758
commit
2aff73ac25
|
@ -26,6 +26,9 @@ export const capitalise = s => {
|
||||||
|
|
||||||
export const lowercase = s => s.substring(0, 1).toLowerCase() + s.substring(1)
|
export const lowercase = s => s.substring(0, 1).toLowerCase() + s.substring(1)
|
||||||
|
|
||||||
|
export const lowercaseExceptFirst = s =>
|
||||||
|
s.charAt(0) + s.substring(1).toLowerCase()
|
||||||
|
|
||||||
export const get_name = s => (!s ? "" : last(s.split("/")))
|
export const get_name = s => (!s ? "" : last(s.split("/")))
|
||||||
|
|
||||||
export const get_capitalised_name = name => pipe(name, [get_name, capitalise])
|
export const get_capitalised_name = name => pipe(name, [get_name, capitalise])
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
$: scimEnabled = $features.isScimEnabled
|
$: scimEnabled = $features.isScimEnabled
|
||||||
$: isSSO = !!user?.provider
|
$: isSSO = !!user?.provider
|
||||||
$: readonly = !sdk.users.isAdmin($auth.user) || scimEnabled
|
$: readonly = !sdk.users.isAdmin($auth.user) || scimEnabled
|
||||||
$: privileged = sdk.users.isAdminOrBuilder(user)
|
$: privileged = sdk.users.isAdminOrGlobalBuilder(user)
|
||||||
$: nameLabel = getNameLabel(user)
|
$: nameLabel = getNameLabel(user)
|
||||||
$: filteredGroups = getFilteredGroups($groups, searchTerm)
|
$: filteredGroups = getFilteredGroups($groups, searchTerm)
|
||||||
$: availableApps = getAvailableApps($apps, privileged, user?.roles)
|
$: availableApps = getAvailableApps($apps, privileged, user?.roles)
|
||||||
|
@ -108,7 +108,8 @@
|
||||||
let availableApps = appList.slice()
|
let availableApps = appList.slice()
|
||||||
if (!privileged) {
|
if (!privileged) {
|
||||||
availableApps = availableApps.filter(x => {
|
availableApps = availableApps.filter(x => {
|
||||||
return Object.keys(roles || {}).find(y => {
|
let roleKeys = Object.keys(roles || {})
|
||||||
|
return roleKeys.concat(user?.builder?.apps).find(y => {
|
||||||
return x.appId === apps.extractAppId(y)
|
return x.appId === apps.extractAppId(y)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -119,7 +120,11 @@
|
||||||
name: app.name,
|
name: app.name,
|
||||||
devId: app.devId,
|
devId: app.devId,
|
||||||
icon: app.icon,
|
icon: app.icon,
|
||||||
role: privileged ? Constants.Roles.ADMIN : roles[prodAppId],
|
role: privileged
|
||||||
|
? Constants.Roles.ADMIN
|
||||||
|
: user?.builder?.apps.includes(prodAppId)
|
||||||
|
? Constants.Roles.CREATOR
|
||||||
|
: roles[prodAppId],
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,16 @@
|
||||||
import { StatusLight } from "@budibase/bbui"
|
import { StatusLight } from "@budibase/bbui"
|
||||||
import { RoleUtils } from "@budibase/frontend-core"
|
import { RoleUtils } from "@budibase/frontend-core"
|
||||||
import { roles } from "stores/backend"
|
import { roles } from "stores/backend"
|
||||||
|
import { Constants } from "@budibase/frontend-core"
|
||||||
|
import { capitalise } from "helpers"
|
||||||
|
|
||||||
export let value
|
export let value
|
||||||
|
|
||||||
const getRoleLabel = roleId => {
|
const getRoleLabel = roleId => {
|
||||||
const role = $roles.find(x => x._id === roleId)
|
const role = $roles.find(x => x._id === roleId)
|
||||||
return role?.name || "Custom role"
|
return roleId === Constants.Roles.CREATOR
|
||||||
|
? capitalise(Constants.Roles.CREATOR.toLowerCase())
|
||||||
|
: role?.name || "Custom role"
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,11 @@
|
||||||
export let row
|
export let row
|
||||||
|
|
||||||
$: priviliged = sdk.users.isAdminOrBuilder(row)
|
$: priviliged = sdk.users.isAdminOrBuilder(row)
|
||||||
$: count = priviliged ? $apps.length : value?.length || 0
|
$: count = priviliged
|
||||||
|
? $apps.length
|
||||||
|
: sdk.users.hasAppBuilderPermissions(row)
|
||||||
|
? row?.builder?.apps?.length
|
||||||
|
: value?.length || 0
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="align">
|
<div class="align">
|
||||||
|
|
|
@ -9,6 +9,7 @@ const RolePriorities = {
|
||||||
}
|
}
|
||||||
const RoleColours = {
|
const RoleColours = {
|
||||||
[Roles.ADMIN]: "var(--spectrum-global-color-static-red-400)",
|
[Roles.ADMIN]: "var(--spectrum-global-color-static-red-400)",
|
||||||
|
[Roles.CREATOR]: "var(--spectrum-global-color-static-magenta-600)",
|
||||||
[Roles.POWER]: "var(--spectrum-global-color-static-orange-400)",
|
[Roles.POWER]: "var(--spectrum-global-color-static-orange-400)",
|
||||||
[Roles.BASIC]: "var(--spectrum-global-color-static-green-400)",
|
[Roles.BASIC]: "var(--spectrum-global-color-static-green-400)",
|
||||||
[Roles.PUBLIC]: "var(--spectrum-global-color-static-blue-400)",
|
[Roles.PUBLIC]: "var(--spectrum-global-color-static-blue-400)",
|
||||||
|
|
Loading…
Reference in New Issue