From 762fce6577aad54d8ae1076c73672e1438f853cb Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 21 Jul 2020 10:24:09 +0100 Subject: [PATCH] ensure table name is not persisted between apps --- .../builder/src/builderStore/store/backend.js | 30 +++++++++---------- .../src/pages/[application]/_reset.svelte | 3 +- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index 12e94aea60..393371ce85 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -2,23 +2,24 @@ import { writable } from "svelte/store" import { cloneDeep } from "lodash/fp" import api from "../api" -export const getBackendUiStore = () => { - const INITIAL_BACKEND_UI_STATE = { - models: [], - views: [], - users: [], - selectedDatabase: {}, - selectedModel: {}, - draftModel: {}, - tabs: { - SETUP_PANEL: "SETUP", - NAVIGATION_PANEL: "NAVIGATE", - }, - } +const INITIAL_BACKEND_UI_STATE = { + models: [], + views: [], + users: [], + selectedDatabase: {}, + selectedModel: {}, + draftModel: {}, + tabs: { + SETUP_PANEL: "SETUP", + NAVIGATION_PANEL: "NAVIGATE", + }, +} - const store = writable(INITIAL_BACKEND_UI_STATE) +export const getBackendUiStore = () => { + const store = writable({ ...INITIAL_BACKEND_UI_STATE }) store.actions = { + reset: () => store.set({ ...INITIAL_BACKEND_UI_STATE }), database: { select: async db => { const modelsResponse = await api.get(`/api/models`) @@ -78,7 +79,6 @@ export const getBackendUiStore = () => { } const SAVE_MODEL_URL = `/api/models` - console.log(updatedModel) const response = await api.post(SAVE_MODEL_URL, updatedModel) const savedModel = await response.json() await store.actions.models.fetch() diff --git a/packages/builder/src/pages/[application]/_reset.svelte b/packages/builder/src/pages/[application]/_reset.svelte index 7e982bdfe0..9891919434 100644 --- a/packages/builder/src/pages/[application]/_reset.svelte +++ b/packages/builder/src/pages/[application]/_reset.svelte @@ -1,6 +1,6 @@