|
|
|
@ -303,14 +303,30 @@ const createOrUpdateIntegration = async () => {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// apply fix to config |
|
|
|
|
function applyConfigFix(fix: any) { |
|
|
|
|
if (!fix) return |
|
|
|
|
|
|
|
|
|
formState.value.dataSource = { |
|
|
|
|
...formState.value.dataSource, |
|
|
|
|
...fix, |
|
|
|
|
connection: { |
|
|
|
|
...formState.value.dataSource.connection, |
|
|
|
|
...fix.connection, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const testConnectionError = ref() |
|
|
|
|
|
|
|
|
|
const testConnection = async () => { |
|
|
|
|
const testConnection = async (retry = 0, initialConfig = null) => { |
|
|
|
|
try { |
|
|
|
|
await validate() |
|
|
|
|
} catch (e) { |
|
|
|
|
focusInvalidInput() |
|
|
|
|
return |
|
|
|
|
if (e.errorFields?.length) { |
|
|
|
|
focusInvalidInput() |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$e('a:source:create:extdb:test-connection', []) |
|
|
|
@ -343,11 +359,36 @@ const testConnection = async () => {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (e: any) { |
|
|
|
|
// take a copy of the current config |
|
|
|
|
const config = initialConfig || JSON.parse(JSON.stringify(formState.value.dataSource)) |
|
|
|
|
await handleConnectionError(e, retry, config) |
|
|
|
|
} finally { |
|
|
|
|
testingConnection.value = false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const MAX_CONNECTION_RETRIES = 3 |
|
|
|
|
|
|
|
|
|
async function handleConnectionError(e: any, retry: number, initialConfig: any): Promise<void> { |
|
|
|
|
if (retry >= MAX_CONNECTION_RETRIES) { |
|
|
|
|
testSuccess.value = false |
|
|
|
|
testConnectionError.value = await extractSdkResponseErrorMsg(e) |
|
|
|
|
// reset the connection config to initial state |
|
|
|
|
formState.value.dataSource = initialConfig |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const fix = generateConfigFix(e) |
|
|
|
|
|
|
|
|
|
if (fix) { |
|
|
|
|
applyConfigFix(fix) |
|
|
|
|
// Retry the connection after applying the fix |
|
|
|
|
return testConnection(retry + 1, initialConfig) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
testingConnection.value = false |
|
|
|
|
// If no fix is available, or fix did not resolve the issue |
|
|
|
|
testSuccess.value = false |
|
|
|
|
testConnectionError.value = await extractSdkResponseErrorMsg(e) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const handleImportURL = async () => { |
|
|
|
@ -545,7 +586,7 @@ watch(
|
|
|
|
|
:loading="testingConnection" |
|
|
|
|
:disabled="isLoading" |
|
|
|
|
icon-position="right" |
|
|
|
|
@click="testConnection" |
|
|
|
|
@click="testConnection()" |
|
|
|
|
> |
|
|
|
|
<template #icon> |
|
|
|
|
<GeneralIcon v-if="testSuccess" icon="circleCheckSolid" class="!text-green-700 w-4 h-4" /> |
|
|
|
|