diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index f646c84d3d..df752cf6a1 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -9,6 +9,7 @@ const INITIAL_BACKEND_UI_STATE = { roles: [], datasources: [], queries: [], + integrations: {}, selectedDatabase: {}, selectedTable: {}, draftTable: {}, @@ -27,11 +28,15 @@ export const getBackendUiStore = () => { const datasources = await datasourcesResponse.json() const queriesResponse = await api.get(`/api/queries`) const queries = await queriesResponse.json() + const integrationsResponse = await api.get("/api/integrations") + const integrations = await integrationsResponse.json() + store.update(state => { state.selectedDatabase = db state.tables = tables state.datasources = datasources state.queries = queries + state.integrations = integrations return state }) }, @@ -132,6 +137,7 @@ export const getBackendUiStore = () => { state.selectedQueryId = json._id return state }) + return json }, select: queryId => store.update(state => { diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte index 29d7c0ffba..11beefff63 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte @@ -1,26 +1,33 @@ - - +{#if editable} + + +{/if} Query @@ -30,6 +34,7 @@ label="Query" mode="sql" on:change={updateQuery} + readOnly={!editable} value={query.fields.sql} /> {:else if schema.type === QueryTypes.JSON} @@ -37,8 +42,9 @@ label="Query" mode="json" on:change={updateQuery} + readOnly={!editable} value={query.fields.json} /> {:else if schema.type === QueryTypes.FIELDS} - + {/if} {/if} diff --git a/packages/builder/src/components/userInterface/TableViewSelect.svelte b/packages/builder/src/components/userInterface/TableViewSelect.svelte index a7f1f87a0e..e5adf611d6 100644 --- a/packages/builder/src/components/userInterface/TableViewSelect.svelte +++ b/packages/builder/src/components/userInterface/TableViewSelect.svelte @@ -5,6 +5,7 @@ import { notifier } from "builderStore/store/notifications" import BottomDrawer from "components/common/BottomDrawer.svelte" import ParameterBuilder from "components/integration/QueryParameterBuilder.svelte" + import IntegrationQueryEditor from "components/integration/index.svelte" import fetchBindableProperties from "../../builderStore/fetchBindableProperties" const dispatch = createEventDispatcher() @@ -13,18 +14,6 @@ export let value = {} - function handleSelected(selected) { - dispatch("change", selected) - dropdownRight.hide() - } - - function openBindingDrawer() { - bindingDrawerOpen = true - } - - function closeDatabindingDrawer() { - bindingDrawerOpen = false - } $: tables = $backendUiStore.tables.map(m => ({ label: m.name, @@ -78,6 +67,24 @@ type: "link", } }) + + function handleSelected(selected) { + dispatch("change", selected) + dropdownRight.hide() + } + + function openBindingDrawer() { + bindingDrawerOpen = true + } + + function closeDatabindingDrawer() { + bindingDrawerOpen = false + } + + function fetchDatasourceSchema(query) { + const source = $backendUiStore.datasources.find(ds => ds._id === query.datasourceId).source + return $backendUiStore.integrations[source].query[query.queryVerb][query.queryType]; + }
Save
-
{value.queryString}
- + + + {#if value.parameters.length > 0} + + {/if}
{/if} @@ -229,6 +243,8 @@ .drawer-contents { padding: var(--spacing-xl); + height: 40vh; + overflow-y: auto; } i { diff --git a/packages/builder/src/pages/[application]/data/datasource/[selectedDatasource]/[query]/index.svelte b/packages/builder/src/pages/[application]/data/datasource/[selectedDatasource]/[query]/index.svelte index bc2cae7537..760c2b322a 100644 --- a/packages/builder/src/pages/[application]/data/datasource/[selectedDatasource]/[query]/index.svelte +++ b/packages/builder/src/pages/[application]/data/datasource/[selectedDatasource]/[query]/index.svelte @@ -17,24 +17,33 @@ } } - $: { - if ($params.query !== "new") { - query = $backendUiStore.queries.find(query => query._id === $params.query) - } else { - // New query - query = { - datasourceId: $params.selectedDatasource, - name: "New Query", - parameters: [], - fields: {}, - } - } + $: selectedQuery = $backendUiStore.queries.find( + query => query._id === $backendUiStore.selectedQueryId + ) || { + datasourceId: $params.selectedDatasource, + name: "New Query", + parameters: [], + fields: {}, } + + // $: { + // if ($params.query !== "new") { + // query = $backendUiStore.queries.find(query => query._id === $params.query) + // } else { + // // New query + // query = { + // datasourceId: $params.selectedDatasource, + // name: "New Query", + // parameters: [], + // fields: {}, + // } + // } + // }
- {#if $backendUiStore.selectedDatabase._id && query} - + {#if $backendUiStore.selectedDatabase._id && selectedQuery} + {/if}