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) )(ctx, next)
} }

View File

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

View File

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

View File

@ -11,7 +11,7 @@ import { BuildSchemaErrors, InvalidColumns } from "../../constants"
import { getIntegration } from "../../integrations" import { getIntegration } from "../../integrations"
import { getDatasourceAndQuery } from "./row/utils" import { getDatasourceAndQuery } from "./row/utils"
import { invalidateDynamicVariables } from "../../threads/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 { import {
UserCtx, UserCtx,
Datasource, Datasource,
@ -25,6 +25,7 @@ import {
FetchDatasourceInfoResponse, FetchDatasourceInfoResponse,
IntegrationBase, IntegrationBase,
DatasourcePlus, DatasourcePlus,
SourceName,
} from "@budibase/types" } from "@budibase/types"
import sdk from "../../sdk" import sdk from "../../sdk"
import { builderSocket } from "../../websockets" import { builderSocket } from "../../websockets"