From 81558588dcc3b627f80af5e0cdeb94e3c448f34d Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 24 Jan 2022 18:53:41 +0000 Subject: [PATCH] Clean up frontend store --- .../src/builderStore/store/frontend.js | 43 +++++-------------- .../NavigationPanel/ScreenWizard.svelte | 2 +- 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 8345a55b40..905cdd3976 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -28,7 +28,6 @@ import { } from "../componentUtils" import { Helpers } from "@budibase/bbui" import { removeBindings } from "../dataBinding" -import { notifications } from "@budibase/bbui" const INITIAL_FRONTEND_STATE = { apps: [], @@ -160,21 +159,6 @@ export const getFrontendStore = () => { return state }) }, - create: async screen => { - const savedScreen = await API.saveScreen(screen) - store.update(state => { - state.screens.push(savedScreen) - state.selectedScreenId = savedScreen._id - state.selectedComponentId = savedScreen.props._id - state.currentFrontEndType = FrontendTypes.SCREEN - selectedAccessRole.set(savedScreen.routing.roleId) - return state - }) - - // Refresh routes - await store.actions.routing.fetch() - return savedScreen - }, save: async screen => { const creatingNewScreen = screen._id === undefined const savedScreen = await API.saveScreen(screen) @@ -431,24 +415,19 @@ export const getFrontendStore = () => { parentComponent._children.push(componentInstance) // Save components and update UI - const savedAsset = await store.actions.preview.saveSelected() - if (savedAsset) { - store.update(state => { - state.currentView = "component" - state.selectedComponentId = componentInstance._id - return state - }) + await store.actions.preview.saveSelected() + store.update(state => { + state.currentView = "component" + state.selectedComponentId = componentInstance._id + return state + }) - // Log event - analytics.captureEvent(Events.COMPONENT.CREATED, { - name: componentInstance._component, - }) + // Log event + analytics.captureEvent(Events.COMPONENT.CREATED, { + name: componentInstance._component, + }) - return componentInstance - } else { - notifications.error("Failed to create component") - return null - } + return componentInstance }, delete: async component => { if (!component) { diff --git a/packages/builder/src/components/design/NavigationPanel/ScreenWizard.svelte b/packages/builder/src/components/design/NavigationPanel/ScreenWizard.svelte index 47aa3c7b26..a9fea4a45b 100644 --- a/packages/builder/src/components/design/NavigationPanel/ScreenWizard.svelte +++ b/packages/builder/src/components/design/NavigationPanel/ScreenWizard.svelte @@ -75,7 +75,7 @@ draftScreen.routing.route = route - await store.actions.screens.create(draftScreen) + await store.actions.screens.save(draftScreen) if (draftScreen.props._instanceName.endsWith("List")) { try { await store.actions.components.links.save(