1
0
Fork 0
mirror of synced 2024-10-05 20:44:47 +13:00

Validate feature toggle

This commit is contained in:
Adria Navarro 2023-05-23 18:23:37 +02:00
parent 7be824b2e6
commit 0c97f61cc8
2 changed files with 14 additions and 6 deletions

View file

@ -53,6 +53,7 @@
config,
schema: selected.datasource,
auth: selected.auth,
features: selected.features || [],
}
if (selected.friendlyName) {
integration.name = selected.friendlyName

View file

@ -8,7 +8,6 @@
saveDatasource as save,
validateDatasourceConfig,
} from "builderStore/datasource"
import { onMount } from "svelte"
export let integration
export let modal
@ -37,10 +36,14 @@
return connected
}
$: shouldValidate = integration.features?.find(f => f === "connection")
async function saveDatasource() {
const valid = await validateConfig()
if (!valid) {
return false
if (shouldValidate) {
const valid = await validateConfig()
if (!valid) {
return false
}
}
try {
if (!datasource.name) {
@ -48,7 +51,7 @@
}
const resp = await save(datasource)
$goto(`./datasource/${resp._id}`)
notifications.success(`Datasource updated successfully.`)
notifications.success(`Datasource created successfully.`)
} catch (err) {
notifications.error(err?.message ?? "Error saving datasource")
// prevent the modal from closing
@ -61,7 +64,11 @@
title={`Connect to ${name}`}
onConfirm={() => saveDatasource()}
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"
showSecondaryButton={datasource.plus}
size="L"