diff --git a/packages/builder/src/pages/builder/app/[application]/data/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/index.svelte
index b2aca1f7f3..47939f09b4 100644
--- a/packages/builder/src/pages/builder/app/[application]/data/index.svelte
+++ b/packages/builder/src/pages/builder/app/[application]/data/index.svelte
@@ -1,22 +1,17 @@
-
-
diff --git a/packages/builder/src/pages/builder/app/[application]/data/new.svelte b/packages/builder/src/pages/builder/app/[application]/data/new.svelte
new file mode 100644
index 0000000000..f8e8fd85e7
--- /dev/null
+++ b/packages/builder/src/pages/builder/app/[application]/data/new.svelte
@@ -0,0 +1,257 @@
+
+
+
+
+
+
+
+ {#if integration?.auth?.type === "google"}
+
+ {:else}
+
+ {/if}
+
+
+
+
+ {#if hasData}
+
+ {/if}
+
+
+ Add new data source
+
+
+
+ Get started with our Budibase DB
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Or connect to an external datasource
+
+
+
+ {#each integrations as [key, value]}
+ handleIntegrationSelect(key)}
+ title={value.friendlyName}
+ description={value.type}
+ {disabled}
+ >
+
+
+ {/each}
+
+
+
+
diff --git a/packages/builder/src/pages/builder/portal/apps/onboarding/_components/DataPanel.svelte b/packages/builder/src/pages/builder/portal/apps/onboarding/_components/DataPanel.svelte
deleted file mode 100644
index 9a7fffd893..0000000000
--- a/packages/builder/src/pages/builder/portal/apps/onboarding/_components/DataPanel.svelte
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
diff --git a/packages/builder/src/pages/builder/portal/apps/onboarding/_components/DatasourceConfigPanel.svelte b/packages/builder/src/pages/builder/portal/apps/onboarding/_components/DatasourceConfigPanel.svelte
deleted file mode 100644
index 2b44648279..0000000000
--- a/packages/builder/src/pages/builder/portal/apps/onboarding/_components/DatasourceConfigPanel.svelte
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
- {#each Object.entries(fields) as [name, { type, default: defaultValue, required }]}
- {#if type !== "boolean"}
- {}}
- label={formatName(name)}
- {type}
- />
- {/if}
- {/each}
- {#each Object.entries(fields) as [name, { type, default: defaultValue, required }]}
- {#if type === "boolean"}
-
- {/if}
- {/each}
-
-
- {#if isGoogle}
-
- {:else}
-
- {/if}
-
-
-
diff --git a/packages/builder/src/pages/builder/portal/apps/onboarding/_components/ExampleApp.svelte b/packages/builder/src/pages/builder/portal/apps/onboarding/_components/ExampleApp.svelte
index 3e970ac360..0b290decbf 100644
--- a/packages/builder/src/pages/builder/portal/apps/onboarding/_components/ExampleApp.svelte
+++ b/packages/builder/src/pages/builder/portal/apps/onboarding/_components/ExampleApp.svelte
@@ -1,6 +1,5 @@
-
-
-
-
- {#if stage === "name"}
- (stage = "data")} />
- {:else if googleComplete}
-
- Please login to your Google account in the new tab which as opened to
- continue.
-
- {:else if integrationsLoading || creationLoading}
-
-
-
- {:else if stage === "data"}
- (stage = "name")}>
-
-
- {#each Object.entries(plusIntegrations) as [integrationType, schema]}
-
- {/each}
-
- {:else if stage in plusIntegrations}
- (stage = "data")}
- onNext={data => {
- const isGoogle = data.isGoogle
- delete data.isGoogle
- return handleCreateApp({ datasourceConfig: data, isGoogle })
- }}
- />
- {:else}
- There was an problem. Please refresh the page and try again.
- {/if}
+
-
+
@@ -258,35 +77,4 @@
.full-width {
width: 100%;
}
- .centered {
- display: flex;
- justify-content: center;
- align-items: center;
- min-height: 400px;
- }
-
- .dataButton {
- margin-bottom: 12px;
- }
-
- .dataButtonContent {
- display: flex;
- align-items: center;
- }
-
- .budibaseLogo {
- height: 20px;
- }
-
- .dataButtonIcon {
- width: 22px;
- display: flex;
- justify-content: center;
- margin-right: 16px;
- }
-
- .dataButtonContent :global(svg) {
- font-size: 18px;
- color: white;
- }
diff --git a/packages/builder/src/stores/backend/tables.js b/packages/builder/src/stores/backend/tables.js
index ba900b7df9..a36c91d1b1 100644
--- a/packages/builder/src/stores/backend/tables.js
+++ b/packages/builder/src/stores/backend/tables.js
@@ -63,9 +63,7 @@ export function createTablesStore() {
const savedTable = await API.saveTable(updatedTable)
replaceTable(table._id, savedTable)
- if (table.type === "external") {
- await datasources.fetch()
- }
+ await datasources.fetch()
select(savedTable._id)
return savedTable
}
diff --git a/packages/frontend-core/src/api/app.js b/packages/frontend-core/src/api/app.js
index 7868eef063..ce18bcc0c5 100644
--- a/packages/frontend-core/src/api/app.js
+++ b/packages/frontend-core/src/api/app.js
@@ -152,4 +152,10 @@ export const buildAppEndpoints = API => ({
url: `/api/${appId}/components/definitions`,
})
},
+
+ addSampleData: async appId => {
+ return await API.post({
+ url: `/api/applications/${appId}/sample`,
+ })
+ },
})
diff --git a/packages/server/src/api/controllers/application.ts b/packages/server/src/api/controllers/application.ts
index 815366785c..9c89b48b8a 100644
--- a/packages/server/src/api/controllers/application.ts
+++ b/packages/server/src/api/controllers/application.ts
@@ -26,7 +26,10 @@ import {
env as envCore,
} from "@budibase/backend-core"
import { USERS_TABLE_SCHEMA } from "../../constants"
-import { buildDefaultDocs } from "../../db/defaultData/datasource_bb_default"
+import {
+ DEFAULT_BB_DATASOURCE_ID,
+ buildDefaultDocs,
+} from "../../db/defaultData/datasource_bb_default"
import { removeAppFromUserRoles } from "../../utilities/workerRequests"
import { stringToReadStream, isQsTrue } from "../../utilities"
import { getLocksById, doesUserHaveLock } from "../../utilities/redis"
@@ -111,11 +114,7 @@ function checkAppName(
}
}
-async function createInstance(
- appId: string,
- template: any,
- includeSampleData: boolean
-) {
+async function createInstance(appId: string, template: any) {
const db = context.getAppDB()
await db.put({
_id: "_design/database",
@@ -142,21 +141,25 @@ async function createInstance(
} else {
// create the users table
await db.put(USERS_TABLE_SCHEMA)
-
- if (includeSampleData) {
- // create ootb stock db
- await addDefaultTables(db)
- }
}
return { _id: appId }
}
-async function addDefaultTables(db: Database) {
- const defaultDbDocs = buildDefaultDocs()
+export const addSampleData = async (ctx: UserCtx) => {
+ const db = context.getAppDB()
- // add in the default db data docs - tables, datasource, rows and links
- await db.bulkDocs([...defaultDbDocs])
+ try {
+ // Check if default datasource exists before creating it
+ await sdk.datasources.get(DEFAULT_BB_DATASOURCE_ID)
+ } catch (err: any) {
+ const defaultDbDocs = buildDefaultDocs()
+
+ // add in the default db data docs - tables, datasource, rows and links
+ await db.bulkDocs([...defaultDbDocs])
+ }
+
+ ctx.status = 200
}
export async function fetch(ctx: UserCtx) {
@@ -248,16 +251,11 @@ async function performAppCreate(ctx: UserCtx) {
if (ctx.request.files && ctx.request.files.templateFile) {
instanceConfig.file = ctx.request.files.templateFile
}
- const includeSampleData = isQsTrue(ctx.request.body.sampleData)
const tenantId = tenancy.isMultiTenant() ? tenancy.getTenantId() : null
const appId = generateDevAppID(generateAppID(tenantId))
return await context.doInAppContext(appId, async () => {
- const instance = await createInstance(
- appId,
- instanceConfig,
- includeSampleData
- )
+ const instance = await createInstance(appId, instanceConfig)
const db = context.getAppDB()
let newApplication: App = {
diff --git a/packages/server/src/api/routes/application.ts b/packages/server/src/api/routes/application.ts
index 0aa88568f3..0c1fa364ff 100644
--- a/packages/server/src/api/routes/application.ts
+++ b/packages/server/src/api/routes/application.ts
@@ -38,6 +38,11 @@ router
authorized(permissions.BUILDER),
controller.revertClient
)
+ .post(
+ "/api/applications/:appId/sample",
+ authorized(permissions.BUILDER),
+ controller.addSampleData
+ )
.post(
"/api/applications/:appId/publish",
authorized(permissions.BUILDER),