diff --git a/packages/builder/src/components/common/RoleSelect.svelte b/packages/builder/src/components/common/RoleSelect.svelte
index 82752554d5..2df61926e1 100644
--- a/packages/builder/src/components/common/RoleSelect.svelte
+++ b/packages/builder/src/components/common/RoleSelect.svelte
@@ -39,7 +39,15 @@
allowCreator
) => {
if (allowedRoles?.length) {
- return roles.filter(role => allowedRoles.includes(role._id))
+ const filteredRoles = roles.filter(role =>
+ allowedRoles.includes(role._id)
+ )
+ return [
+ ...filteredRoles,
+ ...(allowedRoles.includes(Constants.Roles.CREATOR)
+ ? [{ _id: Constants.Roles.CREATOR, name: "Creator", enabled: false }]
+ : []),
+ ]
}
let newRoles = [...roles]
@@ -129,8 +137,9 @@
getOptionColour={getColor}
getOptionIcon={getIcon}
isOptionEnabled={option =>
- option._id !== Constants.Roles.CREATOR ||
- $licensing.perAppBuildersEnabled}
+ (option._id !== Constants.Roles.CREATOR ||
+ $licensing.perAppBuildersEnabled) &&
+ option.enabled !== false}
{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 a7d9584330..f9a40b09a6 100644
--- a/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte
+++ b/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte
@@ -516,6 +516,13 @@
}
return null
}
+
+ const parseRole = user => {
+ if (user.isAdminOrGlobalBuilder) {
+ return Constants.Roles.CREATOR
+ }
+ return user.role
+ }
@@ -725,7 +732,7 @@
diff --git a/packages/pro b/packages/pro
index d24c0dc3a3..5ed0ee2aca 160000
--- a/packages/pro
+++ b/packages/pro
@@ -1 +1 @@
-Subproject commit d24c0dc3a30014cbe61860252aa48104cad36376
+Subproject commit 5ed0ee2aca9d754d80cd46bae412b24621afa47e
diff --git a/packages/worker/src/api/routes/global/tests/groups.spec.ts b/packages/worker/src/api/routes/global/tests/groups.spec.ts
index afeaae952c..8f0739a812 100644
--- a/packages/worker/src/api/routes/global/tests/groups.spec.ts
+++ b/packages/worker/src/api/routes/global/tests/groups.spec.ts
@@ -1,7 +1,7 @@
import { events } from "@budibase/backend-core"
import { generator } from "@budibase/backend-core/tests"
import { structures, TestConfiguration, mocks } from "../../../../tests"
-import { UserGroup } from "@budibase/types"
+import { User, UserGroup } from "@budibase/types"
mocks.licenses.useGroups()
@@ -231,4 +231,39 @@ describe("/api/global/groups", () => {
})
})
})
+
+ describe("with global builder role", () => {
+ let builder: User
+ let group: UserGroup
+
+ beforeAll(async () => {
+ builder = await config.createUser({
+ builder: { global: true },
+ admin: { global: false },
+ })
+ await config.createSession(builder)
+
+ let resp = await config.api.groups.saveGroup(
+ structures.groups.UserGroup()
+ )
+ group = resp.body as UserGroup
+ })
+
+ it("find should return 200", async () => {
+ await config.withUser(builder, async () => {
+ await config.api.groups.searchUsers(group._id!, {
+ emailSearch: `user1`,
+ })
+ })
+ })
+
+ it("update should return 200", async () => {
+ await config.withUser(builder, async () => {
+ await config.api.groups.updateGroupUsers(group._id!, {
+ add: [builder._id!],
+ remove: [],
+ })
+ })
+ })
+ })
})
diff --git a/packages/worker/src/tests/TestConfiguration.ts b/packages/worker/src/tests/TestConfiguration.ts
index 7e9792c9e3..d4fcbeebd6 100644
--- a/packages/worker/src/tests/TestConfiguration.ts
+++ b/packages/worker/src/tests/TestConfiguration.ts
@@ -190,6 +190,16 @@ class TestConfiguration {
}
}
+ async withUser(user: User, f: () => Promise) {
+ const oldUser = this.user
+ this.user = user
+ try {
+ await f()
+ } finally {
+ this.user = oldUser
+ }
+ }
+
authHeaders(user: User) {
const authToken: AuthToken = {
userId: user._id!,
@@ -257,9 +267,10 @@ class TestConfiguration {
})
}
- async createUser(user?: User) {
- if (!user) {
- user = structures.users.user()
+ async createUser(opts?: Partial) {
+ let user = structures.users.user()
+ if (user) {
+ user = { ...user, ...opts }
}
const response = await this._req(user, null, controllers.users.save)
const body = response as SaveUserResponse
diff --git a/packages/worker/src/tests/structures/groups.ts b/packages/worker/src/tests/structures/groups.ts
index b0d6bb8fc0..d39dd74eb8 100644
--- a/packages/worker/src/tests/structures/groups.ts
+++ b/packages/worker/src/tests/structures/groups.ts
@@ -1,8 +1,8 @@
import { generator } from "@budibase/backend-core/tests"
import { db } from "@budibase/backend-core"
-import { UserGroupRoles } from "@budibase/types"
+import { UserGroup as UserGroupType, UserGroupRoles } from "@budibase/types"
-export const UserGroup = () => {
+export function UserGroup(): UserGroupType {
const appsCount = generator.integer({ min: 0, max: 3 })
const roles = Array.from({ length: appsCount }).reduce(
(p: UserGroupRoles, v) => {
@@ -14,13 +14,11 @@ export const UserGroup = () => {
{}
)
- let group = {
- apps: [],
+ return {
color: generator.color(),
icon: generator.word(),
name: generator.word(),
roles: roles,
users: [],
}
- return group
}