diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte
index e4e9f2035f..63fe4932f3 100644
--- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte
+++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte
@@ -11,7 +11,7 @@
import { capitalise } from "helpers"
import { IntegrationTypes } from "constants"
- export let integration
+ export let datasource
export let schema
export let creating
@@ -20,13 +20,13 @@
return false
}
return !(
- (integration.source === IntegrationTypes.REST &&
+ (datasource.source === IntegrationTypes.REST &&
key === "defaultHeaders") ||
value.deprecated
)
}
- $: config = integration.config
+ $: config = datasource?.config
$: configKeys = Object.entries(schema || {})
.filter(el => filter(el))
.map(([key]) => key)
@@ -39,7 +39,7 @@
{#if !creating}
-
+
{/if}
{#each configKeys as configKey}
@@ -54,6 +54,7 @@
bind:this={addButton}
defaults={schema[configKey].default}
bind:object={config[configKey]}
+ on:change
noAddButton={true}
/>
{:else if schema[configKey].type === "boolean"}
diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte
index 4721d403bc..1b20091fbf 100644
--- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte
+++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte
@@ -121,7 +121,6 @@
@@ -161,9 +160,7 @@
Relationships
Define existing relationship
diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/RestExtraConfigForm.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/RestExtraConfigForm.svelte
index 2805e38c99..e5d220d0b6 100644
--- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/RestExtraConfigForm.svelte
+++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/RestExtraConfigForm.svelte
@@ -1,5 +1,5 @@
saveDatasource()}
onCancel={() => modal.show()}
- confirmText={config.plus
+ confirmText={datasource.plus
? "Fetch tables from database"
: "Save and continue to query"}
cancelText="Back"
@@ -40,8 +40,8 @@
diff --git a/packages/builder/src/components/integration/KeyValueBuilder.svelte b/packages/builder/src/components/integration/KeyValueBuilder.svelte
index 04ab56103e..8f66252a3c 100644
--- a/packages/builder/src/components/integration/KeyValueBuilder.svelte
+++ b/packages/builder/src/components/integration/KeyValueBuilder.svelte
@@ -1,5 +1,8 @@
{#each fields as field, idx}
-
-
+
+
{#if !readOnly}
deleteEntry(idx)} />
{/if}
diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/index.svelte
index c891452820..97e1518c8e 100644
--- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/index.svelte
+++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/index.svelte
@@ -7,6 +7,7 @@
Divider,
Layout,
notifications,
+ ActionButton,
} from "@budibase/bbui"
import { datasources, integrations, queries, tables } from "stores/backend"
import IntegrationConfigForm from "components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte"
@@ -15,9 +16,28 @@
import ICONS from "components/backend/DatasourceNavigator/icons"
import { IntegrationTypes } from "constants"
import { capitalise } from "helpers"
+ import { isEqual } from "lodash"
+ import { cloneDeep } from "lodash/fp"
+
+ let baseDatasource, changed
$: datasource = $datasources.list.find(ds => ds._id === $datasources.selected)
$: integration = datasource && $integrations[datasource.source]
+ $: {
+ if (
+ datasource &&
+ (!baseDatasource || baseDatasource.source !== datasource.source)
+ ) {
+ baseDatasource = cloneDeep(datasource)
+ }
+ }
+ $: hasChanged(baseDatasource, datasource)
+
+ function hasChanged(base, ds) {
+ if (base) {
+ changed = !isEqual(base, ds)
+ }
+ }
async function saveDatasource() {
try {
@@ -28,6 +48,7 @@
}
await datasources.fetch()
notifications.success(`Datasource ${name} updated successfully.`)
+ baseDatasource = cloneDeep(datasource)
} catch (err) {
notifications.error(`Error saving datasource: ${err}`)
}
@@ -49,7 +70,7 @@
height="26"
width="26"
/>
- {datasource.name}
+ {baseDatasource.name}
{integration.description}
@@ -57,14 +78,16 @@
Connect your data source to Budibase using the config below.
{#if datasource.plus}
@@ -73,7 +96,9 @@
{#each $queries.list.filter(query => query.datasourceId === datasource._id) as query}
@@ -85,7 +110,7 @@
{/each}
{#if datasource?.source === IntegrationTypes.REST}
-
+
{/if}
diff --git a/packages/server/src/integrations/rest.ts b/packages/server/src/integrations/rest.ts
index 5107325d7c..b3026e9153 100644
--- a/packages/server/src/integrations/rest.ts
+++ b/packages/server/src/integrations/rest.ts
@@ -153,7 +153,12 @@ module RestModule {
}
getUrl(path: string, queryString: string): string {
- return `${this.config.url}/${path}?${queryString}`
+ const main = `${path}?${queryString}`
+ if (!this.config.url) {
+ return main
+ } else {
+ return `${this.config.url}/${main}`
+ }
}
async create({ path = "", queryString = "", headers = {}, json = {} }) {