diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 9d9e2f83e6..778c7f7be5 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -36,6 +36,7 @@ const INITIAL_FRONTEND_STATE = { hasAppPackage: false, libraries: null, appId: "", + routes: {}, } export const getFrontendStore = () => { @@ -120,6 +121,17 @@ export const getFrontendStore = () => { return state }) }, + routing: { + fetch: async () => { + const response = await api.get("/api/routing") + const json = await response.json() + + store.update(state => { + state.routes = json.routes + return state + }) + }, + }, screens: { select: screenId => { store.update(state => { diff --git a/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte b/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte index bd7341be93..3ecd8ce0dc 100644 --- a/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte +++ b/packages/builder/src/components/userInterface/ComponentNavigationTree/ScreenDropdownMenu.svelte @@ -15,9 +15,10 @@ const deleteScreen = () => { const screenToDelete = $allScreens.find(scr => scr._id === screen) store.actions.screens.delete(screenToDelete) + store.actions.routing.fetch() // update the page if required store.update(state => { - if (state.currentPreviewItem._id === screen._id) { + if (state.currentPreviewItem._id === screen) { store.actions.pages.select($store.currentPageName) notifier.success(`Screen ${screenToDelete.name} deleted successfully.`) $goto(`./:page/page-layout`) diff --git a/packages/builder/src/components/userInterface/ComponentNavigationTree/index.svelte b/packages/builder/src/components/userInterface/ComponentNavigationTree/index.svelte index ef783b1afd..dbdfad0828 100644 --- a/packages/builder/src/components/userInterface/ComponentNavigationTree/index.svelte +++ b/packages/builder/src/components/userInterface/ComponentNavigationTree/index.svelte @@ -2,12 +2,10 @@ import { goto } from "@sveltech/routify" import { store } from "builderStore" import PathTree from "./PathTree.svelte" - - export let routes = {}
- {#each Object.keys(routes) as path} - + {#each Object.keys($store.routes) as path} + {/each}
diff --git a/packages/builder/src/components/userInterface/FrontendNavigatePane.svelte b/packages/builder/src/components/userInterface/FrontendNavigatePane.svelte index 7f8630330d..90d03e16a2 100644 --- a/packages/builder/src/components/userInterface/FrontendNavigatePane.svelte +++ b/packages/builder/src/components/userInterface/FrontendNavigatePane.svelte @@ -12,15 +12,8 @@ let routes = {} - async function fetchRoutes() { - const response = await api.get("/api/routing") - const json = await response.json() - - routes = json.routes - } - onMount(() => { - fetchRoutes() + store.actions.routing.fetch() }) @@ -31,7 +24,7 @@ diff --git a/packages/builder/src/components/userInterface/ScreenDropdownMenu.svelte b/packages/builder/src/components/userInterface/ScreenDropdownMenu.svelte deleted file mode 100644 index 74f4654ce3..0000000000 --- a/packages/builder/src/components/userInterface/ScreenDropdownMenu.svelte +++ /dev/null @@ -1,53 +0,0 @@ - - -
-
dropdown.show()}> - -
- - - confirmDeleteDialog.show()} /> - - -
- - -