From 25d0f3f518af8c0d3eaab8e254b9cc59f7eea99f Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 28 Jun 2023 11:59:53 +0100 Subject: [PATCH] Adding settings tab for SQL datasources. --- .../data/datasource/[datasourceId]/index.svelte | 7 +++++++ packages/server/src/integrations/utils.ts | 14 ++------------ packages/shared-core/src/helpers/integrations.ts | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/index.svelte index 5b1715c46f..837cd7f675 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/index.svelte @@ -10,6 +10,7 @@ import RestAuthenticationPanel from "./_components/panels/Authentication/index.svelte" import RestVariablesPanel from "./_components/panels/Variables/index.svelte" import PromptQueryModal from "./_components/PromptQueryModal.svelte" + import { helpers } from "@budibase/shared-core" let selectedPanel = null let panelOptions = [] @@ -39,6 +40,10 @@ panelOptions = ["Queries"] selectedPanel = "Queries" } + // always the last option for SQL + if (helpers.isSQL(datasource)) { + panelOptions.push("Settings") + } } @@ -82,6 +87,8 @@ {:else if selectedPanel === "Variables"} + {:else if selectedPanel === "Settings"} + Settings {:else} Something went wrong {/if} diff --git a/packages/server/src/integrations/utils.ts b/packages/server/src/integrations/utils.ts index cc3caa6d5b..75deaf7f30 100644 --- a/packages/server/src/integrations/utils.ts +++ b/packages/server/src/integrations/utils.ts @@ -1,6 +1,7 @@ import { SourceName, SqlQuery, Datasource, Table } from "@budibase/types" import { DocumentType, SEPARATOR } from "../db/utils" import { FieldTypes, BuildSchemaErrors, InvalidColumns } from "../constants" +import { helpers } from "@budibase/shared-core" const DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}` const ROW_ID_REGEX = /^\[.*]$/g @@ -178,18 +179,7 @@ export function getSqlQuery(query: SqlQuery | string): SqlQuery { } } -export function isSQL(datasource: Datasource): boolean { - if (!datasource || !datasource.source) { - return false - } - const SQL = [ - SourceName.POSTGRES, - SourceName.SQL_SERVER, - SourceName.MYSQL, - SourceName.ORACLE, - ] - return SQL.indexOf(datasource.source) !== -1 -} +export const isSQL = helpers.isSQL export function isIsoDateString(str: string) { if (!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(str)) { diff --git a/packages/shared-core/src/helpers/integrations.ts b/packages/shared-core/src/helpers/integrations.ts index a7b74885d8..b8c220c6a5 100644 --- a/packages/shared-core/src/helpers/integrations.ts +++ b/packages/shared-core/src/helpers/integrations.ts @@ -1,5 +1,18 @@ -import { SourceName } from "@budibase/types" +import { Datasource, SourceName } from "@budibase/types" export function isGoogleSheets(type: SourceName) { return type === SourceName.GOOGLE_SHEETS } + +export function isSQL(datasource: Datasource): boolean { + if (!datasource || !datasource.source) { + return false + } + const SQL = [ + SourceName.POSTGRES, + SourceName.SQL_SERVER, + SourceName.MYSQL, + SourceName.ORACLE, + ] + return SQL.indexOf(datasource.source) !== -1 +}