1
0
Fork 0
mirror of synced 2024-09-30 17:18:14 +13:00

Display fields

This commit is contained in:
Adria Navarro 2023-06-28 14:19:00 +01:00
parent 47d6113fee
commit fe86428cc4
2 changed files with 13 additions and 9 deletions

View file

@ -28,9 +28,11 @@
nameStore.markActive()
if ((await configStore.validate()) && (await nameStore.validate())) {
const { config } = get(configStore)
const { name } = get(nameStore)
return onSubmit({
config: get(configStore).config,
name: get(nameStore).name,
config,
name,
})
}

View file

@ -115,13 +115,15 @@ export function createDatasourcesStore() {
.length
}
const isDatasourceInvalid = async (integration, datasource) => {
const checkDatasourceValidity = async (integration, datasource) => {
if (integration.features?.[DatasourceFeature.CONNECTION_CHECKING]) {
const { connected } = await API.validateDatasource(datasource)
if (!connected) return true
}
const { connected, error } = await API.validateDatasource(datasource)
if (connected) {
return
}
return false
throw new Error(`Unable to connect: ${error}`)
}
}
const create = async ({ integration, config }) => {
@ -136,7 +138,7 @@ export function createDatasourcesStore() {
plus: integration.plus && integration.name !== IntegrationTypes.REST,
}
if (await isDatasourceInvalid(integration, datasource)) {
if (await checkDatasourceValidity(integration, datasource)) {
throw new Error("Unable to connect")
}
@ -150,7 +152,7 @@ export function createDatasourcesStore() {
}
const update = async ({ integration, datasource }) => {
if (await isDatasourceInvalid(integration, datasource)) {
if (await checkDatasourceValidity(integration, datasource)) {
throw new Error("Unable to connect")
}