Merge remote-tracking branch 'origin/master' into feature/form-block-settings-reflow
This commit is contained in:
commit
09c3ad50c9
|
@ -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}
|
||||
/>
|
||||
|
|
|
@ -516,6 +516,13 @@
|
|||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const parseRole = user => {
|
||||
if (user.isAdminOrGlobalBuilder) {
|
||||
return Constants.Roles.CREATOR
|
||||
}
|
||||
return user.role
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window on:keydown={handleKeyDown} />
|
||||
|
@ -725,7 +732,7 @@
|
|||
<RoleSelect
|
||||
footer={getRoleFooter(user)}
|
||||
placeholder={false}
|
||||
value={user.role}
|
||||
value={parseRole(user)}
|
||||
allowRemove={user.role && !user.group}
|
||||
allowPublic={false}
|
||||
allowCreator={true}
|
||||
|
@ -744,7 +751,7 @@
|
|||
autoWidth
|
||||
align="right"
|
||||
allowedRoles={user.isAdminOrGlobalBuilder
|
||||
? [Constants.Roles.ADMIN]
|
||||
? [Constants.Roles.CREATOR]
|
||||
: null}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit d24c0dc3a30014cbe61860252aa48104cad36376
|
||||
Subproject commit 5ed0ee2aca9d754d80cd46bae412b24621afa47e
|
|
@ -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: [],
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -190,6 +190,16 @@ class TestConfiguration {
|
|||
}
|
||||
}
|
||||
|
||||
async withUser(user: User, f: () => Promise<void>) {
|
||||
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<User>) {
|
||||
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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue