Merge branch 'feat/user-groups-tab' of github.com:Budibase/budibase into feat/user-groups-tab

This commit is contained in:
Peter Clement 2022-07-14 16:58:41 +01:00
commit 8034b85db3
5 changed files with 34 additions and 27 deletions

View File

@ -65,8 +65,7 @@
<MenuItem on:click={() => deleteGroup(group)} icon="Delete" <MenuItem on:click={() => deleteGroup(group)} icon="Delete"
>Delete</MenuItem >Delete</MenuItem
> >
<MenuItem on:click={() => editGroup(group)} icon="Delete">Edit</MenuItem <MenuItem on:click={() => editGroup(group)} icon="Edit">Edit</MenuItem>
>
</ActionMenu> </ActionMenu>
</div> </div>
</div> </div>

View File

@ -1,15 +1,37 @@
<script> <script>
import { Select } from "@budibase/bbui" import { notifications, Select } from "@budibase/bbui"
import { users } from "stores/portal"
import { Constants } from "@budibase/frontend-core"
const options = [ export let row
{ label: "App User", value: "appUser" }, $: value = users.getUserRole(row)
{ label: "Developer", value: "developer" },
{ label: "Admin", value: "admin" }, async function updateUserRole({ detail }) {
] if (detail === "developer") {
toggleFlags({ admin: { global: false }, builder: { global: true } })
} else if (detail === "admin") {
toggleFlags({ admin: { global: true }, builder: { global: false } })
} else if (detail === "appUser") {
toggleFlags({ admin: { global: false }, builder: { global: false } })
}
}
async function toggleFlags(roleFlags) {
try {
await users.save({ ...(await users.get(row._id)), ...roleFlags })
} catch (error) {
notifications.error("Error updating user")
}
}
</script> </script>
<div on:click|stopPropagation> <div on:click|stopPropagation>
<Select value={"appUser"} {options} placeholder="Admin" autoWidth quiet /> <Select
{value}
options={Constants.BbRoles}
autoWidth
quiet
on:change={updateUserRole}
/>
</div> </div>
<style> <style>

View File

@ -1,16 +0,0 @@
<script>
import { Icon, ActionMenu, MenuItem } from "@budibase/bbui"
</script>
<div
style=" overflow: hidden;
"
>
<ActionMenu align="right">
<span slot="control">
<Icon hoverable name="More" />
</span>
<MenuItem icon="Delete">Delete</MenuItem>
<MenuItem icon="Delete">Edit</MenuItem>
</ActionMenu>
</div>

View File

@ -21,7 +21,6 @@
import GroupsTableRenderer from "./_components/GroupsTableRenderer.svelte" import GroupsTableRenderer from "./_components/GroupsTableRenderer.svelte"
import AppsTableRenderer from "./_components/AppsTableRenderer.svelte" import AppsTableRenderer from "./_components/AppsTableRenderer.svelte"
import NameTableRenderer from "./_components/NameTableRenderer.svelte" import NameTableRenderer from "./_components/NameTableRenderer.svelte"
import SettingsTableRenderer from "./_components/SettingsTableRenderer.svelte"
import RoleTableRenderer from "./_components/RoleTableRenderer.svelte" import RoleTableRenderer from "./_components/RoleTableRenderer.svelte"
import { goto } from "@roxi/routify" import { goto } from "@roxi/routify"
import OnboardingTypeModal from "./_components/OnboardingTypeModal.svelte" import OnboardingTypeModal from "./_components/OnboardingTypeModal.svelte"
@ -62,7 +61,6 @@
{ column: "userGroups", component: GroupsTableRenderer }, { column: "userGroups", component: GroupsTableRenderer },
{ column: "apps", component: AppsTableRenderer }, { column: "apps", component: AppsTableRenderer },
{ column: "name", component: NameTableRenderer }, { column: "name", component: NameTableRenderer },
{ column: "settings", component: SettingsTableRenderer },
{ column: "role", component: RoleTableRenderer }, { column: "role", component: RoleTableRenderer },
] ]

View File

@ -86,10 +86,14 @@ export function createUsersStore() {
return await API.saveUser(user) return await API.saveUser(user)
} }
const getUserRole = ({ admin, builder }) =>
admin?.global ? "admin" : builder?.global ? "developer" : "appUser"
return { return {
subscribe, subscribe,
search, search,
get, get,
getUserRole,
fetch, fetch,
invite, invite,
acceptInvite, acceptInvite,