diff --git a/packages/builder/src/components/common/RoleSelect.svelte b/packages/builder/src/components/common/RoleSelect.svelte index 3d84ef2e22..82752554d5 100644 --- a/packages/builder/src/components/common/RoleSelect.svelte +++ b/packages/builder/src/components/common/RoleSelect.svelte @@ -23,7 +23,6 @@ const dispatch = createEventDispatcher() const RemoveID = "remove" - const CreatorID = "CREATOR" $: options = getOptions( $roles, @@ -47,7 +46,7 @@ if (allowCreator) { newRoles = [ { - _id: CreatorID, + _id: Constants.Roles.CREATOR, name: "Creator", tag: !$licensing.perAppBuildersEnabled && @@ -88,8 +87,6 @@ const onChange = e => { if (allowRemove && e.detail === RemoveID) { dispatch("remove") - } else if (e.detail === CreatorID) { - dispatch("addcreator") } else { dispatch("change", e.detail) } @@ -112,7 +109,8 @@ getOptionColour={getColor} getOptionIcon={getIcon} isOptionEnabled={option => - option._id !== CreatorID || $licensing.perAppBuildersEnabled} + option._id !== Constants.Roles.CREATOR || + $licensing.perAppBuildersEnabled} {placeholder} {error} /> @@ -131,7 +129,8 @@ getOptionColour={getColor} getOptionIcon={getIcon} isOptionEnabled={option => - option._id !== CreatorID || $licensing.perAppBuildersEnabled} + option._id !== Constants.Roles.CREATOR || + $licensing.perAppBuildersEnabled} {placeholder} {error} /> diff --git a/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte b/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte index b304140a8d..3e6741e920 100644 --- a/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte @@ -81,17 +81,15 @@ filteredInvites.sort(sortInviteRoles) return } - filteredInvites = appInvites - .filter(invite => { - const inviteInfo = invite.info?.apps - if (!query && inviteInfo && prodAppId) { - return Object.keys(inviteInfo).includes(prodAppId) - } - return invite.email.includes(query) - }) - .sort(sortInviteRoles) + filteredInvites = appInvites.filter(invite => { + const inviteInfo = invite.info?.apps + if (!query && inviteInfo && prodAppId) { + return Object.keys(inviteInfo).includes(prodAppId) + } + return invite.email.includes(query) + }) + filteredInvites.sort(sortInviteRoles) } - $: filterByAppAccess, prodAppId, filterInvites(query) $: if (searchFocus === true) { filterByAppAccess = false @@ -122,21 +120,22 @@ await usersFetch.refresh() filteredUsers = $usersFetch.rows + .filter(user => !user?.admin?.global) // filter out global admins .map(user => { const isAdminOrGlobalBuilder = sdk.users.isAdminOrGlobalBuilder( user, prodAppId ) const isAppBuilder = sdk.users.hasAppBuilderPermissions(user, prodAppId) - let role = undefined + let role if (isAdminOrGlobalBuilder) { role = Constants.Roles.ADMIN } else if (isAppBuilder) { role = Constants.Roles.CREATOR } else { - const appRole = Object.keys(user.roles).find(x => x === prodAppId) + const appRole = user.roles[prodAppId] if (appRole) { - role = user.roles[appRole] + role = appRole } } @@ -617,9 +616,6 @@ allowPublic={false} allowCreator={true} quiet={true} - on:addcreator={() => { - onUpdateUserInvite(invite, Constants.Roles.CREATOR) - }} on:change={e => { onUpdateUserInvite(invite, e.detail) }} @@ -673,10 +669,11 @@ quiet={true} allowCreator={true} on:change={e => { - onUpdateGroup(group, e.detail) - }} - on:addcreator={() => { - addGroupAppBuilder(group._id) + if (e.detail === Constants.Roles.CREATOR) { + addGroupAppBuilder(group._id) + } else { + onUpdateGroup(group, e.detail) + } }} on:remove={() => { onUpdateGroup(group) @@ -712,11 +709,13 @@ allowPublic={false} allowCreator={true} quiet={true} - on:addcreator={() => { - addAppBuilder(user._id) - }} + on:addcreator={() => {}} on:change={e => { - onUpdateUser(user, e.detail) + if (e.detail === Constants.Roles.CREATOR) { + addAppBuilder(user._id) + } else { + onUpdateUser(user, e.detail) + } }} on:remove={() => { onUpdateUser(user) diff --git a/packages/builder/src/pages/builder/portal/users/groups/[groupId].svelte b/packages/builder/src/pages/builder/portal/users/groups/[groupId].svelte index 6a4364c414..793ba5c09f 100644 --- a/packages/builder/src/pages/builder/portal/users/groups/[groupId].svelte +++ b/packages/builder/src/pages/builder/portal/users/groups/[groupId].svelte @@ -21,6 +21,7 @@ import GroupIcon from "./_components/GroupIcon.svelte" import GroupUsers from "./_components/GroupUsers.svelte" import { sdk } from "@budibase/shared-core" + import { Constants } from "@budibase/frontend-core" export let groupId @@ -45,7 +46,7 @@ let loaded = false let editModal, deleteModal - + $: console.log(group) $: scimEnabled = $features.isScimEnabled $: readonly = !sdk.users.isAdmin($auth.user) || scimEnabled $: group = $groups.find(x => x._id === groupId) @@ -57,8 +58,11 @@ ) .map(app => ({ ...app, - role: group?.roles?.[apps.getProdAppID(app.devId)], + role: group?.builder?.apps.includes(apps.getProdAppID(app.devId)) + ? Constants.Roles.CREATOR + : group?.roles?.[apps.getProdAppID(app.devId)], })) + $: console.log(groupApps) $: { if (loaded && !group?._id) { $goto("./") diff --git a/packages/builder/src/pages/builder/portal/users/groups/_components/GroupAppsTableRenderer.svelte b/packages/builder/src/pages/builder/portal/users/groups/_components/GroupAppsTableRenderer.svelte index 51f4d7f77c..48b1bfbce6 100644 --- a/packages/builder/src/pages/builder/portal/users/groups/_components/GroupAppsTableRenderer.svelte +++ b/packages/builder/src/pages/builder/portal/users/groups/_components/GroupAppsTableRenderer.svelte @@ -1,9 +1,19 @@