Fix role display for groups and update status light

This commit is contained in:
Andrew Kingston 2022-08-01 13:00:16 +01:00
parent 6e31e69528
commit 08849395f1
1 changed files with 12 additions and 4 deletions

View File

@ -18,6 +18,7 @@
import { users, apps, groups } from "stores/portal"
import { onMount } from "svelte"
import { RoleUtils } from "@budibase/frontend-core"
import { roles } from "../../../../../stores/backend"
export let groupId
let popoverAnchor
@ -104,10 +105,17 @@
}
}
const getRoleLabel = appId => {
const roleId = group?.roles?.[`app_${appId}`]
const role = $roles.find(x => x._id === roleId)
return role?.name || "Custom role"
}
onMount(async () => {
try {
await groups.actions.init()
await apps.load()
await roles.fetch()
} catch (error) {
notifications.error("Error fetching User Group data")
}
@ -184,11 +192,11 @@
>
<div class="title ">
<StatusLight
square
color={RoleUtils.getRoleColour(group.roles[app.appId])}
/>
<div style="margin-left: var(--spacing-s);">
<Body size="XS">{group.roles[app.appId]}</Body>
</div>
>
{getRoleLabel(app.appId)}
</StatusLight>
</div>
</ListItem>
{/each}