From 05188f058854e4c1ae77449c80f2d2c6d8876ebf Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 23 Nov 2022 17:12:23 +0000 Subject: [PATCH] Review updates --- .../src/builderStore/store/frontend.js | 22 ++++++++++--------- .../builder/src/constants/backend/index.js | 2 ++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index dc7264a814..fb486c6d27 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -20,6 +20,11 @@ import { } from "../componentUtils" import { Helpers } from "@budibase/bbui" import { Utils } from "@budibase/frontend-core" +import { + BUDIBASE_INTERNAL_DB_ID, + DB_TYPE_INTERNAL, + DB_TYPE_EXTERNAL, +} from "constants/backend" const INITIAL_FRONTEND_STATE = { apps: [], @@ -497,25 +502,22 @@ export const getFrontendStore = () => { const internalTable = filteredTables.find( table => - table.sourceId === "bb_internal" && table.type == "internal" + table.sourceId === BUDIBASE_INTERNAL_DB_ID && + table.type == DB_TYPE_INTERNAL ) const defaultSourceTable = filteredTables.find( table => - table.sourceId !== "bb_internal" && table.type == "internal" + table.sourceId !== BUDIBASE_INTERNAL_DB_ID && + table.type == DB_TYPE_INTERNAL ) const defaultExternalTable = filteredTables.find( - table => table.type == "external" + table => table.type == DB_TYPE_EXTERNAL ) - if (defaultSourceTable) { - defaultDatasource = defaultSourceTable - } else if (internalTable) { - defaultDatasource = internalTable - } else if (defaultExternalTable) { - defaultDatasource = defaultExternalTable - } + defaultDatasource = + defaultSourceTable || internalTable || defaultExternalTable } // Generate default props diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index 5ecc7bc324..f3898e1d9e 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -175,6 +175,8 @@ export const SWITCHABLE_TYPES = [ export const BUDIBASE_INTERNAL_DB_ID = "bb_internal" export const BUDIBASE_DATASOURCE_TYPE = "budibase" +export const DB_TYPE_INTERNAL = "internal" +export const DB_TYPE_EXTERNAL = "external" export const IntegrationTypes = { POSTGRES: "POSTGRES",