Disabled the ability to rename the Sample Data datasource. Updated the backend to ensure that renaming doesn't alter its structure and block deletion

This commit is contained in:
Dean 2022-11-28 17:25:10 +00:00
parent 678b4c1402
commit 7d0e2c289d
5 changed files with 21 additions and 5 deletions

View File

@ -5,6 +5,7 @@
import { ActionMenu, MenuItem, Icon } from "@budibase/bbui" import { ActionMenu, MenuItem, Icon } from "@budibase/bbui"
import ConfirmDialog from "components/common/ConfirmDialog.svelte" import ConfirmDialog from "components/common/ConfirmDialog.svelte"
import UpdateDatasourceModal from "components/backend/DatasourceNavigator/modals/UpdateDatasourceModal.svelte" import UpdateDatasourceModal from "components/backend/DatasourceNavigator/modals/UpdateDatasourceModal.svelte"
import { BUDIBASE_DATASOURCE_TYPE } from "constants/backend"
export let datasource export let datasource
@ -42,7 +43,9 @@
<div slot="control" class="icon"> <div slot="control" class="icon">
<Icon size="S" hoverable name="MoreSmallList" /> <Icon size="S" hoverable name="MoreSmallList" />
</div> </div>
{#if datasource.type !== BUDIBASE_DATASOURCE_TYPE}
<MenuItem icon="Edit" on:click={updateDatasourceDialog.show}>Edit</MenuItem> <MenuItem icon="Edit" on:click={updateDatasourceDialog.show}>Edit</MenuItem>
{/if}
<MenuItem icon="Delete" on:click={confirmDeleteDialog.show}>Delete</MenuItem> <MenuItem icon="Delete" on:click={confirmDeleteDialog.show}>Delete</MenuItem>
</ActionMenu> </ActionMenu>

View File

@ -174,6 +174,7 @@ export const SWITCHABLE_TYPES = [
] ]
export const BUDIBASE_INTERNAL_DB_ID = "bb_internal" 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 BUDIBASE_DATASOURCE_TYPE = "budibase"
export const DB_TYPE_INTERNAL = "internal" export const DB_TYPE_INTERNAL = "internal"
export const DB_TYPE_EXTERNAL = "external" export const DB_TYPE_EXTERNAL = "external"

View File

@ -1,7 +1,8 @@
<script> <script>
import { datasources } from "stores/backend" import { datasources } from "stores/backend"
import { DEFAULT_BB_DATASOURCE_ID } from "constants/backend"
datasources.select("datasource_internal_bb_default") datasources.select(DEFAULT_BB_DATASOURCE_ID)
</script> </script>
<slot /> <slot />

View File

@ -152,7 +152,12 @@ export async function update(ctx: BBContext) {
let datasource = await db.get(datasourceId) let datasource = await db.get(datasourceId)
const auth = datasource.config.auth const auth = datasource.config.auth
await invalidateVariables(datasource, ctx.request.body) 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) { if (auth && !ctx.request.body.auth) {
// don't strip auth config from DB // don't strip auth config from DB
datasource.config.auth = auth datasource.config.auth = auth
@ -163,7 +168,7 @@ export async function update(ctx: BBContext) {
datasource._rev = response.rev datasource._rev = response.rev
// Drain connection pools when configuration is changed // Drain connection pools when configuration is changed
if (datasource.source) { if (datasource.source && datasource.plus) {
const source = await getIntegration(datasource.source) const source = await getIntegration(datasource.source)
if (source && source.pool) { if (source && source.pool) {
await source.pool.end() await source.pool.end()

View File

@ -631,8 +631,14 @@ exports.buildDefaultDocs = () => {
) )
}) })
const dataSource = {
...this.DEFAULT_BB_DATASOURCE,
updatedAt: new Date().toISOString(),
createdAt: new Date().toISOString(),
}
return [ return [
this.DEFAULT_BB_DATASOURCE, dataSource,
inventoryData.table, inventoryData.table,
employeeData.table, employeeData.table,
jobData.table, jobData.table,