From bd488463cb48edda7e126e76be9fab6f3f1db15c Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 9 Dec 2020 18:18:47 +0000 Subject: [PATCH] Add role selection for viewing screens and smart handling of preview screen --- packages/builder/src/builderStore/index.js | 4 +- .../src/builderStore/store/frontend.js | 1 + .../ComponentNavigationTree/PathTree.svelte | 2 + .../ComponentNavigationTree/index.svelte | 65 +++++++++++++++++-- .../userInterface/FrontendNavigatePane.svelte | 30 +++++++-- .../components/userInterface/Layout.svelte | 3 +- .../userInterface/NewScreenModal.svelte | 2 +- 7 files changed, 96 insertions(+), 11 deletions(-) diff --git a/packages/builder/src/builderStore/index.js b/packages/builder/src/builderStore/index.js index 887ef733e4..f1914efab2 100644 --- a/packages/builder/src/builderStore/index.js +++ b/packages/builder/src/builderStore/index.js @@ -2,7 +2,7 @@ import { getFrontendStore } from "./store/frontend" import { getBackendUiStore } from "./store/backend" import { getAutomationStore } from "./store/automation/" import { getThemeStore } from "./store/theme" -import { derived } from "svelte/store" +import { derived, writable } from "svelte/store" import analytics from "analytics" import { LAYOUT_NAMES } from "../constants" import { makePropsSafe } from "components/userInterface/assetParsing/createProps" @@ -74,6 +74,8 @@ export const mainLayout = derived(store, $store => { ) }) +export const selectedAccessRole = writable("BASIC") + export const initialise = async () => { try { await analytics.activate() diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index a853a98dce..754cd6e127 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -110,6 +110,7 @@ export const getFrontendStore = () => { const creatingNewScreen = screen._id === undefined const response = await api.post(`/api/screens`, screen) screen = await response.json() + await store.actions.routing.fetch() store.update(state => { const foundScreen = state.screens.findIndex( diff --git a/packages/builder/src/components/userInterface/ComponentNavigationTree/PathTree.svelte b/packages/builder/src/components/userInterface/ComponentNavigationTree/PathTree.svelte index 765041b184..5dd4ed9a7c 100644 --- a/packages/builder/src/components/userInterface/ComponentNavigationTree/PathTree.svelte +++ b/packages/builder/src/components/userInterface/ComponentNavigationTree/PathTree.svelte @@ -20,6 +20,7 @@ export let route export let path export let indent + export let border $: selectedScreen = $currentAsset @@ -34,6 +35,7 @@ icon="ri-folder-line" text={path} opened={true} + {border} withArrow={route.subpaths} /> {#each Object.entries(route.subpaths) as [url, subpath]} diff --git a/packages/builder/src/components/userInterface/ComponentNavigationTree/index.svelte b/packages/builder/src/components/userInterface/ComponentNavigationTree/index.svelte index 9528b2844c..a88c6feb34 100644 --- a/packages/builder/src/components/userInterface/ComponentNavigationTree/index.svelte +++ b/packages/builder/src/components/userInterface/ComponentNavigationTree/index.svelte @@ -1,12 +1,69 @@
- {#each paths as path} - + {#each paths as path, idx} + 0} {path} route={routes[path]} /> {/each} + + {#if !paths.length} +
+ There aren't any screens configured with this access role. +
+ {/if}
+ + diff --git a/packages/builder/src/components/userInterface/FrontendNavigatePane.svelte b/packages/builder/src/components/userInterface/FrontendNavigatePane.svelte index 23d2e6cf1a..25f939d2f1 100644 --- a/packages/builder/src/components/userInterface/FrontendNavigatePane.svelte +++ b/packages/builder/src/components/userInterface/FrontendNavigatePane.svelte @@ -1,13 +1,18 @@