Validate url

This commit is contained in:
Adria Navarro 2023-05-31 13:00:33 +02:00
parent 1e238ce693
commit 25c921e340
4 changed files with 19 additions and 14 deletions

View File

@ -88,7 +88,7 @@ export async function postAuth(
}
)
ctx.redirect(`${baseUrl}/new?action=google_continue&id=${id}`)
ctx.redirect(`${baseUrl}/new?continue_google_setup=${id}`)
}
)(ctx, next)
}

View File

@ -1,5 +1,11 @@
<script>
import { ModalContent, Body, Layout, Link } from "@budibase/bbui"
import {
ModalContent,
Body,
Layout,
Link,
notifications,
} from "@budibase/bbui"
import { IntegrationNames, IntegrationTypes } from "constants/backend"
import GoogleButton from "../_components/GoogleButton.svelte"
import { organisation } from "stores/portal"
@ -9,9 +15,10 @@
import IntegrationConfigForm from "../TableIntegrationMenu/IntegrationConfigForm.svelte"
export let integration
export let continueSetup = false
export let continueSetupId = false
let datasource = cloneDeep(integration)
datasource.config.continueSetupId = continueSetupId
$: isGoogleConfigured = !!$organisation.googleDatasourceConfigured
@ -25,7 +32,7 @@
SET_URL: "Set_url",
}
let step = continueSetup
let step = continueSetupId
? GoogleDatasouceConfigStep.SET_URL
: GoogleDatasouceConfigStep.AUTH
@ -38,7 +45,7 @@
onConfirm: async () => {
const resp = await validateDatasourceConfig(datasource)
if (!resp.connected) {
displayError(`Unable to connect - ${resp.error}`)
notifications.error(`Unable to connect - ${resp.error}`)
}
return false

View File

@ -25,7 +25,6 @@
let integration = null
let disabled = false
let promptUpload = false
let continueGoogleSetup
$: hasData = $datasources.list.length > 1 || $tables.list.length > 1
$: hasDefaultData =
@ -131,12 +130,10 @@
return integrationsArray
}
let isGoogleContinueAction
let continueGoogleSetup
onMount(() => {
const urlParams = new URLSearchParams(window.location.search)
const action = urlParams.get("action")
isGoogleContinueAction = action === "google_continue"
continueGoogleSetup = urlParams.get("continue_google_setup")
})
const fetchIntegrations = async () => {
@ -144,7 +141,7 @@
integrations = sortIntegrations(unsortedIntegrations)
console.log(integrations[IntegrationTypes.GOOGLE_SHEETS])
if (isGoogleContinueAction) {
if (continueGoogleSetup) {
handleIntegrationSelect(IntegrationTypes.GOOGLE_SHEETS)
}
}
@ -159,12 +156,12 @@
<Modal
bind:this={externalDatasourceModal}
on:hide={() => {
continueGoogleSetup = false
continueGoogleSetup = null
}}
>
{#if integration?.auth?.type === "google"}
<GoogleDatasourceConfigModal
continueSetup={isGoogleContinueAction}
continueSetupId={continueGoogleSetup}
{integration}
/>
{:else}

View File

@ -11,7 +11,7 @@ import { BuildSchemaErrors, InvalidColumns } from "../../constants"
import { getIntegration } from "../../integrations"
import { getDatasourceAndQuery } from "./row/utils"
import { invalidateDynamicVariables } from "../../threads/utils"
import { db as dbCore, context, events } from "@budibase/backend-core"
import { db as dbCore, context, events, cache } from "@budibase/backend-core"
import {
UserCtx,
Datasource,
@ -25,6 +25,7 @@ import {
FetchDatasourceInfoResponse,
IntegrationBase,
DatasourcePlus,
SourceName,
} from "@budibase/types"
import sdk from "../../sdk"
import { builderSocket } from "../../websockets"