ensure table name is not persisted between apps

This commit is contained in:
Martin McKeaveney 2020-07-21 10:24:09 +01:00
parent c4ee632d58
commit 32cfc40fd4
2 changed files with 17 additions and 16 deletions

View File

@ -2,23 +2,24 @@ import { writable } from "svelte/store"
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
import api from "../api" import api from "../api"
export const getBackendUiStore = () => { const INITIAL_BACKEND_UI_STATE = {
const INITIAL_BACKEND_UI_STATE = { models: [],
models: [], views: [],
views: [], users: [],
users: [], selectedDatabase: {},
selectedDatabase: {}, selectedModel: {},
selectedModel: {}, draftModel: {},
draftModel: {}, tabs: {
tabs: { SETUP_PANEL: "SETUP",
SETUP_PANEL: "SETUP", NAVIGATION_PANEL: "NAVIGATE",
NAVIGATION_PANEL: "NAVIGATE", },
}, }
}
const store = writable(INITIAL_BACKEND_UI_STATE) export const getBackendUiStore = () => {
const store = writable({ ...INITIAL_BACKEND_UI_STATE })
store.actions = { store.actions = {
reset: () => store.set({ ...INITIAL_BACKEND_UI_STATE }),
database: { database: {
select: async db => { select: async db => {
const modelsResponse = await api.get(`/api/models`) const modelsResponse = await api.get(`/api/models`)
@ -78,7 +79,6 @@ export const getBackendUiStore = () => {
} }
const SAVE_MODEL_URL = `/api/models` const SAVE_MODEL_URL = `/api/models`
console.log(updatedModel)
const response = await api.post(SAVE_MODEL_URL, updatedModel) const response = await api.post(SAVE_MODEL_URL, updatedModel)
const savedModel = await response.json() const savedModel = await response.json()
await store.actions.models.fetch() await store.actions.models.fetch()

View File

@ -1,6 +1,6 @@
<script> <script>
import Modal from "svelte-simple-modal" import Modal from "svelte-simple-modal"
import { store, workflowStore } from "builderStore" import { store, workflowStore, backendUiStore } from "builderStore"
import SettingsLink from "components/settings/Link.svelte" import SettingsLink from "components/settings/Link.svelte"
import { get } from "builderStore/api" import { get } from "builderStore/api"
@ -20,6 +20,7 @@
const pkg = await res.json() const pkg = await res.json()
if (res.ok) { if (res.ok) {
backendUiStore.actions.reset()
await store.setPackage(pkg) await store.setPackage(pkg)
workflowStore.actions.fetch() workflowStore.actions.fetch()
return pkg return pkg