Merge pull request #15745 from Budibase/BUDI-9127/autosave-auth-settings
Autosave rest authentication settings
This commit is contained in:
commit
59fe147863
|
@ -1,20 +1,29 @@
|
|||
<script>
|
||||
import RestAuthenticationBuilder from "./RestAuthenticationBuilder.svelte"
|
||||
import { cloneDeep } from "lodash/fp"
|
||||
import SaveDatasourceButton from "../SaveDatasourceButton.svelte"
|
||||
import Panel from "../Panel.svelte"
|
||||
import Tooltip from "../Tooltip.svelte"
|
||||
import { integrations } from "@/stores/builder"
|
||||
import { notifications } from "@budibase/bbui"
|
||||
|
||||
export let datasource
|
||||
$: updatedDatasource = cloneDeep(datasource)
|
||||
|
||||
const updateAuthConfigs = newAuthConfigs => {
|
||||
const updateAuthConfigs = async newAuthConfigs => {
|
||||
updatedDatasource.config.authConfigs = newAuthConfigs
|
||||
|
||||
try {
|
||||
await integrations.saveDatasource(updatedDatasource)
|
||||
notifications.success(
|
||||
`Datasource ${updatedDatasource.name} updated successfully`
|
||||
)
|
||||
} catch (error) {
|
||||
notifications.error(`Error saving datasource: ${error.message}`)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Panel>
|
||||
<SaveDatasourceButton slot="controls" {datasource} {updatedDatasource} />
|
||||
<Tooltip
|
||||
slot="tooltip"
|
||||
title="REST Authentication"
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<script>
|
||||
import { get } from "svelte/store"
|
||||
import { isEqual } from "lodash"
|
||||
import { integrationForDatasource } from "@/stores/selectors"
|
||||
import { integrations, datasources } from "@/stores/builder"
|
||||
import { integrations } from "@/stores/builder"
|
||||
import { notifications, Button } from "@budibase/bbui"
|
||||
|
||||
export let datasource
|
||||
|
@ -12,11 +10,7 @@
|
|||
|
||||
const save = async () => {
|
||||
try {
|
||||
const integration = integrationForDatasource(
|
||||
get(integrations),
|
||||
updatedDatasource
|
||||
)
|
||||
await datasources.save({ datasource: updatedDatasource, integration })
|
||||
await integrations.saveDatasource(updatedDatasource)
|
||||
notifications.success(
|
||||
`Datasource ${updatedDatasource.name} updated successfully`
|
||||
)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { writable, type Writable } from "svelte/store"
|
||||
import { get, writable, type Writable } from "svelte/store"
|
||||
import { API } from "@/api"
|
||||
import { Integration } from "@budibase/types"
|
||||
import { Datasource, Integration } from "@budibase/types"
|
||||
import { integrationForDatasource } from "@/stores/selectors"
|
||||
import { datasources } from "./datasources"
|
||||
|
||||
type IntegrationsState = Record<string, Integration>
|
||||
|
||||
|
@ -25,9 +27,15 @@ const createIntegrationsStore = () => {
|
|||
store.set(integrations)
|
||||
}
|
||||
|
||||
const saveDatasource = async (datasource: Datasource) => {
|
||||
const integration = integrationForDatasource(get(store), datasource)
|
||||
await datasources.save({ datasource, integration })
|
||||
}
|
||||
|
||||
return {
|
||||
...store,
|
||||
init,
|
||||
saveDatasource,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue