From 4387eb2a674e16f6e0329f7d428ccc7972453d82 Mon Sep 17 00:00:00 2001 From: Gerard Burns Date: Tue, 27 Jun 2023 14:16:55 +0100 Subject: [PATCH 1/4] Update datasource config to use tabs --- .../buttons/ExistingRelationshipButton.svelte | 54 ++-- .../PlusConfigForm.svelte | 249 ------------------ .../TableIntegrationMenu/index.svelte | 86 ------ .../rest/RestExtraConfigForm.svelte | 137 ---------- .../CreateEditRelationshipModal.svelte | 66 +++++ .../index.svelte | 2 +- .../Authentication}/AuthTypeRenderer.svelte | 0 .../RestAuthenticationBuilder.svelte | 27 +- .../RestAuthenticationModal.svelte | 0 .../panels/Authentication}/authTypes.js | 0 .../panels/Authentication/index.svelte | 27 ++ .../_components/panels/Headers.svelte | 53 ++++ .../_components/panels/Panel.svelte | 27 ++ .../panels/Queries/RestImportButton.svelte | 21 ++ .../Queries/RestImportQueriesModal.svelte | 132 ++++++++++ .../_components/panels/Queries/index.svelte | 43 +++ .../_components/panels/Relationships.svelte | 108 ++++++++ .../panels/SaveDatasourceButton.svelte | 29 ++ .../_components/panels/Tables/Controls.svelte | 71 +++++ .../Tables}/CreateExternalTableModal.svelte | 0 .../_components/panels/Tables/index.svelte | 33 +++ .../_components/panels/Tooltip.svelte | 30 +++ .../Variables}/ViewDynamicVariables.svelte | 7 +- .../_components/panels/Variables/index.svelte | 59 +++++ .../datasource/[datasourceId]/index.svelte | 249 ++++++------------ .../builder/src/stores/backend/datasources.js | 5 +- 26 files changed, 829 insertions(+), 686 deletions(-) delete mode 100644 packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte delete mode 100644 packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte delete mode 100644 packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/RestExtraConfigForm.svelte create mode 100644 packages/builder/src/components/backend/Datasources/CreateEditRelationshipModal.svelte rename packages/builder/src/{components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth => pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication}/AuthTypeRenderer.svelte (100%) rename packages/builder/src/{components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth => pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication}/RestAuthenticationBuilder.svelte (69%) rename packages/builder/src/{components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth => pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication}/RestAuthenticationModal.svelte (100%) rename packages/builder/src/{components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth => pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication}/authTypes.js (100%) create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/index.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Headers.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Panel.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportButton.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportQueriesModal.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/index.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Relationships.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/SaveDatasourceButton.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Tables/Controls.svelte rename packages/builder/src/{components/backend/DatasourceNavigator/TableIntegrationMenu => pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Tables}/CreateExternalTableModal.svelte (100%) create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Tables/index.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Tooltip.svelte rename packages/builder/src/{components/backend/DatasourceNavigator/TableIntegrationMenu/rest/variables => pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Variables}/ViewDynamicVariables.svelte (87%) create mode 100644 packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Variables/index.svelte diff --git a/packages/builder/src/components/backend/DataTable/buttons/ExistingRelationshipButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/ExistingRelationshipButton.svelte index aa666ea8d6..d0b0d9e68c 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/ExistingRelationshipButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/ExistingRelationshipButton.svelte @@ -1,18 +1,14 @@ {#if datasource}
- + modal.show({ fromTable: table })} + > Define relationship
- - - + {/if} diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte deleted file mode 100644 index 36fb34143a..0000000000 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte +++ /dev/null @@ -1,249 +0,0 @@ - - - - - - - - - - - confirmDialog.hide()} - warning={false} - title="Confirm table fetch" -> - - If you have fetched tables from this database before, this action may - overwrite any changes you made after your initial fetch. - -
-
- -
-
- - -
- Tables -
- - -
-
- - This datasource can determine tables automatically. Budibase can fetch your - tables directly from the database and you can use them without having to write - any queries at all. - -{#if schemaError} - -{/if} -{#if plusTables && Object.values(plusTables).length > 0} - onClickTable(detail)} - schema={tableSchema} - data={Object.values(plusTables)} - allowEditColumns={false} - allowEditRows={false} - allowSelectRows={false} - customRenderers={[{ column: "primary", component: ArrayRenderer }]} - /> -{:else} - No tables found. -{/if} -{#if integration.relationships !== false} - -
- Relationships - -
- - Tell budibase how your tables are related to get even more smart features. - - {#if relationshipInfo && relationshipInfo.length > 0} -
openRelationshipModal(detail.from, detail.to)} - schema={relationshipSchema} - data={relationshipInfo} - allowEditColumns={false} - allowEditRows={false} - allowSelectRows={false} - /> - {:else} - No relationships configured. - {/if} -{/if} - - diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte deleted file mode 100644 index 9277207e37..0000000000 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte +++ /dev/null @@ -1,86 +0,0 @@ - - -
-
- {#each Object.entries(integrations) as [integrationType, schema]} -
selectIntegration(integrationType)} - > - - {schema.name || integrationType} -
- {/each} -
-
- - diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/RestExtraConfigForm.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/RestExtraConfigForm.svelte deleted file mode 100644 index fc495ec3f2..0000000000 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/RestExtraConfigForm.svelte +++ /dev/null @@ -1,137 +0,0 @@ - - - -
-
- Headers - Optional -
-
- -
-
- - Headers enable you to provide additional information about the request, such - as format. - - onDefaultHeaderUpdate(evt.detail)} - noAddButton - bindings={getRestBindings()} -/> -
- addHeader.addEntry()}> - Add header - -
- - -
-
- Authentication - Optional -
-
- -
-
- - Create an authentication config that can be shared with queries. - - - - -
-
- Variables - Optional -
-
- -
-
-Variables enable you to store and re-use values in queries, with the choice - of a static value such as a token using static variables, or a value from a - query response using dynamic variables. -Static - - - -
-Dynamic - - Dynamic variables are evaluated when a dependant query is executed. The value - is cached for a period of time and will be refreshed if a query fails. - - - - diff --git a/packages/builder/src/components/backend/Datasources/CreateEditRelationshipModal.svelte b/packages/builder/src/components/backend/Datasources/CreateEditRelationshipModal.svelte new file mode 100644 index 0000000000..03683bcfc9 --- /dev/null +++ b/packages/builder/src/components/backend/Datasources/CreateEditRelationshipModal.svelte @@ -0,0 +1,66 @@ + + + + + + + diff --git a/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/index.svelte index 9dfe18a407..59ea8ce1d1 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/_components/CreateExternalDatasourceModal/index.svelte @@ -33,7 +33,7 @@ // A REST integration is created immediately, we don't need to display a config modal. loading = true datasources - .create({ integration, fields: configFromIntegration(integration) }) + .create({ integration, config: configFromIntegration(integration) }) .then(datasource => { store.setIntegration(integration) store.setDatasource(datasource) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/AuthTypeRenderer.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/AuthTypeRenderer.svelte similarity index 100% rename from packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/AuthTypeRenderer.svelte rename to packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/AuthTypeRenderer.svelte diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/RestAuthenticationBuilder.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationBuilder.svelte similarity index 69% rename from packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/RestAuthenticationBuilder.svelte rename to packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationBuilder.svelte index 92f1269a82..c94cbbf81c 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/RestAuthenticationBuilder.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationBuilder.svelte @@ -3,9 +3,11 @@ import AuthTypeRenderer from "./AuthTypeRenderer.svelte" import RestAuthenticationModal from "./RestAuthenticationModal.svelte" import { Helpers } from "@budibase/bbui" + import { createEventDispatcher } from "svelte" - export let configs = [] + export let authConfigs = [] + const dispatch = createEventDispatcher() let currentConfig = null let modal @@ -20,8 +22,10 @@ } const onConfirm = config => { + let newAuthConfigs + if (currentConfig) { - configs = configs.map(c => { + newAuthConfigs = authConfigs.map(c => { // replace the current config with the new one if (c._id === currentConfig._id) { return config @@ -30,27 +34,36 @@ }) } else { config._id = Helpers.uuid() - configs = [...configs, config] + newAuthConfigs = [...authConfigs, config] } + + dispatch("change", newAuthConfigs) } const onRemove = () => { - configs = configs.filter(c => { + const newAuthConfigs = authConfigs.filter(c => { return c._id !== currentConfig._id }) + + dispatch("change", newAuthConfigs) } - + - {#if configs && configs.length > 0} + {#if authConfigs && authConfigs.length > 0}
openConfigModal(detail)} {schema} - data={configs} + data={authConfigs} allowEditColumns={false} allowEditRows={false} allowSelectRows={false} diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/RestAuthenticationModal.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationModal.svelte similarity index 100% rename from packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/RestAuthenticationModal.svelte rename to packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/RestAuthenticationModal.svelte diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/authTypes.js b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/authTypes.js similarity index 100% rename from packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/rest/auth/authTypes.js rename to packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/authTypes.js diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/index.svelte new file mode 100644 index 0000000000..439ef961ed --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Authentication/index.svelte @@ -0,0 +1,27 @@ + + + + + + updateAuthConfigs(detail)} + authConfigs={updatedDatasource.config.authConfigs} + /> + diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Headers.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Headers.svelte new file mode 100644 index 0000000000..221547309b --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Headers.svelte @@ -0,0 +1,53 @@ + + + + + + onDefaultHeaderUpdate(evt.detail)} + noAddButton + bindings={restBindings} + /> +
+ addHeader.addEntry()}> + Add header + +
+
diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Panel.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Panel.svelte new file mode 100644 index 0000000000..4ef602bffb --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Panel.svelte @@ -0,0 +1,27 @@ + + +
+
+
+ +
+
+ +
+
+
+ +
+
+ + diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportButton.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportButton.svelte new file mode 100644 index 0000000000..682284adca --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportButton.svelte @@ -0,0 +1,21 @@ + + + + + + +
+ +
+ + diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportQueriesModal.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportQueriesModal.svelte new file mode 100644 index 0000000000..82a2aa8066 --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[datasourceId]/_components/panels/Queries/RestImportQueriesModal.svelte @@ -0,0 +1,132 @@ + + + importQueries()} + {onCancel} + confirmText={"Import"} + cancelText="Back" + size="L" +> + + Import + Import your rest collection using one of the options below + + + + + { + $data.file = e.detail?.[0] + lastTouched = "file" + }} + fileTags={[ + "OpenAPI 3.0", + "OpenAPI 2.0", + "Swagger 2.0", + "cURL", + "YAML", + "JSON", + ]} + maximum={1} + /> + + +