From 9037ab86d54447c70e2b33bf6e67bcddd3f6100d Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 10 Mar 2023 18:46:48 +0000 Subject: [PATCH] Adding an error for XLSX type sheets not working, adding the sheets URL as an option for google config (should be added to redirect URL) and fixing some error states. --- .../CreateExternalTableModal.svelte | 4 +++- .../modals/GoogleDatasourceConfigModal.svelte | 7 +++---- .../builder/portal/settings/auth/index.svelte | 17 +++++++++++++++-- .../server/src/integrations/googlesheets.ts | 7 ++++++- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/CreateExternalTableModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/CreateExternalTableModal.svelte index 45269a365c..664b5629d4 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/CreateExternalTableModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/CreateExternalTableModal.svelte @@ -35,7 +35,9 @@ await datasources.fetch() $goto(`../../table/${table._id}`) } catch (error) { - notifications.error("Error saving table") + notifications.error( + `Error saving table - ${error?.message || "unknown error"}` + ) } } diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte index 8e03a6e1d1..c12ddab78d 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte @@ -4,7 +4,7 @@ import cloneDeep from "lodash/cloneDeepWith" import GoogleButton from "../_components/GoogleButton.svelte" import { saveDatasource as save } from "builderStore/datasource" - import { API } from "api" + import { organisation } from "stores/portal" import { onMount } from "svelte" export let integration @@ -12,11 +12,10 @@ // kill the reference so the input isn't saved let datasource = cloneDeep(integration) - let isGoogleConfigured + $: isGoogleConfigured = !!$organisation.google onMount(async () => { - const config = await API.getTenantConfig() - isGoogleConfigured = !!config?.config.google + await organisation.init() }) 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 0e82dd31e7..2d4dc7ee46 100644 --- a/packages/builder/src/pages/builder/portal/settings/auth/index.svelte +++ b/packages/builder/src/pages/builder/portal/settings/auth/index.svelte @@ -47,8 +47,9 @@ $: googleCallbackTooltip = $admin.cloud ? null : googleCallbackReadonly - ? "Vist the organisation page to update the platform URL" + ? "Visit the organisation page to update the platform URL" : "Leave blank to use the default callback URL" + $: googleSheetsCallbackUrl = `${$organisation.platformUrl}/api/global/auth/datasource/google/callback` $: GoogleConfigFields = { Google: [ @@ -62,6 +63,14 @@ placeholder: $organisation.googleCallbackUrl, copyButton: true, }, + { + name: "sheetsURL", + label: "Sheets URL", + readonly: googleCallbackReadonly, + tooltip: googleCallbackTooltip, + placeholder: googleSheetsCallbackUrl, + copyButton: true, + }, ], } @@ -396,7 +405,11 @@ To allow users to authenticate using their Google accounts, fill out the - fields below. + fields below. Read the documentation for more information. diff --git a/packages/server/src/integrations/googlesheets.ts b/packages/server/src/integrations/googlesheets.ts index 0c658df0f5..3c2d8cda5b 100644 --- a/packages/server/src/integrations/googlesheets.ts +++ b/packages/server/src/integrations/googlesheets.ts @@ -199,7 +199,12 @@ class GoogleSheetsIntegration implements DatasourcePlus { this.client.useOAuth2Client(oauthClient) await this.client.loadInfo() - } catch (err) { + } catch (err: any) { + // this happens for xlsx imports + if (err.message?.includes("operation is not supported")) { + err.message = + "This operation is not supported - XLSX sheets must be converted." + } console.error("Error connecting to google sheets", err) throw err }