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:
parent
678b4c1402
commit
7d0e2c289d
5 changed files with 21 additions and 5 deletions
|
@ -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 @@
|
|||
<div slot="control" class="icon">
|
||||
<Icon size="S" hoverable name="MoreSmallList" />
|
||||
</div>
|
||||
<MenuItem icon="Edit" on:click={updateDatasourceDialog.show}>Edit</MenuItem>
|
||||
{#if datasource.type !== BUDIBASE_DATASOURCE_TYPE}
|
||||
<MenuItem icon="Edit" on:click={updateDatasourceDialog.show}>Edit</MenuItem>
|
||||
{/if}
|
||||
<MenuItem icon="Delete" on:click={confirmDeleteDialog.show}>Delete</MenuItem>
|
||||
</ActionMenu>
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<script>
|
||||
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>
|
||||
|
||||
<slot />
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue