Merge remote-tracking branch 'origin/master' into feature/form-block-settings-reflow
This commit is contained in:
commit
09c3ad50c9
|
@ -39,7 +39,15 @@
|
||||||
allowCreator
|
allowCreator
|
||||||
) => {
|
) => {
|
||||||
if (allowedRoles?.length) {
|
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]
|
let newRoles = [...roles]
|
||||||
|
|
||||||
|
@ -129,8 +137,9 @@
|
||||||
getOptionColour={getColor}
|
getOptionColour={getColor}
|
||||||
getOptionIcon={getIcon}
|
getOptionIcon={getIcon}
|
||||||
isOptionEnabled={option =>
|
isOptionEnabled={option =>
|
||||||
option._id !== Constants.Roles.CREATOR ||
|
(option._id !== Constants.Roles.CREATOR ||
|
||||||
$licensing.perAppBuildersEnabled}
|
$licensing.perAppBuildersEnabled) &&
|
||||||
|
option.enabled !== false}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
{error}
|
{error}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -516,6 +516,13 @@
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const parseRole = user => {
|
||||||
|
if (user.isAdminOrGlobalBuilder) {
|
||||||
|
return Constants.Roles.CREATOR
|
||||||
|
}
|
||||||
|
return user.role
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:keydown={handleKeyDown} />
|
<svelte:window on:keydown={handleKeyDown} />
|
||||||
|
@ -725,7 +732,7 @@
|
||||||
<RoleSelect
|
<RoleSelect
|
||||||
footer={getRoleFooter(user)}
|
footer={getRoleFooter(user)}
|
||||||
placeholder={false}
|
placeholder={false}
|
||||||
value={user.role}
|
value={parseRole(user)}
|
||||||
allowRemove={user.role && !user.group}
|
allowRemove={user.role && !user.group}
|
||||||
allowPublic={false}
|
allowPublic={false}
|
||||||
allowCreator={true}
|
allowCreator={true}
|
||||||
|
@ -744,7 +751,7 @@
|
||||||
autoWidth
|
autoWidth
|
||||||
align="right"
|
align="right"
|
||||||
allowedRoles={user.isAdminOrGlobalBuilder
|
allowedRoles={user.isAdminOrGlobalBuilder
|
||||||
? [Constants.Roles.ADMIN]
|
? [Constants.Roles.CREATOR]
|
||||||
: null}
|
: null}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d24c0dc3a30014cbe61860252aa48104cad36376
|
Subproject commit 5ed0ee2aca9d754d80cd46bae412b24621afa47e
|
|
@ -1,7 +1,7 @@
|
||||||
import { events } from "@budibase/backend-core"
|
import { events } from "@budibase/backend-core"
|
||||||
import { generator } from "@budibase/backend-core/tests"
|
import { generator } from "@budibase/backend-core/tests"
|
||||||
import { structures, TestConfiguration, mocks } from "../../../../tests"
|
import { structures, TestConfiguration, mocks } from "../../../../tests"
|
||||||
import { UserGroup } from "@budibase/types"
|
import { User, UserGroup } from "@budibase/types"
|
||||||
|
|
||||||
mocks.licenses.useGroups()
|
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) {
|
authHeaders(user: User) {
|
||||||
const authToken: AuthToken = {
|
const authToken: AuthToken = {
|
||||||
userId: user._id!,
|
userId: user._id!,
|
||||||
|
@ -257,9 +267,10 @@ class TestConfiguration {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async createUser(user?: User) {
|
async createUser(opts?: Partial<User>) {
|
||||||
if (!user) {
|
let user = structures.users.user()
|
||||||
user = structures.users.user()
|
if (user) {
|
||||||
|
user = { ...user, ...opts }
|
||||||
}
|
}
|
||||||
const response = await this._req(user, null, controllers.users.save)
|
const response = await this._req(user, null, controllers.users.save)
|
||||||
const body = response as SaveUserResponse
|
const body = response as SaveUserResponse
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { generator } from "@budibase/backend-core/tests"
|
import { generator } from "@budibase/backend-core/tests"
|
||||||
import { db } from "@budibase/backend-core"
|
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 appsCount = generator.integer({ min: 0, max: 3 })
|
||||||
const roles = Array.from({ length: appsCount }).reduce(
|
const roles = Array.from({ length: appsCount }).reduce(
|
||||||
(p: UserGroupRoles, v) => {
|
(p: UserGroupRoles, v) => {
|
||||||
|
@ -14,13 +14,11 @@ export const UserGroup = () => {
|
||||||
{}
|
{}
|
||||||
)
|
)
|
||||||
|
|
||||||
let group = {
|
return {
|
||||||
apps: [],
|
|
||||||
color: generator.color(),
|
color: generator.color(),
|
||||||
icon: generator.word(),
|
icon: generator.word(),
|
||||||
name: generator.word(),
|
name: generator.word(),
|
||||||
roles: roles,
|
roles: roles,
|
||||||
users: [],
|
users: [],
|
||||||
}
|
}
|
||||||
return group
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue