From 96f44c0a863569fbf8050f0bd460a38a1ff98488 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 5 Jun 2023 17:40:12 +0100 Subject: [PATCH] Reworking implementation to a single modal, that changes content rather than progressing to a new modal. --- .../modals/DatasourceConfigModal.svelte | 87 +++++++++++-------- .../modals/FetchTablesModal.svelte | 21 ----- packages/frontend-core/src/api/datasources.js | 11 +++ 3 files changed, 61 insertions(+), 58 deletions(-) delete mode 100644 packages/builder/src/components/backend/DatasourceNavigator/modals/FetchTablesModal.svelte diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte index 52051fe134..e9d23ff0c7 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte @@ -1,14 +1,7 @@ - - - - - datasourcePlus ? saveDatasource() : fetchTablesModal.show()} - confirmText={datasourcePlus ? "Connect" : "Save and continue to query"} - cancelText="Back" + {title} + onConfirm={() => nextStep()} + {confirmText} + cancelText={fetchTableStep ? "Cancel" : "Back"} showSecondaryButton={datasourcePlus} size="L" disabled={!isValid} > - - Connect your database to Budibase using the config below. - - - (isValid = e.detail)} - /> + {#if !fetchTableStep} + + Connect your database to Budibase using the config below. + + + (isValid = e.detail)} + /> + {:else} + Some stuff here + {/if} diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/FetchTablesModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/FetchTablesModal.svelte deleted file mode 100644 index 41a1f2d2d0..0000000000 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/FetchTablesModal.svelte +++ /dev/null @@ -1,21 +0,0 @@ - - - prevModal.show()} - confirmText="Continue" - cancelText="Back" - size="L" - disabled={selected.length === 0} -> - SOME TABLES HERE - diff --git a/packages/frontend-core/src/api/datasources.js b/packages/frontend-core/src/api/datasources.js index 16d19c512f..f7554f64b0 100644 --- a/packages/frontend-core/src/api/datasources.js +++ b/packages/frontend-core/src/api/datasources.js @@ -69,4 +69,15 @@ export const buildDatasourceEndpoints = API => ({ body: { datasource }, }) }, + + /** + * Fetch table names available within the datasource, for filtering out undesired tables + * @param datasource the datasource configuration to use for fetching tables + */ + fetchTablesForDatasource: async datasource => { + return await API.post({ + url: `/api/datasources/tables`, + body: { datasource }, + }) + }, })