From ee81fd7a5931770f4b1647bed2aac87cfeefd52b Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 29 May 2023 15:39:39 +0200 Subject: [PATCH 01/39] Split auth google section --- .../portal/settings/auth/google.svelte | 235 ++++++++++++++++++ .../builder/portal/settings/auth/index.svelte | 154 +----------- 2 files changed, 237 insertions(+), 152 deletions(-) create mode 100644 packages/builder/src/pages/builder/portal/settings/auth/google.svelte diff --git a/packages/builder/src/pages/builder/portal/settings/auth/google.svelte b/packages/builder/src/pages/builder/portal/settings/auth/google.svelte new file mode 100644 index 0000000000..82ab13cc8e --- /dev/null +++ b/packages/builder/src/pages/builder/portal/settings/auth/google.svelte @@ -0,0 +1,235 @@ + + +{#if providers.google} + + + +
+ + Google +
+
+ + To allow users to authenticate using their Google accounts, fill out the + fields below. Read the documentation for more information. + +
+ + {#each GoogleConfigFields.Google as field} +
+ +
+
+ +
+ {#if field.copyButton} +
copyToClipboard(field.placeholder)} + > + +
+ {/if} +
+
+ {/each} +
+ + +
+
+
+ +
+{/if} + + diff --git a/packages/builder/src/pages/builder/portal/settings/auth/index.svelte b/packages/builder/src/pages/builder/portal/settings/auth/index.svelte index 38f5e0788b..36cf5c13a8 100644 --- a/packages/builder/src/pages/builder/portal/settings/auth/index.svelte +++ b/packages/builder/src/pages/builder/portal/settings/auth/index.svelte @@ -1,5 +1,4 @@ - - {#if isGoogleConfigured === true} - + {#if step === GoogleDatasouceConfigStep.AUTH} + + {#if isGoogleConfigured === true} + + Authenticate with your google account to use the {integrationName} integration. + + + {:else if isGoogleConfigured === false} Authenticate with your google account to use the {IntegrationNames[ - datasource.type - ]} integration.Google authentication is not enabled, please complete Google SSO + configuration. + Configure Google SSO + {/if} + {/if} + {#if step === GoogleDatasouceConfigStep.SET_URL} + + Add the URL of the sheet you want to connect - - {:else if isGoogleConfigured === false} - Google authentication is not enabled, please complete Google SSO - configuration. - Configure Google SSO {/if} diff --git a/packages/builder/src/pages/builder/app/[application]/data/new.svelte b/packages/builder/src/pages/builder/app/[application]/data/new.svelte index fedaf013da..ed2e7f360d 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/new.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/new.svelte @@ -17,6 +17,7 @@ import IntegrationIcon from "components/backend/DatasourceNavigator/IntegrationIcon.svelte" import ICONS from "components/backend/DatasourceNavigator/icons/index.js" import FontAwesomeIcon from "components/common/FontAwesomeIcon.svelte" + import { onMount } from "svelte" let internalTableModal let externalDatasourceModal @@ -24,6 +25,7 @@ let integration = null let disabled = false let promptUpload = false + let continueGoogleSetup $: hasData = $datasources.list.length > 1 || $tables.list.length > 1 $: hasDefaultData = @@ -135,15 +137,29 @@ } $: fetchIntegrations() + + onMount(() => { + const urlParams = new URLSearchParams(window.location.search) + const action = urlParams.get("action") + if (action === "google_continue") { + continueGoogleSetup = true + externalDatasourceModal.show() + } + }) - - {#if integration?.auth?.type === "google"} - + { + continueGoogleSetup = false + }} +> + {#if integration?.auth?.type === "google" || continueGoogleSetup} + {:else} {/if} From 1e238ce69376987e13db2ac1fabfe281a0d7df52 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 31 May 2023 12:26:01 +0200 Subject: [PATCH 27/39] Validate google sheets url --- .../modals/GoogleDatasourceConfigModal.svelte | 40 +++++++++++++++++-- .../builder/app/[application]/data/new.svelte | 33 +++++++++------ .../server/src/integrations/googlesheets.ts | 2 +- 3 files changed, 57 insertions(+), 18 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte index 79fb0f6b5b..a0b0902480 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte @@ -4,9 +4,15 @@ import GoogleButton from "../_components/GoogleButton.svelte" import { organisation } from "stores/portal" 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 + let datasource = cloneDeep(integration) + $: isGoogleConfigured = !!$organisation.googleDatasourceConfigured onMount(async () => { @@ -22,13 +28,32 @@ let step = continueSetup ? GoogleDatasouceConfigStep.SET_URL : 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 + }, + }, + } {#if step === GoogleDatasouceConfigStep.AUTH} @@ -48,8 +73,15 @@ {/if} {/if} {#if step === GoogleDatasouceConfigStep.SET_URL} - - Add the URL of the sheet you want to connect + + Add the URL of the sheet you want to connect. + + (isValid = e.detail)} + /> {/if} diff --git a/packages/builder/src/pages/builder/app/[application]/data/new.svelte b/packages/builder/src/pages/builder/app/[application]/data/new.svelte index ed2e7f360d..536859d4f9 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/new.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/new.svelte @@ -131,21 +131,25 @@ return integrationsArray } - const fetchIntegrations = async () => { - const unsortedIntegrations = await API.getIntegrations() - integrations = sortIntegrations(unsortedIntegrations) - } - - $: fetchIntegrations() - + let isGoogleContinueAction onMount(() => { const urlParams = new URLSearchParams(window.location.search) const action = urlParams.get("action") - if (action === "google_continue") { - continueGoogleSetup = true - externalDatasourceModal.show() - } + + isGoogleContinueAction = action === "google_continue" }) + + const fetchIntegrations = async () => { + const unsortedIntegrations = await API.getIntegrations() + integrations = sortIntegrations(unsortedIntegrations) + console.log(integrations[IntegrationTypes.GOOGLE_SHEETS]) + + if (isGoogleContinueAction) { + handleIntegrationSelect(IntegrationTypes.GOOGLE_SHEETS) + } + } + + $: fetchIntegrations() @@ -158,8 +162,11 @@ continueGoogleSetup = false }} > - {#if integration?.auth?.type === "google" || continueGoogleSetup} - + {#if integration?.auth?.type === "google"} + {:else} {/if} diff --git a/packages/server/src/integrations/googlesheets.ts b/packages/server/src/integrations/googlesheets.ts index 8863aa0b3a..2598f6db62 100644 --- a/packages/server/src/integrations/googlesheets.ts +++ b/packages/server/src/integrations/googlesheets.ts @@ -72,7 +72,7 @@ const SCHEMA: Integration = { }, datasource: { spreadsheetId: { - display: "Google Sheet URL", + display: "Spreadsheet URL", type: DatasourceFieldType.STRING, required: true, }, From 25c921e3406eb653f3acf21fc5a6878bc945a05c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 31 May 2023 13:00:33 +0200 Subject: [PATCH 28/39] Validate url --- .../src/middleware/passport/datasource/google.ts | 2 +- .../modals/GoogleDatasourceConfigModal.svelte | 15 +++++++++++---- .../builder/app/[application]/data/new.svelte | 13 +++++-------- packages/server/src/api/controllers/datasource.ts | 3 ++- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/packages/backend-core/src/middleware/passport/datasource/google.ts b/packages/backend-core/src/middleware/passport/datasource/google.ts index 7f5e7f0d90..2f91e01d9a 100644 --- a/packages/backend-core/src/middleware/passport/datasource/google.ts +++ b/packages/backend-core/src/middleware/passport/datasource/google.ts @@ -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) } diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte index a0b0902480..f93f7b29da 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte @@ -1,5 +1,11 @@