Review updates

This commit is contained in:
Dean 2022-11-15 17:03:35 +00:00
parent 0b75f6036d
commit f73b4f8b01
12 changed files with 34 additions and 37 deletions

View File

@ -2,7 +2,7 @@
import { onMount } from "svelte" import { onMount } from "svelte"
import { get } from "svelte/store" import { get } from "svelte/store"
import { goto, params } from "@roxi/routify" import { goto, params } from "@roxi/routify"
import { BUDIBASE_INTERNAL_DB } from "constants" import { BUDIBASE_INTERNAL_DB_ID } from "constants/backend"
import { database, datasources, queries, tables, views } from "stores/backend" import { database, datasources, queries, tables, views } from "stores/backend"
import EditDatasourcePopover from "./popovers/EditDatasourcePopover.svelte" import EditDatasourcePopover from "./popovers/EditDatasourcePopover.svelte"
import EditQueryPopover from "./popovers/EditQueryPopover.svelte" import EditQueryPopover from "./popovers/EditQueryPopover.svelte"
@ -129,7 +129,7 @@
size="18" size="18"
/> />
</div> </div>
{#if datasource._id !== BUDIBASE_INTERNAL_DB} {#if datasource._id !== BUDIBASE_INTERNAL_DB_ID}
<EditDatasourcePopover {datasource} /> <EditDatasourcePopover {datasource} />
{/if} {/if}
</NavItem> </NavItem>

View File

@ -12,6 +12,10 @@
} from "@budibase/bbui" } from "@budibase/bbui"
import { datasources } from "stores/backend" import { datasources } from "stores/backend"
import TableDataImport from "../TableDataImport.svelte" import TableDataImport from "../TableDataImport.svelte"
import {
BUDIBASE_INTERNAL_DB_ID,
BUDIBASE_DATASOURCE_TYPE,
} from "constants/backend"
import { buildAutoColumn, getAutoColumnInformation } from "builderStore/utils" import { buildAutoColumn, getAutoColumnInformation } from "builderStore/utils"
$: tableNames = $tables.list.map(table => table.name) $: tableNames = $tables.list.map(table => table.name)
@ -19,10 +23,10 @@
source => source._id === $datasources.selected source => source._id === $datasources.selected
) )
$: isSelectedInternal = selectedSource?.type === "budibase" $: isSelectedInternal = selectedSource?.type === BUDIBASE_DATASOURCE_TYPE
$: targetDatasourceId = isSelectedInternal $: targetDatasourceId = isSelectedInternal
? selectedSource._id ? selectedSource._id
: "bb_internal" : BUDIBASE_INTERNAL_DB_ID
export let name export let name
let dataImport let dataImport

View File

@ -3,7 +3,10 @@
import { datasources, integrations, queries } from "stores/backend" import { datasources, integrations, queries } from "stores/backend"
import BindingBuilder from "components/integration/QueryBindingBuilder.svelte" import BindingBuilder from "components/integration/QueryBindingBuilder.svelte"
import IntegrationQueryEditor from "components/integration/index.svelte" import IntegrationQueryEditor from "components/integration/index.svelte"
import { BUDIBASE_DATASOURCE_ID } from "constants/backend" import {
BUDIBASE_INTERNAL_DB_ID,
BUDIBASE_DATASOURCE_TYPE,
} from "constants/backend"
export let parameters export let parameters
export let bindings = [] export let bindings = []
@ -14,7 +17,8 @@
) )
// Executequery must exclude budibase datasource // Executequery must exclude budibase datasource
$: executeQueryDatasources = $datasources.list.filter( $: executeQueryDatasources = $datasources.list.filter(
x => x._id !== BUDIBASE_DATASOURCE_ID && x.type !== "budibase" x =>
x._id !== BUDIBASE_INTERNAL_DB_ID && x.type !== BUDIBASE_DATASOURCE_TYPE
) )
function fetchQueryDefinition(query) { function fetchQueryDefinition(query) {

View File

@ -173,7 +173,8 @@ export const SWITCHABLE_TYPES = [
...ALLOWABLE_NUMBER_TYPES, ...ALLOWABLE_NUMBER_TYPES,
] ]
export const BUDIBASE_DATASOURCE_ID = "bb_internal" export const BUDIBASE_INTERNAL_DB_ID = "bb_internal"
export const BUDIBASE_DATASOURCE_TYPE = "budibase"
export const IntegrationTypes = { export const IntegrationTypes = {
POSTGRES: "POSTGRES", POSTGRES: "POSTGRES",

View File

@ -43,8 +43,6 @@ export const LAYOUT_NAMES = {
}, },
} }
export const BUDIBASE_INTERNAL_DB = "bb_internal"
// one or more word characters and whitespace // one or more word characters and whitespace
export const APP_NAME_REGEX = /^[\w\s]+$/ export const APP_NAME_REGEX = /^[\w\s]+$/
// zero or more non-whitespace characters // zero or more non-whitespace characters

View File

@ -1,7 +1,7 @@
<script> <script>
import { redirect, params } from "@roxi/routify" import { redirect, params } from "@roxi/routify"
import { Icon, Tabs, Tab } from "@budibase/bbui" import { Icon, Tabs, Tab } from "@budibase/bbui"
import { BUDIBASE_INTERNAL_DB } from "constants" import { BUDIBASE_INTERNAL_DB_ID } from "constants/backend"
import DatasourceNavigator from "components/backend/DatasourceNavigator/DatasourceNavigator.svelte" import DatasourceNavigator from "components/backend/DatasourceNavigator/DatasourceNavigator.svelte"
import CreateDatasourceModal from "components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte" import CreateDatasourceModal from "components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte"
@ -11,7 +11,7 @@
$: isExternal = $: isExternal =
$params.selectedDatasource && $params.selectedDatasource &&
$params.selectedDatasource !== BUDIBASE_INTERNAL_DB $params.selectedDatasource !== BUDIBASE_INTERNAL_DB_ID
function selectFirstDatasource() { function selectFirstDatasource() {
$redirect("./table") $redirect("./table")

View File

@ -21,7 +21,7 @@
<Layout gap="XS" noPadding> <Layout gap="XS" noPadding>
<header> <header>
<svelte:component this={ICONS.BUDIBASE} height="26" width="26" /> <svelte:component this={ICONS.BUDIBASE} height="26" width="26" />
<Heading size="M">Budibase Default</Heading> <Heading size="M">Test DB</Heading>
</header> </header>
<Body size="M">A little something to get you up and running!</Body> <Body size="M">A little something to get you up and running!</Body>
<Body size="M" <Body size="M"

View File

@ -175,17 +175,6 @@ const addDefaultTables = async (db: any) => {
// add in the default db data docs - tables, datasource, rows and links // add in the default db data docs - tables, datasource, rows and links
await db.bulkDocs([...defaultDbDocs]) await db.bulkDocs([...defaultDbDocs])
// Sync Quotas with the imported row count.
const metrics = defaultDbDocs.reduce((acc, doc) => {
acc[doc.type] = acc[doc.type] ? acc[doc.type] + 1 : 1
return acc
}, {})
// Record the row quotas
if (metrics.row) {
await quotas.addRows(metrics.row)
}
} }
export const fetch = async (ctx: any) => { export const fetch = async (ctx: any) => {

View File

@ -7,7 +7,11 @@ const {
getTableParams, getTableParams,
} = require("../../db/utils") } = require("../../db/utils")
const { destroy: tableDestroy } = require("./table/internal") const { destroy: tableDestroy } = require("./table/internal")
const { BuildSchemaErrors, InvalidColumns } = require("../../constants") const {
BuildSchemaErrors,
InvalidColumns,
BUDIBASE_DATASOURCE_TYPE,
} = require("../../constants")
const { getIntegration } = require("../../integrations") const { getIntegration } = require("../../integrations")
const { getDatasourceAndQuery } = require("./row/utils") const { getDatasourceAndQuery } = require("./row/utils")
const { invalidateDynamicVariables } = require("../../threads/utils") const { invalidateDynamicVariables } = require("../../threads/utils")
@ -51,7 +55,7 @@ exports.fetch = async function (ctx) {
delete datasource.config.auth delete datasource.config.auth
} }
if (datasource.type === "budibase") { if (datasource.type === BUDIBASE_DATASOURCE_TYPE) {
datasource.entities = internal[datasource._id] datasource.entities = internal[datasource._id]
} }
} }
@ -243,7 +247,7 @@ exports.destroy = async function (ctx) {
const datasource = await db.get(datasourceId) const datasource = await db.get(datasourceId)
// Delete all queries for the datasource // Delete all queries for the datasource
if (datasource.type === "budibase") { if (datasource.type === BUDIBASE_DATASOURCE_TYPE) {
await destroyInternalTablesBySourceId(datasourceId) await destroyInternalTablesBySourceId(datasourceId)
} else { } else {
const queries = await db.allDocs(getQueryParams(datasourceId, null)) const queries = await db.allDocs(getQueryParams(datasourceId, null))

View File

@ -89,6 +89,8 @@ exports.DatasourceAuthTypes = {
GOOGLE: "google", GOOGLE: "google",
} }
exports.BUDIBASE_DATASOURCE_TYPE = "budibase"
exports.SortDirection = { exports.SortDirection = {
ASCENDING: "ASCENDING", ASCENDING: "ASCENDING",
DESCENDING: "DESCENDING", DESCENDING: "DESCENDING",

View File

@ -10,6 +10,7 @@ const { inventoryImport } = require("./inventoryImport")
const { employeeImport } = require("./employeeImport") const { employeeImport } = require("./employeeImport")
const { jobsImport } = require("./jobsImport") const { jobsImport } = require("./jobsImport")
const { expensesImport } = require("./expensesImport") const { expensesImport } = require("./expensesImport")
const { BUDIBASE_DATASOURCE_TYPE } = require("../../constants")
exports.DEFAULT_JOBS_TABLE_ID = "ta_bb_jobs" exports.DEFAULT_JOBS_TABLE_ID = "ta_bb_jobs"
exports.DEFAULT_INVENTORY_TABLE_ID = "ta_bb_inventory" exports.DEFAULT_INVENTORY_TABLE_ID = "ta_bb_inventory"
@ -18,8 +19,8 @@ exports.DEFAULT_EMPLOYEE_TABLE_ID = "ta_bb_employee"
exports.DEFAULT_BB_DATASOURCE_ID = "datasource_internal_bb_default" exports.DEFAULT_BB_DATASOURCE_ID = "datasource_internal_bb_default"
exports.DEFAULT_BB_DATASOURCE = { exports.DEFAULT_BB_DATASOURCE = {
_id: this.DEFAULT_BB_DATASOURCE_ID, _id: this.DEFAULT_BB_DATASOURCE_ID,
type: "budibase", type: BUDIBASE_DATASOURCE_TYPE,
name: "BB Default", name: "Test DB",
source: "BUDIBASE", source: "BUDIBASE",
config: {}, config: {},
} }
@ -290,14 +291,6 @@ exports.DEFAULT_EMPLOYEE_TABLE_SCHEMA = {
name: "Badge Photo", name: "Badge Photo",
sortable: false, sortable: false,
}, },
// Jobs: {
// name: "Jobs",
// type: FieldTypes.LINK,
// tableId: this.DEFAULT_EMPLOYEE_TABLE_ID,
// fieldName: "Assigned",
// relationshipType: RelationshipTypes.MANY_TO_MANY,
// sortable: false,
// },
Jobs: { Jobs: {
type: FieldTypes.LINK, type: FieldTypes.LINK,
constraints: { constraints: {

View File

@ -22,6 +22,8 @@ const {
getGlobalIDFromUserMetadataID, getGlobalIDFromUserMetadataID,
} = require("@budibase/backend-core/db") } = require("@budibase/backend-core/db")
const { BUDIBASE_DATASOURCE_TYPE } = require("../constants")
const UNICODE_MAX = "\ufff0" const UNICODE_MAX = "\ufff0"
const AppStatus = { const AppStatus = {
@ -40,7 +42,7 @@ exports.StaticDatabases = StaticDatabases
const BudibaseInternalDB = { const BudibaseInternalDB = {
_id: "bb_internal", _id: "bb_internal",
type: "budibase", type: BUDIBASE_DATASOURCE_TYPE,
name: "Budibase DB", name: "Budibase DB",
source: "BUDIBASE", source: "BUDIBASE",
config: {}, config: {},