1
0
Fork 0
mirror of synced 2024-07-02 04:50:44 +12:00

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 ac3edb2f60
commit 9cdd519a8a

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>