Fix initial role not being set when updating user role

This commit is contained in:
Andrew Kingston 2021-05-18 19:08:23 +01:00
parent 478ec4c090
commit e136cee959
1 changed files with 8 additions and 9 deletions

View File

@ -1,7 +1,6 @@
<script>
import { createEventDispatcher } from "svelte"
import { Body, Select, ModalContent, notifications } from "@budibase/bbui"
import { fetchData } from "helpers"
import { users } from "stores/portal"
export let app
@ -11,7 +10,7 @@
const roles = app.roles
let options = roles.map(role => role._id)
let selectedRole
let selectedRole = user?.roles?.[app?._id]
async function updateUserRoles() {
const res = await users.updateRoles({
@ -24,7 +23,7 @@
if (res.status === 400) {
notifications.error("Failed to update role")
} else {
notifications.success("Roles updated")
notifications.success("Role updated")
dispatch("update")
}
}
@ -32,20 +31,20 @@
<ModalContent
onConfirm={updateUserRoles}
title="Update App Roles"
confirmText="Update roles"
title="Update App Role"
confirmText="Update role"
cancelText="Cancel"
size="M"
showCloseIcon={false}
>
<Body noPadding
>Update {user.email}'s roles for <strong>{app.name}</strong>.</Body
>
<Body noPadding>
Update {user.email}'s role for <strong>{app.name}</strong>.
</Body>
<Select
placeholder={null}
bind:value={selectedRole}
on:change
{options}
label="Select roles:"
label="Role"
/>
</ModalContent>