diff --git a/packages/builder/src/builderStore/dataBinding.js b/packages/builder/src/builderStore/dataBinding.js index dee0b86fb3..e76342fb3b 100644 --- a/packages/builder/src/builderStore/dataBinding.js +++ b/packages/builder/src/builderStore/dataBinding.js @@ -1,6 +1,7 @@ import { cloneDeep } from "lodash/fp" import { get } from "svelte/store" -import { backendUiStore, store } from "builderStore" +import { store } from "builderStore" +import { tables as tablesStore, queries as queriesStores } from 'builderStore/store/backend/' import { findComponentPath } from "./storeUtils" import { makePropSafe } from "@budibase/string-templates" import { TableNames } from "../constants" @@ -164,7 +165,7 @@ const getContextBindings = (asset, componentId) => { */ const getUserBindings = () => { let bindings = [] - const tables = get(backendUiStore).tables + const tables = get(tablesStore).list const userTable = tables.find(table => table._id === TableNames.USERS) const schema = { ...userTable.schema, @@ -223,10 +224,10 @@ export const getSchemaForDatasource = (datasource, isForm = false) => { if (datasource) { const { type } = datasource if (type === "query") { - const queries = get(backendUiStore).queries + const queries = get(queriesStores).queries table = queries.find(query => query._id === datasource._id) } else { - const tables = get(backendUiStore).tables + const tables = get(tablesStore).tables table = tables.find(table => table._id === datasource.tableId) } if (table) { diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index a7947f3e5e..62826b3b61 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -1,5 +1,4 @@ -import { writable, get } from "svelte/store" -import { cloneDeep } from "lodash/fp" +import { writable } from "svelte/store" import api from "../api" const INITIAL_BACKEND_UI_STATE = { @@ -16,18 +15,6 @@ export const getBackendUiStore = () => { store.actions = { reset: () => store.set({ ...INITIAL_BACKEND_UI_STATE }), - database: { - select: async db => { - const [tables] = await Promise.all([ - api.get(`/api/tables`).then(r => r.json()), - ]) - - store.update(state => { - state.tables = tables - return state - }) - }, - }, rows: { save: () => store.update(state => { @@ -40,40 +27,6 @@ export const getBackendUiStore = () => { return state }), }, - views: { - select: view => - store.update(state => { - state.selectedView = view - state.selectedTable = {} - return state - }), - delete: async view => { - await api.delete(`/api/views/${view}`) - await store.actions.tables.fetch() - }, - save: async view => { - const response = await api.post(`/api/views`, view) - const json = await response.json() - - const viewMeta = { - name: view.name, - ...json, - } - - store.update(state => { - const viewTable = state.tables.find( - table => table._id === view.tableId - ) - - if (view.originalName) delete viewTable.views[view.originalName] - viewTable.views[view.name] = viewMeta - - state.tables = state.tables - state.selectedView = viewMeta - return state - }) - }, - }, } return store diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 2b450eb49f..8c890cc5f5 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -2,7 +2,6 @@ import { get, writable } from "svelte/store" import { cloneDeep } from "lodash/fp" import { allScreens, - backendUiStore, hostingStore, currentAsset, mainLayout, diff --git a/packages/builder/src/components/automation/AutomationPanel/CreateAutomationModal.svelte b/packages/builder/src/components/automation/AutomationPanel/CreateAutomationModal.svelte index abc7bd9f96..d827cfdee8 100644 --- a/packages/builder/src/components/automation/AutomationPanel/CreateAutomationModal.svelte +++ b/packages/builder/src/components/automation/AutomationPanel/CreateAutomationModal.svelte @@ -1,5 +1,6 @@ -{#if $backendUiStore.selectedDatabase._id && selectedTable.name} +{#if $database._id && selectedTable.name} {:else}Create your first table to start building{/if} diff --git a/packages/builder/src/pages/[application]/data/view/[selectedView]/index.svelte b/packages/builder/src/pages/[application]/data/view/[selectedView]/index.svelte index 312e799005..f18f6742b0 100644 --- a/packages/builder/src/pages/[application]/data/view/[selectedView]/index.svelte +++ b/packages/builder/src/pages/[application]/data/view/[selectedView]/index.svelte @@ -1,11 +1,11 @@ -{#if $backendUiStore.selectedDatabase._id && selectedView} +{#if $database._id && selectedView} {:else}Create your first table to start building{/if}