Budibase is an open-source low-code platform for creating internal apps in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s 🚀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

59 lines
1.4 KiB

<script>
import { datasources } from "stores/backend"
import { notifications } from "@budibase/bbui"
import { Input, ModalContent, Modal } from "@budibase/bbui"
import analytics from "analytics"
let error = ""
let modal
let name
export let datasource
export let onCancel = undefined
export const show = () => {
name = datasource?.name
modal.show()
}
export const hide = () => {
modal.hide()
}
function checkValid(evt) {
const datasourceName = evt.target.value
if ($datasources?.list.some(ds => ds.name === datasourceName)) {
error = `Datasource with name ${datasourceName} already exists. Please choose another name.`
return
}
error = ""
}
async function updateDatasource() {
const updatedDatasource = {
...datasource,
name,
}
await datasources.save(updatedDatasource)
notifications.success(`Datasource ${name} updated successfully.`)
analytics.captureEvent("Datasource Updated", updatedDatasource)
hide()
}
</script>
<Modal bind:this={modal} on:hide={onCancel}>
<ModalContent
title="Edit Datasource"
size="L"
confirmText="Save"
onConfirm={updateDatasource}
disabled={error || !name || !datasource?.type}
>
<Input
data-cy="datasource-name-input"
label="Datasource Name"
on:input={checkValid}
bind:value={name}
{error}
/>
</ModalContent>
</Modal>