Validate feature toggle
This commit is contained in:
parent
7be824b2e6
commit
0c97f61cc8
|
@ -53,6 +53,7 @@
|
||||||
config,
|
config,
|
||||||
schema: selected.datasource,
|
schema: selected.datasource,
|
||||||
auth: selected.auth,
|
auth: selected.auth,
|
||||||
|
features: selected.features || [],
|
||||||
}
|
}
|
||||||
if (selected.friendlyName) {
|
if (selected.friendlyName) {
|
||||||
integration.name = selected.friendlyName
|
integration.name = selected.friendlyName
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
saveDatasource as save,
|
saveDatasource as save,
|
||||||
validateDatasourceConfig,
|
validateDatasourceConfig,
|
||||||
} from "builderStore/datasource"
|
} from "builderStore/datasource"
|
||||||
import { onMount } from "svelte"
|
|
||||||
|
|
||||||
export let integration
|
export let integration
|
||||||
export let modal
|
export let modal
|
||||||
|
@ -37,10 +36,14 @@
|
||||||
return connected
|
return connected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: shouldValidate = integration.features?.find(f => f === "connection")
|
||||||
|
|
||||||
async function saveDatasource() {
|
async function saveDatasource() {
|
||||||
const valid = await validateConfig()
|
if (shouldValidate) {
|
||||||
if (!valid) {
|
const valid = await validateConfig()
|
||||||
return false
|
if (!valid) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (!datasource.name) {
|
if (!datasource.name) {
|
||||||
|
@ -48,7 +51,7 @@
|
||||||
}
|
}
|
||||||
const resp = await save(datasource)
|
const resp = await save(datasource)
|
||||||
$goto(`./datasource/${resp._id}`)
|
$goto(`./datasource/${resp._id}`)
|
||||||
notifications.success(`Datasource updated successfully.`)
|
notifications.success(`Datasource created successfully.`)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
notifications.error(err?.message ?? "Error saving datasource")
|
notifications.error(err?.message ?? "Error saving datasource")
|
||||||
// prevent the modal from closing
|
// prevent the modal from closing
|
||||||
|
@ -61,7 +64,11 @@
|
||||||
title={`Connect to ${name}`}
|
title={`Connect to ${name}`}
|
||||||
onConfirm={() => saveDatasource()}
|
onConfirm={() => saveDatasource()}
|
||||||
onCancel={() => modal.show()}
|
onCancel={() => modal.show()}
|
||||||
confirmText={datasource.plus ? "Connect" : "Save and continue to query"}
|
confirmText={datasource.plus
|
||||||
|
? shouldValidate
|
||||||
|
? "Connect"
|
||||||
|
: "Save and continue"
|
||||||
|
: "Save and continue to query"}
|
||||||
cancelText="Back"
|
cancelText="Back"
|
||||||
showSecondaryButton={datasource.plus}
|
showSecondaryButton={datasource.plus}
|
||||||
size="L"
|
size="L"
|
||||||
|
|
Loading…
Reference in New Issue