Create datasource on the second step
This commit is contained in:
parent
9ee06e8e42
commit
9021a095b1
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
import { saveDatasource } from "builderStore/datasource"
|
import { saveDatasource } from "builderStore/datasource"
|
||||||
import { DatasourceFeature } from "@budibase/types"
|
import { DatasourceFeature } from "@budibase/types"
|
||||||
|
import { API } from "api"
|
||||||
|
|
||||||
export let integration
|
export let integration
|
||||||
export let continueSetupId = false
|
export let continueSetupId = false
|
||||||
|
@ -50,20 +51,6 @@
|
||||||
let allSheets
|
let allSheets
|
||||||
let selectedSheets
|
let selectedSheets
|
||||||
|
|
||||||
const saveDatasourceAndRedirect = async () => {
|
|
||||||
try {
|
|
||||||
const resp = await saveDatasource(datasource, {
|
|
||||||
tablesFilter: selectedSheets,
|
|
||||||
})
|
|
||||||
$goto(`./datasource/${resp._id}`)
|
|
||||||
notifications.success(`Datasource created successfully.`)
|
|
||||||
} catch (err) {
|
|
||||||
notifications.error(err?.message ?? "Error saving datasource")
|
|
||||||
// prevent the modal from closing
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$: modalConfig = {
|
$: modalConfig = {
|
||||||
[GoogleDatasouceConfigStep.AUTH]: {
|
[GoogleDatasouceConfigStep.AUTH]: {
|
||||||
title: `Connect to ${integrationName}`,
|
title: `Connect to ${integrationName}`,
|
||||||
|
@ -82,8 +69,21 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const resp = await saveDatasource(datasource, {
|
||||||
|
tablesFilter: selectedSheets,
|
||||||
|
skipFetch: true,
|
||||||
|
})
|
||||||
|
datasource = resp
|
||||||
|
} catch (err) {
|
||||||
|
notifications.error(err?.message ?? "Error saving datasource")
|
||||||
|
// prevent the modal from closing
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if (!integration.features[DatasourceFeature.FETCH_TABLE_NAMES]) {
|
if (!integration.features[DatasourceFeature.FETCH_TABLE_NAMES]) {
|
||||||
saveDatasourceAndRedirect()
|
$goto(`./datasource/${datasource._id}`)
|
||||||
|
notifications.success(`Datasource created successfully.`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,23 @@
|
||||||
? "Fetch sheets"
|
? "Fetch sheets"
|
||||||
: "Continue without fetching",
|
: "Continue without fetching",
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
await saveDatasourceAndRedirect()
|
try {
|
||||||
|
if (selectedSheets.length) {
|
||||||
|
await API.buildDatasourceSchema({
|
||||||
|
datasourceId: datasource._id,
|
||||||
|
tablesFilter: selectedSheets,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
$goto(`./datasource/${datasource._id}`)
|
||||||
|
} catch (err) {
|
||||||
|
notifications.error(err?.message ?? "Error fetching the sheets")
|
||||||
|
// prevent the modal from closing
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onCancel: async () => {
|
||||||
|
$goto(`./datasource/${datasource._id}`)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -120,6 +136,7 @@
|
||||||
confirmText={modalConfig[step].confirmButtonText}
|
confirmText={modalConfig[step].confirmButtonText}
|
||||||
showConfirmButton={!!modalConfig[step].onConfirm}
|
showConfirmButton={!!modalConfig[step].onConfirm}
|
||||||
onConfirm={modalConfig[step].onConfirm}
|
onConfirm={modalConfig[step].onConfirm}
|
||||||
|
onCancel={modalConfig[step].onCancel}
|
||||||
disabled={!isValid}
|
disabled={!isValid}
|
||||||
>
|
>
|
||||||
{#if step === GoogleDatasouceConfigStep.AUTH}
|
{#if step === GoogleDatasouceConfigStep.AUTH}
|
||||||
|
|
Loading…
Reference in New Issue