Merge pull request #8857 from Budibase/fix/sample-data-edit-removed-delete-fixed
Remove ability to edit the 'Sample Data' datasource name
This commit is contained in:
commit
b66cf84876
|
@ -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,14 @@ 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 isBudibaseSource = datasource.type === dbCore.BUDIBASE_DATASOURCE_TYPE
|
||||
|
||||
const dataSourceBody = isBudibaseSource
|
||||
? { 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 +170,7 @@ export async function update(ctx: BBContext) {
|
|||
datasource._rev = response.rev
|
||||
|
||||
// Drain connection pools when configuration is changed
|
||||
if (datasource.source) {
|
||||
if (datasource.source && !isBudibaseSource) {
|
||||
const source = await getIntegration(datasource.source)
|
||||
if (source && source.pool) {
|
||||
await source.pool.end()
|
||||
|
|
|
@ -18,7 +18,8 @@ export const DEFAULT_INVENTORY_TABLE_ID = "ta_bb_inventory"
|
|||
export const DEFAULT_EXPENSES_TABLE_ID = "ta_bb_expenses"
|
||||
export const DEFAULT_EMPLOYEE_TABLE_ID = "ta_bb_employee"
|
||||
export const DEFAULT_BB_DATASOURCE_ID = "datasource_internal_bb_default"
|
||||
export const DEFAULT_BB_DATASOURCE = {
|
||||
|
||||
const defaultDatasource = {
|
||||
_id: DEFAULT_BB_DATASOURCE_ID,
|
||||
type: dbCore.BUDIBASE_DATASOURCE_TYPE,
|
||||
name: "Sample Data",
|
||||
|
@ -26,6 +27,8 @@ export const DEFAULT_BB_DATASOURCE = {
|
|||
config: {},
|
||||
}
|
||||
|
||||
export const DEFAULT_BB_DATASOURCE = defaultDatasource
|
||||
|
||||
function syncLastIds(table: Table, rowCount: number) {
|
||||
Object.keys(table.schema).forEach(key => {
|
||||
const entry = table.schema[key]
|
||||
|
@ -634,8 +637,14 @@ export function buildDefaultDocs() {
|
|||
}
|
||||
)
|
||||
|
||||
const dataSource = {
|
||||
...defaultDatasource,
|
||||
updatedAt: new Date().toISOString(),
|
||||
createdAt: new Date().toISOString(),
|
||||
}
|
||||
|
||||
return [
|
||||
DEFAULT_BB_DATASOURCE,
|
||||
dataSource,
|
||||
inventoryData.table,
|
||||
employeeData.table,
|
||||
jobData.table,
|
||||
|
|
Loading…
Reference in New Issue