diff --git a/packages/builder/src/components/backend/DataTable/DataTable.svelte b/packages/builder/src/components/backend/DataTable/DataTable.svelte index 1fab8bcd32..025a6fc684 100644 --- a/packages/builder/src/components/backend/DataTable/DataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/DataTable.svelte @@ -53,7 +53,9 @@ bind:hideAutocolumns {loading} > - + {#if isInternal} + + {/if} {#if schema && Object.keys(schema).length > 0} {#if !isUsersTable} { update(state => ({ ...state, selected: datasourceId })) - queries.update(state => ({ ...state, selected: null })) + queries.unselect() + tables.unselect() + views.unselect() + }, + unselect: () => { + update(state => ({ ...state, selected: null })) }, updateSchema: async datasource => { let url = `/api/datasources/${datasource._id}/schema` diff --git a/packages/builder/src/stores/backend/queries.js b/packages/builder/src/stores/backend/queries.js index e0a5c9d9fc..2eeae29b9d 100644 --- a/packages/builder/src/stores/backend/queries.js +++ b/packages/builder/src/stores/backend/queries.js @@ -55,10 +55,6 @@ export function createQueriesStore() { }, select: query => { update(state => ({ ...state, selected: query._id })) - datasources.update(state => ({ - ...state, - selected: query.datasourceId, - })) tables.update(state => ({ ...state, selected: null, @@ -66,10 +62,6 @@ export function createQueriesStore() { }, unselect: () => { update(state => ({ ...state, selected: null })) - datasources.update(state => ({ - ...state, - selected: null, - })) }, delete: async query => { const response = await api.delete( diff --git a/packages/builder/src/stores/backend/tables.js b/packages/builder/src/stores/backend/tables.js index 18c748631a..e0b614a63e 100644 --- a/packages/builder/src/stores/backend/tables.js +++ b/packages/builder/src/stores/backend/tables.js @@ -1,5 +1,5 @@ import { writable, get } from "svelte/store" -import { views, queries } from "./" +import { views, queries, datasources } from "./" import { cloneDeep } from "lodash/fp" import api from "builderStore/api" @@ -25,8 +25,9 @@ export function createTablesStore() { selected: table, draft: cloneDeep(table), })) - views.select({ name: table._id }) + views.unselect() queries.unselect() + datasources.unselect() } } @@ -70,6 +71,12 @@ export function createTablesStore() { update, fetch, select, + unselect: () => { + update(state => ({ + ...state, + selected: null, + })) + }, save, init: async () => { const response = await api.get("/api/tables") diff --git a/packages/builder/src/stores/backend/views.js b/packages/builder/src/stores/backend/views.js index d6497bf871..0b15d18fa5 100644 --- a/packages/builder/src/stores/backend/views.js +++ b/packages/builder/src/stores/backend/views.js @@ -1,5 +1,5 @@ import { writable, get } from "svelte/store" -import { tables } from "./" +import { tables, datasources, queries } from "./" import api from "builderStore/api" export function createViewsStore() { @@ -10,11 +10,20 @@ export function createViewsStore() { return { subscribe, + update, select: async view => { update(state => ({ ...state, selected: view, })) + queries.unselect() + datasources.unselect() + }, + unselect: () => { + update(state => ({ + ...state, + selected: null, + })) }, delete: async view => { await api.delete(`/api/views/${view}`)