diff --git a/packages/builder/src/components/backend/DatasourceNavigator/popovers/EditDatasourcePopover.svelte b/packages/builder/src/components/backend/DatasourceNavigator/popovers/EditDatasourcePopover.svelte index ae0023f682..165ed18ad8 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/popovers/EditDatasourcePopover.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/popovers/EditDatasourcePopover.svelte @@ -5,6 +5,7 @@ import { ActionMenu, MenuItem, Icon } from "@budibase/bbui" import ConfirmDialog from "components/common/ConfirmDialog.svelte" import UpdateDatasourceModal from "components/backend/DatasourceNavigator/modals/UpdateDatasourceModal.svelte" + import { BUDIBASE_DATASOURCE_TYPE } from "constants/backend" export let datasource @@ -42,7 +43,9 @@
- Edit + {#if datasource.type !== BUDIBASE_DATASOURCE_TYPE} + Edit + {/if} Delete diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index f3898e1d9e..35e250d459 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -174,6 +174,7 @@ export const SWITCHABLE_TYPES = [ ] export const BUDIBASE_INTERNAL_DB_ID = "bb_internal" +export const DEFAULT_BB_DATASOURCE_ID = "datasource_internal_bb_default" export const BUDIBASE_DATASOURCE_TYPE = "budibase" export const DB_TYPE_INTERNAL = "internal" export const DB_TYPE_EXTERNAL = "external" diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/datasource_internal_bb_default/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/datasource_internal_bb_default/_layout.svelte index 249f23d8b6..168290ef02 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/datasource_internal_bb_default/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/datasource_internal_bb_default/_layout.svelte @@ -1,7 +1,8 @@ diff --git a/packages/server/src/api/controllers/datasource.ts b/packages/server/src/api/controllers/datasource.ts index 511eb8ab74..cb1eb9ccaf 100644 --- a/packages/server/src/api/controllers/datasource.ts +++ b/packages/server/src/api/controllers/datasource.ts @@ -152,7 +152,12 @@ export async function update(ctx: BBContext) { let datasource = await db.get(datasourceId) const auth = datasource.config.auth await invalidateVariables(datasource, ctx.request.body) - datasource = { ...datasource, ...ctx.request.body } + + const dataSourceBody = !datasource.plus + ? { name: ctx.request.body?.name } + : ctx.request.body + + datasource = { ...datasource, ...dataSourceBody } if (auth && !ctx.request.body.auth) { // don't strip auth config from DB datasource.config.auth = auth @@ -163,7 +168,7 @@ export async function update(ctx: BBContext) { datasource._rev = response.rev // Drain connection pools when configuration is changed - if (datasource.source) { + if (datasource.source && datasource.plus) { const source = await getIntegration(datasource.source) if (source && source.pool) { await source.pool.end() diff --git a/packages/server/src/db/defaultData/datasource_bb_default.js b/packages/server/src/db/defaultData/datasource_bb_default.js index f12ee2c97d..0716b4bddf 100644 --- a/packages/server/src/db/defaultData/datasource_bb_default.js +++ b/packages/server/src/db/defaultData/datasource_bb_default.js @@ -631,8 +631,14 @@ exports.buildDefaultDocs = () => { ) }) + const dataSource = { + ...this.DEFAULT_BB_DATASOURCE, + updatedAt: new Date().toISOString(), + createdAt: new Date().toISOString(), + } + return [ - this.DEFAULT_BB_DATASOURCE, + dataSource, inventoryData.table, employeeData.table, jobData.table,