Files
windmill/frontend/src/lib/components/triggers/postgres/CheckPostgresRequirement.svelte
T
dieriba 57cfa4045b feat: add postgres trigger captures (#5165)
* feat: 🚧 add postgres trigger config in back

* feat: add capture section for postgres

* feat: update postgres trigger panel, update capture migration

* fix: ci and casing style

* feat: capture done

* fix: update sqlx

* fix: remove unused

* feat: handle persisting data

* fix: add feature flag

* feat: capture done

* fix: feature flag

* feat: capture done

* nits: add plus into postgres capture label

* feat: trigger done

* Update PostgresTriggerEditorInner.svelte

* Update script_helpers.ts

* nit

* chore: update to meet pr comment requirement

* refactor:

* fix:

* fix: miss closing curly braces

* fix:

* fix: ci

* Update mod.rs

* polishing postgres trigger

* update minor changes on UI

* nits: remove log and update function parameters

* fix: remove wrong name

* nits: change icon

* fix: nit migration

* nits: refacto and remove alert

* nits: change variable name

* update workspaces_export

* fix: ci

---------

Co-authored-by: HugoCasa <hugo@casademont.ch>
Co-authored-by: Guilhem <guilhemlemouel@gmail.com>
2025-02-11 18:16:12 +01:00

80 lines
2.2 KiB
Svelte

<script lang="ts">
import { Button } from '$lib/components/common'
import Tooltip from '$lib/components/Tooltip.svelte'
import { PostgresTriggerService } from '$lib/gen'
import { workspaceStore } from '$lib/stores'
import { sendUserToast } from '$lib/toast'
import { emptyString } from '$lib/utils'
let loadingConfiguration = false
const checkDatabaseConfiguration = async () => {
if (emptyString(postgres_resource_path)) {
sendUserToast('You must first pick a database resource', true)
return
}
try {
const invalidConfig = !(await PostgresTriggerService.isValidPostgresConfiguration({
workspace: $workspaceStore!,
path: postgres_resource_path
}))
let msg = 'Database is in logical mode. Triggers can be used.'
if (invalidConfig) {
msg =
'Database is NOT in logical mode. Triggers cannot be used. Refer to the PostgreSQL documentation for configuration requirements.'
}
sendUserToast(msg, invalidConfig)
} catch (error) {
sendUserToast(error.body, true)
}
loadingConfiguration = false
}
const checkConnectionAndDatabaseConfiguration = async () => {
try {
loadingConfiguration = true
if (checkConnection) {
await checkConnection()
}
await checkDatabaseConfiguration()
} catch (error) {
sendUserToast(error.body, true)
}
loadingConfiguration = false
}
export let can_write: boolean
export let postgres_resource_path: string
export let checkConnection: any | undefined = undefined
console.log('dbg check connection', checkConnection)
</script>
{#if postgres_resource_path}
<div class="flex flex-col justify-end mt-1 gap-2">
<Button
disabled={!can_write}
loading={loadingConfiguration}
on:click={checkConnectionAndDatabaseConfiguration}
size="xs"
color="light"
spacingSize="sm"
variant="border"
>
{`Check database configuration ${checkConnection ? 'and connection' : ''}`}
<Tooltip
documentationLink="https://www.windmill.dev/docs/core_concepts/postgres_triggers#requirements"
>
<p class="text-sm">
Verifies whether the database is configured with the required <strong>settings</strong>.
{checkConnection && 'Also checks whether the connection to the database is working.'}
</p>
</Tooltip>
</Button>
</div>
{/if}