replace use of datasources.save with datasources.update

This commit is contained in:
Gerard Burns 2023-06-26 14:15:04 +01:00
parent f3d5e2b4a0
commit 88582b871e
5 changed files with 20 additions and 18 deletions

View File

@ -1,8 +1,10 @@
<script> <script>
import { get } from "svelte/store"
import { ActionButton, Modal, notifications } from "@budibase/bbui" import { ActionButton, Modal, notifications } from "@budibase/bbui"
import CreateEditRelationship from "../../Datasources/CreateEditRelationship.svelte" import CreateEditRelationship from "../../Datasources/CreateEditRelationship.svelte"
import { datasources } from "../../../../stores/backend" import { datasources, integrations } from "../../../../stores/backend"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
import { integrationForDatasource } from "stores/selectors"
export let table export let table
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
@ -27,7 +29,10 @@
async function saveRelationship() { async function saveRelationship() {
try { try {
// Create datasource // Create datasource
await datasources.save(datasource) await datasources.update({
datasource,
integration: integrationForDatasource(get(integrations), datasource),
})
notifications.success(`Relationship information saved.`) notifications.success(`Relationship information saved.`)
dispatch("updatecolumns") dispatch("updatecolumns")
} catch (err) { } catch (err) {

View File

@ -1,7 +1,9 @@
<script> <script>
import { datasources } from "stores/backend" import { get } from "svelte/store"
import { datasources, integrations } from "stores/backend"
import { notifications } from "@budibase/bbui" import { notifications } from "@budibase/bbui"
import { Input, ModalContent, Modal } from "@budibase/bbui" import { Input, ModalContent, Modal } from "@budibase/bbui"
import { integrationForDatasource } from "stores/selectors"
let error = "" let error = ""
let modal let modal
@ -32,7 +34,10 @@
...datasource, ...datasource,
name, name,
} }
await datasources.save(updatedDatasource) await datasources.update({
datasource: updatedDatasource,
integration: integrationForDatasource(get(integrations), datasource),
})
notifications.success(`Datasource ${name} updated successfully.`) notifications.success(`Datasource ${name} updated successfully.`)
hide() hide()
} }

View File

@ -176,7 +176,10 @@
notifications.success(`Request saved successfully`) notifications.success(`Request saved successfully`)
if (dynamicVariables) { if (dynamicVariables) {
datasource.config.dynamicVariables = rebuildVariables(saveId) datasource.config.dynamicVariables = rebuildVariables(saveId)
datasource = await datasources.save(datasource) datasource = await datasources.update({
integration: integrationInfo,
datasource,
})
} }
prettifyQueryRequestBody( prettifyQueryRequestBody(
query, query,

View File

@ -50,7 +50,7 @@
const saveDatasource = async () => { const saveDatasource = async () => {
try { try {
// Create datasource // Create datasource
await datasources.save(datasource) await datasources.update({ datasource, integration })
if (datasource?.plus) { if (datasource?.plus) {
await tables.fetch() await tables.fetch()
} }

View File

@ -122,6 +122,7 @@ export function createDatasourcesStore() {
} }
const update = async ({ integration, datasource }) => { const update = async ({ integration, datasource }) => {
console.log(integration, datasource)
if (await isDatasourceInvalid(integration, datasource)) { if (await isDatasourceInvalid(integration, datasource)) {
throw new Error("Unable to connect") throw new Error("Unable to connect")
} }
@ -131,17 +132,6 @@ export function createDatasourcesStore() {
return updateDatasource(response) return updateDatasource(response)
} }
// TODO deprecate
const save = async datasource => {
if (await isDatasourceInvalid(datasource)) {
throw new Error("Unable to connect")
}
const response = await API.updateDatasource(datasource)
return updateDatasource(response)
}
const deleteDatasource = async datasource => { const deleteDatasource = async datasource => {
await API.deleteDatasource({ await API.deleteDatasource({
datasourceId: datasource?._id, datasourceId: datasource?._id,
@ -213,7 +203,6 @@ export function createDatasourcesStore() {
updateSchema, updateSchema,
create, create,
update, update,
save,
delete: deleteDatasource, delete: deleteDatasource,
removeSchemaError, removeSchemaError,
replaceDatasource, replaceDatasource,