From f73b4f8b01a4a2d4bf2f988003a2a4adb41b1d56 Mon Sep 17 00:00:00 2001 From: Dean Date: Tue, 15 Nov 2022 17:03:35 +0000 Subject: [PATCH] Review updates --- .../DatasourceNavigator/DatasourceNavigator.svelte | 4 ++-- .../TableNavigator/modals/CreateTableModal.svelte | 8 ++++++-- .../ButtonActionEditor/actions/ExecuteQuery.svelte | 8 ++++++-- packages/builder/src/constants/backend/index.js | 3 ++- packages/builder/src/constants/index.js | 2 -- .../builder/app/[application]/data/_layout.svelte | 4 ++-- .../datasource_internal_bb_default/index.svelte | 2 +- packages/server/src/api/controllers/application.ts | 11 ----------- packages/server/src/api/controllers/datasource.js | 10 +++++++--- packages/server/src/constants/index.js | 2 ++ .../src/db/defaultData/datasource_bb_default.js | 13 +++---------- packages/server/src/db/utils.js | 4 +++- 12 files changed, 34 insertions(+), 37 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte index a3531513fb..c860c7cba3 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte @@ -2,7 +2,7 @@ import { onMount } from "svelte" import { get } from "svelte/store" import { goto, params } from "@roxi/routify" - import { BUDIBASE_INTERNAL_DB } from "constants" + import { BUDIBASE_INTERNAL_DB_ID } from "constants/backend" import { database, datasources, queries, tables, views } from "stores/backend" import EditDatasourcePopover from "./popovers/EditDatasourcePopover.svelte" import EditQueryPopover from "./popovers/EditQueryPopover.svelte" @@ -129,7 +129,7 @@ size="18" /> - {#if datasource._id !== BUDIBASE_INTERNAL_DB} + {#if datasource._id !== BUDIBASE_INTERNAL_DB_ID} {/if} diff --git a/packages/builder/src/components/backend/TableNavigator/modals/CreateTableModal.svelte b/packages/builder/src/components/backend/TableNavigator/modals/CreateTableModal.svelte index 44e592a0b1..1872a308e5 100644 --- a/packages/builder/src/components/backend/TableNavigator/modals/CreateTableModal.svelte +++ b/packages/builder/src/components/backend/TableNavigator/modals/CreateTableModal.svelte @@ -12,6 +12,10 @@ } from "@budibase/bbui" import { datasources } from "stores/backend" import TableDataImport from "../TableDataImport.svelte" + import { + BUDIBASE_INTERNAL_DB_ID, + BUDIBASE_DATASOURCE_TYPE, + } from "constants/backend" import { buildAutoColumn, getAutoColumnInformation } from "builderStore/utils" $: tableNames = $tables.list.map(table => table.name) @@ -19,10 +23,10 @@ source => source._id === $datasources.selected ) - $: isSelectedInternal = selectedSource?.type === "budibase" + $: isSelectedInternal = selectedSource?.type === BUDIBASE_DATASOURCE_TYPE $: targetDatasourceId = isSelectedInternal ? selectedSource._id - : "bb_internal" + : BUDIBASE_INTERNAL_DB_ID export let name let dataImport diff --git a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ExecuteQuery.svelte b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ExecuteQuery.svelte index 757f65c65f..c74613b649 100644 --- a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ExecuteQuery.svelte +++ b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ExecuteQuery.svelte @@ -3,7 +3,10 @@ import { datasources, integrations, queries } from "stores/backend" import BindingBuilder from "components/integration/QueryBindingBuilder.svelte" import IntegrationQueryEditor from "components/integration/index.svelte" - import { BUDIBASE_DATASOURCE_ID } from "constants/backend" + import { + BUDIBASE_INTERNAL_DB_ID, + BUDIBASE_DATASOURCE_TYPE, + } from "constants/backend" export let parameters export let bindings = [] @@ -14,7 +17,8 @@ ) // Executequery must exclude budibase datasource $: executeQueryDatasources = $datasources.list.filter( - x => x._id !== BUDIBASE_DATASOURCE_ID && x.type !== "budibase" + x => + x._id !== BUDIBASE_INTERNAL_DB_ID && x.type !== BUDIBASE_DATASOURCE_TYPE ) function fetchQueryDefinition(query) { diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index 427e8d80a1..5ecc7bc324 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -173,7 +173,8 @@ export const SWITCHABLE_TYPES = [ ...ALLOWABLE_NUMBER_TYPES, ] -export const BUDIBASE_DATASOURCE_ID = "bb_internal" +export const BUDIBASE_INTERNAL_DB_ID = "bb_internal" +export const BUDIBASE_DATASOURCE_TYPE = "budibase" export const IntegrationTypes = { POSTGRES: "POSTGRES", diff --git a/packages/builder/src/constants/index.js b/packages/builder/src/constants/index.js index 151a0cdf8d..803cafcffb 100644 --- a/packages/builder/src/constants/index.js +++ b/packages/builder/src/constants/index.js @@ -43,8 +43,6 @@ export const LAYOUT_NAMES = { }, } -export const BUDIBASE_INTERNAL_DB = "bb_internal" - // one or more word characters and whitespace export const APP_NAME_REGEX = /^[\w\s]+$/ // zero or more non-whitespace characters diff --git a/packages/builder/src/pages/builder/app/[application]/data/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/data/_layout.svelte index 7046614768..14eab7c41b 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/_layout.svelte @@ -1,7 +1,7 @@