From 1606ca0c84949fbb8194d1f5e98ca8e5b63c1846 Mon Sep 17 00:00:00 2001 From: Gerard Burns Date: Mon, 26 Jun 2023 09:52:02 +0100 Subject: [PATCH] Refactor Datasource Creation Modal (#10783) --- .../src/FancyForm/FancyCheckboxGroup.svelte | 3 +- packages/builder/package.json | 3 +- .../_components/DatasourceCard.svelte | 60 ----- .../_components/GoogleSignIn.svelte | 145 ------------ .../modals/GoogleDatasourceConfigModal.svelte | 207 ------------------ .../DatasourceConfigEditor/ConfigInput.svelte | 40 ++++ .../fields/Boolean.svelte | 20 ++ .../fields/FieldGroup.svelte | 47 ++++ .../fields/LongForm.svelte | 22 ++ .../fields/Object.svelte | 37 ++++ .../fields/String.svelte | 39 ++++ .../DatasourceConfigEditor/index.svelte | 114 ++++++++++ .../DatasourceConfigEditor/stores/config.js | 26 +++ .../stores/validatedConfig.js | 40 ++++ .../stores/validation.js | 95 ++++++++ .../GoogleAuthPrompt.svelte | 31 +++ .../GoogleButton.svelte | 0 .../TableImportSelection/index.svelte | 62 ++++++ .../tableSelectionStore.js | 64 ++++++ .../index.svelte | 76 +++++++ .../stores/datasourceCreation.js | 92 ++++++++ .../stores/datasourceCreation.test.js | 116 ++++++++++ .../stores/onGoogleAuth.js | 24 ++ .../stores/onGoogleAuth.test.js | 70 ++++++ .../CreateInternalTableModal.svelte | 22 ++ .../builder/app/[application]/data/new.svelte | 183 +++------------- .../builder/src/stores/backend/datasources.js | 97 ++++++-- packages/builder/src/stores/backend/index.js | 3 +- .../src/stores/backend/integrations.js | 12 +- .../src/stores/backend/sortedIntegrations.js | 39 ++++ .../stores/backend/sortedIntegrations.test.js | 127 +++++++++++ packages/builder/src/stores/selectors.js | 35 +++ packages/builder/src/stores/selectors.test.js | 56 +++++ 33 files changed, 1418 insertions(+), 589 deletions(-) delete mode 100644 packages/builder/src/components/backend/DatasourceNavigator/_components/DatasourceCard.svelte delete mode 100644 packages/builder/src/components/backend/DatasourceNavigator/_components/GoogleSignIn.svelte delete mode 100644 packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/ConfigInput.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/fields/Boolean.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/fields/FieldGroup.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/fields/LongForm.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/fields/Object.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/fields/String.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/index.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/stores/config.js create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/stores/validatedConfig.js create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/stores/validation.js create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/GoogleAuthPrompt.svelte rename packages/builder/src/{components/backend/DatasourceNavigator/_components => pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal}/GoogleButton.svelte (100%) create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/TableImportSelection/index.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/TableImportSelection/tableSelectionStore.js create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/index.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/stores/datasourceCreation.js create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/stores/datasourceCreation.test.js create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/stores/onGoogleAuth.js create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/stores/onGoogleAuth.test.js create mode 100644 packages/builder/src/pages/builder/app/[application]/data/_components/CreateInternalTableModal.svelte create mode 100644 packages/builder/src/stores/backend/sortedIntegrations.js create mode 100644 packages/builder/src/stores/backend/sortedIntegrations.test.js create mode 100644 packages/builder/src/stores/selectors.js create mode 100644 packages/builder/src/stores/selectors.test.js diff --git a/packages/bbui/src/FancyForm/FancyCheckboxGroup.svelte b/packages/bbui/src/FancyForm/FancyCheckboxGroup.svelte index aaea388c36..ca3a6d937a 100644 --- a/packages/bbui/src/FancyForm/FancyCheckboxGroup.svelte +++ b/packages/bbui/src/FancyForm/FancyCheckboxGroup.svelte @@ -12,7 +12,6 @@ const dispatch = createEventDispatcher() $: updateSelected(selectedBooleans) - $: dispatch("change", selected) $: allSelected = selected?.length === options.length $: noneSelected = !selected?.length @@ -28,6 +27,7 @@ } } selected = array + dispatch("change", selected) } function toggleSelectAll() { @@ -36,6 +36,7 @@ } else { selectedBooleans = reset() } + dispatch("change", selected) } diff --git a/packages/builder/package.json b/packages/builder/package.json index a2567dc638..646bb144df 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -9,7 +9,8 @@ "dev:builder": "routify -c dev:vite", "dev:vite": "vite --host 0.0.0.0", "rollup": "rollup -c -w", - "test": "vitest run" + "test": "vitest run", + "test:watch": "vitest" }, "jest": { "globals": { diff --git a/packages/builder/src/components/backend/DatasourceNavigator/_components/DatasourceCard.svelte b/packages/builder/src/components/backend/DatasourceNavigator/_components/DatasourceCard.svelte deleted file mode 100644 index 67ecf1c56c..0000000000 --- a/packages/builder/src/components/backend/DatasourceNavigator/_components/DatasourceCard.svelte +++ /dev/null @@ -1,60 +0,0 @@ - - -
dispatcher("selected", integrationType)} - class="item hoverable" -> -
- -
- {schema.friendlyName} - {#if schema.type} - {schema.type || ""} - {/if} -
-
-
- - diff --git a/packages/builder/src/components/backend/DatasourceNavigator/_components/GoogleSignIn.svelte b/packages/builder/src/components/backend/DatasourceNavigator/_components/GoogleSignIn.svelte deleted file mode 100644 index c30e8fc2ee..0000000000 --- a/packages/builder/src/components/backend/DatasourceNavigator/_components/GoogleSignIn.svelte +++ /dev/null @@ -1,145 +0,0 @@ - - - - - btn_google_dark_normal_ios - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte deleted file mode 100644 index 14f81f915c..0000000000 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/GoogleDatasourceConfigModal.svelte +++ /dev/null @@ -1,207 +0,0 @@ - - - - {#if step === GoogleDatasouceConfigStep.AUTH} - - {#if isGoogleConfigured === true} - - Authenticate with your google account to use the {integrationName} integration. - - - {:else if isGoogleConfigured === false} - 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. - - (isValid = e.detail)} - /> - - {/if} - {#if step === GoogleDatasouceConfigStep.SET_SHEETS} - - Select which spreadsheets you want to connect. - - - - {#if setSheetsErrorTitle || setSheetsErrorMessage} - - {/if} - - {/if} - diff --git a/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/ConfigInput.svelte b/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/ConfigInput.svelte new file mode 100644 index 0000000000..37fd579594 --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/ConfigInput.svelte @@ -0,0 +1,40 @@ + + + diff --git a/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/fields/Boolean.svelte b/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/fields/Boolean.svelte new file mode 100644 index 0000000000..daa4b7a2f9 --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/fields/Boolean.svelte @@ -0,0 +1,20 @@ + + +
+ + +
+ + diff --git a/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/fields/FieldGroup.svelte b/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/fields/FieldGroup.svelte new file mode 100644 index 0000000000..a83929663b --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/fields/FieldGroup.svelte @@ -0,0 +1,47 @@ + + + !!properties.value)} + header={name} +> + + {#each value as field} +
+ + handleChange(field.key, e.detail)} + value={field.value} + /> +
+ {/each} +
+
+ + diff --git a/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/fields/LongForm.svelte b/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/fields/LongForm.svelte new file mode 100644 index 0000000000..efbeb007e8 --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/DatasourceConfigEditor/fields/LongForm.svelte @@ -0,0 +1,22 @@ + + +
+ +