From 3ae5ce980207824dfda5c23ae71244cdc2f5ee88 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 22 Oct 2024 15:16:07 +0100 Subject: [PATCH] Use role display names for picking preview roles --- .../components/devtools/DevToolsHeader.svelte | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/client/src/components/devtools/DevToolsHeader.svelte b/packages/client/src/components/devtools/DevToolsHeader.svelte index 55b705e717..f283defc7c 100644 --- a/packages/client/src/components/devtools/DevToolsHeader.svelte +++ b/packages/client/src/components/devtools/DevToolsHeader.svelte @@ -2,27 +2,28 @@ import { Heading, Select, ActionButton } from "@budibase/bbui" import { devToolsStore, appStore, roleStore } from "../../stores" import { getContext, onMount } from "svelte" + import { API } from "api" const context = getContext("context") const SELF_ROLE = "self" - let staticRoleList + let roles - $: previewOptions = buildRoleList(staticRoleList) + $: previewOptions = buildRoleList(roles) - function buildRoleList(roleIds) { + function buildRoleList(roles) { const list = [] list.push({ label: "View as yourself", value: SELF_ROLE, }) - if (!roleIds) { + if (!roles) { return list } - for (let roleId of roleIds) { + for (let role of roles) { list.push({ - label: `View as ${roleId.toLowerCase()} user`, - value: roleId, + label: `View as ${role.uiMetadata?.displayName || role.name}`, + value: role._id, }) } return list @@ -31,12 +32,12 @@ onMount(async () => { // make sure correct before starting await devToolsStore.actions.changeRole(SELF_ROLE) - staticRoleList = await roleStore.actions.fetchAccessibleRoles() + roles = await API.getRoles() })
- Preview + Previ werewr eww