Fix route choice when using devtools role preview and fix devtools role ID not being passed down in context
This commit is contained in:
parent
908c0a3efc
commit
b7af3e75fa
|
@ -58,8 +58,22 @@
|
||||||
if ($authStore) {
|
if ($authStore) {
|
||||||
// There is a logged in user, so handle them
|
// There is a logged in user, so handle them
|
||||||
if ($screenStore.screens.length) {
|
if ($screenStore.screens.length) {
|
||||||
|
let firstRoute
|
||||||
|
|
||||||
|
// If using devtools, find the first screen matching our role
|
||||||
|
if ($devToolsStore.role) {
|
||||||
|
firstRoute =
|
||||||
|
$screenStore.screens.filter(
|
||||||
|
screen => screen.routing?.roleId === $devToolsStore.role
|
||||||
|
)[0]?.routing?.route || "/"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise just use the fist route
|
||||||
|
else {
|
||||||
|
firstRoute = $screenStore.screens[0]?.routing?.route ?? "/"
|
||||||
|
}
|
||||||
|
|
||||||
// Screens exist so navigate back to the home screen
|
// Screens exist so navigate back to the home screen
|
||||||
const firstRoute = $screenStore.screens[0].routing?.route ?? "/"
|
|
||||||
routeStore.actions.navigate(firstRoute)
|
routeStore.actions.navigate(firstRoute)
|
||||||
} else {
|
} else {
|
||||||
// No screens likely means the user has no permissions to view this app
|
// No screens likely means the user has no permissions to view this app
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import Provider from "./Provider.svelte"
|
import Provider from "./Provider.svelte"
|
||||||
import { authStore } from "stores"
|
import { authStore, devToolsStore } from "stores"
|
||||||
import { ActionTypes } from "constants"
|
import { ActionTypes } from "constants"
|
||||||
import { Constants } from "@budibase/frontend-core"
|
import { Constants } from "@budibase/frontend-core"
|
||||||
|
|
||||||
|
@ -17,6 +17,10 @@
|
||||||
]
|
]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Provider key="user" data={$authStore} {actions}>
|
<Provider
|
||||||
|
key="user"
|
||||||
|
data={{ ...$authStore, roleId: $devToolsStore.role || $authStore?.roleId }}
|
||||||
|
{actions}
|
||||||
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</Provider>
|
</Provider>
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.devtools {
|
.devtools {
|
||||||
background: var(--spectrum-alias-background-color-secondary);
|
background: var(--spectrum-alias-background-color-primary);
|
||||||
flex: 0 0 320px;
|
flex: 0 0 320px;
|
||||||
border-left: 1px solid var(--spectrum-global-color-gray-300);
|
border-left: 1px solid var(--spectrum-global-color-gray-300);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
value={$componentStore.selectedComponentDefinition?.name}
|
value={$componentStore.selectedComponentDefinition?.name}
|
||||||
/>
|
/>
|
||||||
<DevToolsStat
|
<DevToolsStat
|
||||||
|
copyable
|
||||||
label="Component ID"
|
label="Component ID"
|
||||||
value={$componentStore.selectedComponent?._id}
|
value={$componentStore.selectedComponent?._id}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue