Validate google sheets url
This commit is contained in:
parent
d4ba73f331
commit
1e238ce693
|
@ -4,9 +4,15 @@
|
||||||
import GoogleButton from "../_components/GoogleButton.svelte"
|
import GoogleButton from "../_components/GoogleButton.svelte"
|
||||||
import { organisation } from "stores/portal"
|
import { organisation } from "stores/portal"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
|
import { validateDatasourceConfig } from "builderStore/datasource"
|
||||||
|
import cloneDeep from "lodash/cloneDeepWith"
|
||||||
|
import IntegrationConfigForm from "../TableIntegrationMenu/IntegrationConfigForm.svelte"
|
||||||
|
|
||||||
|
export let integration
|
||||||
export let continueSetup = false
|
export let continueSetup = false
|
||||||
|
|
||||||
|
let datasource = cloneDeep(integration)
|
||||||
|
|
||||||
$: isGoogleConfigured = !!$organisation.googleDatasourceConfigured
|
$: isGoogleConfigured = !!$organisation.googleDatasourceConfigured
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
@ -22,13 +28,32 @@
|
||||||
let step = continueSetup
|
let step = continueSetup
|
||||||
? GoogleDatasouceConfigStep.SET_URL
|
? GoogleDatasouceConfigStep.SET_URL
|
||||||
: GoogleDatasouceConfigStep.AUTH
|
: GoogleDatasouceConfigStep.AUTH
|
||||||
|
|
||||||
|
let isValid
|
||||||
|
|
||||||
|
const modalConfig = {
|
||||||
|
[GoogleDatasouceConfigStep.AUTH]: {},
|
||||||
|
[GoogleDatasouceConfigStep.SET_URL]: {
|
||||||
|
confirmButtonText: "Connect",
|
||||||
|
onConfirm: async () => {
|
||||||
|
const resp = await validateDatasourceConfig(datasource)
|
||||||
|
if (!resp.connected) {
|
||||||
|
displayError(`Unable to connect - ${resp.error}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ModalContent
|
<ModalContent
|
||||||
title={`Connect to ${integrationName}`}
|
title={`Connect to ${integrationName}`}
|
||||||
cancelText="Back"
|
cancelText="Cancel"
|
||||||
size="L"
|
size="L"
|
||||||
showConfirmButton={false}
|
confirmText={modalConfig[step].confirmButtonText}
|
||||||
|
showConfirmButton={!!modalConfig[step].onConfirm}
|
||||||
|
onConfirm={modalConfig[step].onConfirm}
|
||||||
>
|
>
|
||||||
{#if step === GoogleDatasouceConfigStep.AUTH}
|
{#if step === GoogleDatasouceConfigStep.AUTH}
|
||||||
<!-- check true and false directly, don't render until flag is set -->
|
<!-- check true and false directly, don't render until flag is set -->
|
||||||
|
@ -48,8 +73,15 @@
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{#if step === GoogleDatasouceConfigStep.SET_URL}
|
{#if step === GoogleDatasouceConfigStep.SET_URL}
|
||||||
<Layout noPadding>
|
<Layout noPadding no>
|
||||||
<Body size="S">Add the URL of the sheet you want to connect</Body>
|
<Body size="S">Add the URL of the sheet you want to connect.</Body>
|
||||||
|
|
||||||
|
<IntegrationConfigForm
|
||||||
|
schema={datasource.schema}
|
||||||
|
bind:datasource
|
||||||
|
creating={true}
|
||||||
|
on:valid={e => (isValid = e.detail)}
|
||||||
|
/>
|
||||||
</Layout>
|
</Layout>
|
||||||
{/if}
|
{/if}
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
|
@ -131,21 +131,25 @@
|
||||||
return integrationsArray
|
return integrationsArray
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchIntegrations = async () => {
|
let isGoogleContinueAction
|
||||||
const unsortedIntegrations = await API.getIntegrations()
|
|
||||||
integrations = sortIntegrations(unsortedIntegrations)
|
|
||||||
}
|
|
||||||
|
|
||||||
$: fetchIntegrations()
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const urlParams = new URLSearchParams(window.location.search)
|
const urlParams = new URLSearchParams(window.location.search)
|
||||||
const action = urlParams.get("action")
|
const action = urlParams.get("action")
|
||||||
if (action === "google_continue") {
|
|
||||||
continueGoogleSetup = true
|
isGoogleContinueAction = action === "google_continue"
|
||||||
externalDatasourceModal.show()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const fetchIntegrations = async () => {
|
||||||
|
const unsortedIntegrations = await API.getIntegrations()
|
||||||
|
integrations = sortIntegrations(unsortedIntegrations)
|
||||||
|
console.log(integrations[IntegrationTypes.GOOGLE_SHEETS])
|
||||||
|
|
||||||
|
if (isGoogleContinueAction) {
|
||||||
|
handleIntegrationSelect(IntegrationTypes.GOOGLE_SHEETS)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$: fetchIntegrations()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:this={internalTableModal}>
|
<Modal bind:this={internalTableModal}>
|
||||||
|
@ -158,8 +162,11 @@
|
||||||
continueGoogleSetup = false
|
continueGoogleSetup = false
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#if integration?.auth?.type === "google" || continueGoogleSetup}
|
{#if integration?.auth?.type === "google"}
|
||||||
<GoogleDatasourceConfigModal continueSetup={continueGoogleSetup} />
|
<GoogleDatasourceConfigModal
|
||||||
|
continueSetup={isGoogleContinueAction}
|
||||||
|
{integration}
|
||||||
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<DatasourceConfigModal {integration} />
|
<DatasourceConfigModal {integration} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -72,7 +72,7 @@ const SCHEMA: Integration = {
|
||||||
},
|
},
|
||||||
datasource: {
|
datasource: {
|
||||||
spreadsheetId: {
|
spreadsheetId: {
|
||||||
display: "Google Sheet URL",
|
display: "Spreadsheet URL",
|
||||||
type: DatasourceFieldType.STRING,
|
type: DatasourceFieldType.STRING,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue