1
0
Fork 0
mirror of synced 2024-06-18 18:35:37 +12:00

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-15 11:30:11 +01:00
commit 25a395972c

View file

@ -1,37 +1,15 @@
<script>
import { notifications, Select } from "@budibase/bbui"
import { users } from "stores/portal"
import { Constants } from "@budibase/frontend-core"
export let row
$: value = users.getUserRole(row)
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")
}
}
$: value =
Constants.BbRoles.find(x => x.value === users.getUserRole(row))?.label ||
"Not Available"
</script>
<div on:click|stopPropagation>
<Select
{value}
options={Constants.BbRoles}
autoWidth
quiet
on:change={updateUserRole}
/>
{value}
</div>
<style>