2021-09-24 08:47:22 +12:00
|
|
|
<script>
|
2021-09-24 21:19:48 +12:00
|
|
|
import { goto } from "@roxi/routify"
|
2021-09-24 22:28:56 +12:00
|
|
|
import { ModalContent, notifications, Body, Layout } from "@budibase/bbui"
|
2021-09-24 08:47:22 +12:00
|
|
|
import IntegrationConfigForm from "components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte"
|
2021-12-07 06:39:51 +13:00
|
|
|
import { IntegrationNames } from "constants/backend"
|
2021-10-07 03:06:48 +13:00
|
|
|
import cloneDeep from "lodash/cloneDeepWith"
|
2021-12-01 05:21:16 +13:00
|
|
|
import { saveDatasource as save } from "builderStore/datasource"
|
2021-09-24 08:47:22 +12:00
|
|
|
|
|
|
|
export let integration
|
2021-10-07 03:06:48 +13:00
|
|
|
export let modal
|
|
|
|
|
|
|
|
// kill the reference so the input isn't saved
|
2021-12-01 06:56:15 +13:00
|
|
|
let datasource = cloneDeep(integration)
|
2021-09-24 21:19:48 +12:00
|
|
|
|
2021-09-24 08:47:22 +12:00
|
|
|
async function saveDatasource() {
|
|
|
|
try {
|
2021-12-01 06:56:15 +13:00
|
|
|
const resp = await save(datasource)
|
2021-09-27 22:04:01 +13:00
|
|
|
$goto(`./datasource/${resp._id}`)
|
2021-09-24 08:47:22 +12:00
|
|
|
notifications.success(`Datasource updated successfully.`)
|
|
|
|
} catch (err) {
|
|
|
|
notifications.error(`Error saving datasource: ${err}`)
|
2021-09-24 21:01:53 +12:00
|
|
|
}
|
|
|
|
}
|
2021-09-24 08:47:22 +12:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<ModalContent
|
2021-12-01 06:56:15 +13:00
|
|
|
title={`Connect to ${IntegrationNames[datasource.type]}`}
|
2021-09-24 08:47:22 +12:00
|
|
|
onConfirm={() => saveDatasource()}
|
2021-10-07 03:06:48 +13:00
|
|
|
onCancel={() => modal.show()}
|
2021-12-01 06:56:15 +13:00
|
|
|
confirmText={datasource.plus
|
2021-09-24 21:01:53 +12:00
|
|
|
? "Fetch tables from database"
|
|
|
|
: "Save and continue to query"}
|
|
|
|
cancelText="Back"
|
2021-10-13 04:13:54 +13:00
|
|
|
size="L"
|
2021-09-24 08:47:22 +12:00
|
|
|
>
|
2021-09-24 22:28:56 +12:00
|
|
|
<Layout noPadding>
|
|
|
|
<Body size="XS"
|
|
|
|
>Connect your database to Budibase using the config below.
|
|
|
|
</Body>
|
|
|
|
</Layout>
|
|
|
|
|
2021-12-01 05:21:16 +13:00
|
|
|
<IntegrationConfigForm
|
2021-12-01 06:56:15 +13:00
|
|
|
schema={datasource.schema}
|
|
|
|
bind:datasource
|
2021-12-01 05:21:16 +13:00
|
|
|
creating={true}
|
|
|
|
/>
|
2021-09-24 08:47:22 +12:00
|
|
|
</ModalContent>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
</style>
|