diff --git a/packages/builder/src/helpers/helpers.js b/packages/builder/src/helpers/helpers.js index bf5cdc003b..99483d40e2 100644 --- a/packages/builder/src/helpers/helpers.js +++ b/packages/builder/src/helpers/helpers.js @@ -26,6 +26,9 @@ export const capitalise = s => { 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_capitalised_name = name => pipe(name, [get_name, capitalise]) diff --git a/packages/builder/src/pages/builder/portal/users/users/[userId].svelte b/packages/builder/src/pages/builder/portal/users/users/[userId].svelte index 904dd7d430..5ae6d7cb9d 100644 --- a/packages/builder/src/pages/builder/portal/users/users/[userId].svelte +++ b/packages/builder/src/pages/builder/portal/users/users/[userId].svelte @@ -89,7 +89,7 @@ $: scimEnabled = $features.isScimEnabled $: isSSO = !!user?.provider $: readonly = !sdk.users.isAdmin($auth.user) || scimEnabled - $: privileged = sdk.users.isAdminOrBuilder(user) + $: privileged = sdk.users.isAdminOrGlobalBuilder(user) $: nameLabel = getNameLabel(user) $: filteredGroups = getFilteredGroups($groups, searchTerm) $: availableApps = getAvailableApps($apps, privileged, user?.roles) @@ -108,7 +108,8 @@ let availableApps = appList.slice() if (!privileged) { 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) }) }) @@ -119,7 +120,11 @@ name: app.name, devId: app.devId, 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], } }) } diff --git a/packages/builder/src/pages/builder/portal/users/users/_components/AppRoleTableRenderer.svelte b/packages/builder/src/pages/builder/portal/users/users/_components/AppRoleTableRenderer.svelte index 5664a95045..e6821cba37 100644 --- a/packages/builder/src/pages/builder/portal/users/users/_components/AppRoleTableRenderer.svelte +++ b/packages/builder/src/pages/builder/portal/users/users/_components/AppRoleTableRenderer.svelte @@ -2,12 +2,16 @@ import { StatusLight } from "@budibase/bbui" import { RoleUtils } from "@budibase/frontend-core" import { roles } from "stores/backend" + import { Constants } from "@budibase/frontend-core" + import { capitalise } from "helpers" export let value const getRoleLabel = 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" } diff --git a/packages/builder/src/pages/builder/portal/users/users/_components/AppsTableRenderer.svelte b/packages/builder/src/pages/builder/portal/users/users/_components/AppsTableRenderer.svelte index 55cad9b93b..b454d2668c 100644 --- a/packages/builder/src/pages/builder/portal/users/users/_components/AppsTableRenderer.svelte +++ b/packages/builder/src/pages/builder/portal/users/users/_components/AppsTableRenderer.svelte @@ -7,7 +7,11 @@ export let 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
diff --git a/packages/frontend-core/src/utils/roles.js b/packages/frontend-core/src/utils/roles.js index 9190d41c12..1ae9d3ac14 100644 --- a/packages/frontend-core/src/utils/roles.js +++ b/packages/frontend-core/src/utils/roles.js @@ -9,6 +9,7 @@ const RolePriorities = { } const RoleColours = { [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.BASIC]: "var(--spectrum-global-color-static-green-400)", [Roles.PUBLIC]: "var(--spectrum-global-color-static-blue-400)",