Adding ability to create new admins.

This commit is contained in:
mike12345567 2021-05-21 16:30:37 +01:00
parent b119ae19c6
commit 27fc3a3c5e
1 changed files with 32 additions and 12 deletions

View File

@ -17,7 +17,7 @@
notifications,
} from "@budibase/bbui"
import { fetchData } from "helpers"
import { users } from "stores/portal"
import { users, auth } from "stores/portal"
import TagsRenderer from "./_components/TagsTableRenderer.svelte"
import UpdateRolesModal from "./_components/UpdateRolesModal.svelte"
@ -56,13 +56,21 @@
let toggleDisabled = false
async function toggleBuilderAccess({ detail }) {
async function toggleFlag(flagName, detail) {
toggleDisabled = true
await users.save({ ...$userFetch?.data, builder: { global: detail } })
await users.save({ ...$userFetch?.data, [flagName]: { global: detail } })
await userFetch.refresh()
toggleDisabled = false
}
async function toggleBuilderAccess({ detail }) {
return toggleFlag("builder", detail)
}
async function toggleAdminAccess({ detail }) {
return toggleFlag("admin", detail)
}
async function openUpdateRolesModal({ detail }) {
selectedApp = detail
editRolesModal.show()
@ -107,6 +115,8 @@
<Label size="L">Last name</Label>
<Input disabled thin value={$userFetch?.data?.lastName} />
</div>
<!-- don't let a user remove the privileges that let them be here -->
{#if userId !== $auth.user._id}
<div class="field">
<Label size="L">Development access?</Label>
<Toggle
@ -116,6 +126,16 @@
disabled={toggleDisabled}
/>
</div>
<div class="field">
<Label size="L">Administration access?</Label>
<Toggle
text=""
value={$userFetch?.data?.admin?.global}
on:change={toggleAdminAccess}
disabled={toggleDisabled}
/>
</div>
{/if}
</div>
<div class="regenerate">
<ActionButton