From b72b93e5b28cc3fcf28220dc2bff0dd2ee6c77ce Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 23 Nov 2023 14:03:23 +0000 Subject: [PATCH] Update user invitation modal and details page to allow creating creator users --- .../portal/users/users/[userId].svelte | 23 +++++++++++++++---- .../users/_components/AddUserModal.svelte | 2 +- .../builder/portal/users/users/index.svelte | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) 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 ec10ec8316..07ed1b26f4 100644 --- a/packages/builder/src/pages/builder/portal/users/users/[userId].svelte +++ b/packages/builder/src/pages/builder/portal/users/users/[userId].svelte @@ -98,7 +98,17 @@ return y._id === userId }) }) - $: globalRole = sdk.users.isAdmin(user) ? "admin" : "appUser" + $: globalRole = getGlobalRole(user) + + const getGlobalRole = user => { + if (sdk.users.isAdmin(user)) { + return Constants.BudibaseRoles.Admin + } else if (sdk.users.isCreator(user)) { + return Constants.BudibaseRoles.Creator + } else { + return Constants.BudibaseRoles.AppUser + } + } const getAvailableApps = (appList, privileged, roles) => { let availableApps = appList.slice() @@ -177,12 +187,17 @@ } async function updateUserRole({ detail }) { - if (detail === "developer") { + if (detail === Constants.BudibaseRoles.Developer) { toggleFlags({ admin: { global: false }, builder: { global: true } }) - } else if (detail === "admin") { + } else if (detail === Constants.BudibaseRoles.Admin) { toggleFlags({ admin: { global: true }, builder: { global: true } }) - } else if (detail === "appUser") { + } else if (detail === Constants.BudibaseRoles.AppUser) { toggleFlags({ admin: { global: false }, builder: { global: false } }) + } else if (detail === Constants.BudibaseRoles.Creator) { + toggleFlags({ + admin: { global: false }, + builder: { global: false, creator: true }, + }) } } diff --git a/packages/builder/src/pages/builder/portal/users/users/_components/AddUserModal.svelte b/packages/builder/src/pages/builder/portal/users/users/_components/AddUserModal.svelte index 806468021f..0730c31674 100644 --- a/packages/builder/src/pages/builder/portal/users/users/_components/AddUserModal.svelte +++ b/packages/builder/src/pages/builder/portal/users/users/_components/AddUserModal.svelte @@ -98,7 +98,7 @@ align-items: center; flex-direction: row;" > -
+
({ email: user.email, builder: user.role === Constants.BudibaseRoles.Developer, + creator: user.role === Constants.BudibaseRoles.Creator, admin: user.role === Constants.BudibaseRoles.Admin, groups: userData.groups, }))