Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
refactor: consolidate notification provider forms (#1704)
Kyle Mendellfcdf70f274f0
diff --git a/backend/internal/huma/handlers/notifications.go b/backend/internal/huma/handlers/notifications.goindex 5a331893f..21515cd43 100644--- a/backend/internal/huma/handlers/notifications.go+++ b/backend/internal/huma/handlers/notifications.go@@ -3,6 +3,7 @@ package handlersimport ("context""net/http"+ "strings""github.com/danielgtaylor/huma/v2""github.com/getarcaneapp/arcane/backend/internal/common"@@ -81,12 +82,34 @@ type CreateOrUpdateAppriseSettingsOutput struct {type TestAppriseNotificationInput struct {EnvironmentID string `path:"id" doc:"Environment ID"`+ Type string `query:"type" default:"simple"`}type TestAppriseNotificationOutput struct {Body base.ApiResponse[base.MessageResponse]}+var supportedNotificationTestTypes = map[string]struct{}{+ "simple": {},+ "image-update": {},+ "batch-image-update": {},+ "vulnerability-found": {},+ "prune-report": {},+}++func normalizeNotificationTestType(testType string) string {+ normalized := strings.TrimSpace(testType)+ if normalized == "" {+ return "simple"+ }+ return normalized+}++func isSupportedNotificationTestType(testType string) bool {+ _, ok := supportedNotificationTestTypes[testType]+ return ok+}+// RegisterNotifications registers notification endpoints.////nolint:staticcheck // AppriseService still functional, deprecated in favor of Shoutrrr@@ -264,8 +287,12 @@ func (h *NotificationHandler) TestNotification(ctx context.Context, input *TestNreturn nil, err}provider := models.NotificationProvider(input.Provider)+ testType := normalizeNotificationTestType(input.Type)+ if !isSupportedNotificationTestType(testType) {+ return nil, huma.Error400BadRequest("invalid notification test type")+ }- if err := h.notificationService.TestNotification(ctx, provider, input.Type); err != nil {+ if err := h.notificationService.TestNotification(ctx, provider, testType); err != nil {return nil, huma.Error500InternalServerError((&common.NotificationTestError{Err: err}).Error())}@@ -334,7 +361,11 @@ func (h *NotificationHandler) TestAppriseNotification(ctx context.Context, inputif err := checkAdmin(ctx); err != nil {return nil, err}- if err := h.appriseService.TestNotification(ctx); err != nil {+ testType := normalizeNotificationTestType(input.Type)+ if !isSupportedNotificationTestType(testType) {+ return nil, huma.Error400BadRequest("invalid notification test type")+ }+ if err := h.appriseService.TestNotification(ctx, testType); err != nil {return nil, huma.Error500InternalServerError((&common.AppriseTestError{Err: err}).Error())}diff --git a/backend/internal/services/apprise_service.go b/backend/internal/services/apprise_service.goindex 8aa04a0b1..9eb1a9337 100644--- a/backend/internal/services/apprise_service.go+++ b/backend/internal/services/apprise_service.go@@ -211,8 +211,62 @@ func (s *AppriseService) SendBatchImageUpdateNotification(ctx context.Context, ureturn s.SendNotification(ctx, title, body, "text", models.NotificationEventImageUpdate)}-func (s *AppriseService) TestNotification(ctx context.Context) error {- title := "Test Notification from Arcane"- body := "If you're reading this, your Apprise integration is working correctly!"- return s.SendNotification(ctx, title, body, "text", models.NotificationEventImageUpdate)+func (s *AppriseService) TestNotification(ctx context.Context, testType string) error {+ switch testType {+ case "vulnerability-found":+ title := "Vulnerability Summary Notification"+ body := fmt.Sprintf(+ "Summary Date: %s\nCritical: 1\nHigh: 3\nMedium: 2\nLow: 1\nUnknown: 0\nFixable vulnerabilities: 7\nExamples: CVE-2025-1234, CVE-2025-5678, CVE-2026-0001",+ time.Now().UTC().Format("2006-01-02"),+ )+ return s.SendNotification(ctx, title, body, "text", models.NotificationEventVulnerabilityFound)+ case "prune-report":+ title := "System Prune Report"+ body := "Containers pruned: 2\nImages deleted: 1\nVolumes deleted: 1\nNetworks deleted: 1\nSpace reclaimed: 3.56 GB"+ return s.SendNotification(ctx, title, body, "text", models.NotificationEventPruneReport)+ case "image-update":+ testUpdate := &imageupdate.Response{+ HasUpdate: true,+ UpdateType: "digest",+ CurrentDigest: "sha256:abc123def456789012345678901234567890",+ LatestDigest: "sha256:xyz789ghi012345678901234567890123456",+ CheckTime: time.Now(),+ ResponseTimeMs: 100,+ }+ return s.SendImageUpdateNotification(ctx, "nginx:latest", testUpdate)+ case "batch-image-update":+ testUpdates := map[string]*imageupdate.Response{+ "nginx:latest": {+ HasUpdate: true,+ UpdateType: "digest",+ CurrentDigest: "sha256:abc123def456789012345678901234567890",+ LatestDigest: "sha256:xyz789ghi012345678901234567890123456",+ CheckTime: time.Now(),+ ResponseTimeMs: 100,+ },+ "postgres:16-alpine": {+ HasUpdate: true,+ UpdateType: "digest",+ CurrentDigest: "sha256:def456abc123789012345678901234567890",+ LatestDigest: "sha256:ghi789xyz012345678901234567890123456",+ CheckTime: time.Now(),+ ResponseTimeMs: 120,+ },+ "redis:7.2-alpine": {+ HasUpdate: true,+ UpdateType: "digest",+ CurrentDigest: "sha256:123456789abc012345678901234567890def",+ LatestDigest: "sha256:456789012def345678901234567890123abc",+ CheckTime: time.Now(),+ ResponseTimeMs: 95,+ },+ }+ return s.SendBatchImageUpdateNotification(ctx, testUpdates)+ case "simple", "":+ title := "Test Notification from Arcane"+ body := "If you're reading this, your Apprise integration is working correctly!"+ return s.SendNotification(ctx, title, body, "text", models.NotificationEventImageUpdate)+ default:+ return fmt.Errorf("unsupported apprise test type: %s", testType)+ }}diff --git a/backend/internal/services/notification_service.go b/backend/internal/services/notification_service.goindex 6a48df540..434470328 100644--- a/backend/internal/services/notification_service.go+++ b/backend/internal/services/notification_service.go@@ -953,60 +953,89 @@ func (s *NotificationService) TestNotification(ctx context.Context, provider modResponseTimeMs: 100,}+ if testType == notificationTestTypeBatchImageUpdate {+ // Create test batch updates with multiple images+ testUpdates := map[string]*imageupdate.Response{+ "nginx:latest": {+ HasUpdate: true,+ UpdateType: "digest",+ CurrentDigest: "sha256:abc123def456789012345678901234567890",+ LatestDigest: "sha256:xyz789ghi012345678901234567890123456",+ CheckTime: time.Now(),+ ResponseTimeMs: 100,+ },+ "postgres:16-alpine": {+ HasUpdate: true,+ UpdateType: "digest",+ CurrentDigest: "sha256:def456abc123789012345678901234567890",+ LatestDigest: "sha256:ghi789xyz012345678901234567890123456",+ CheckTime: time.Now(),+ ResponseTimeMs: 120,+ },+ "redis:7.2-alpine": {+ HasUpdate: true,+ UpdateType: "digest",+ CurrentDigest: "sha256:123456789abc012345678901234567890def",+ LatestDigest: "sha256:456789012def345678901234567890123abc",+ CheckTime: time.Now(),+ ResponseTimeMs: 95,+ },+ }+ switch provider {+ case models.NotificationProviderDiscord:+ return s.sendBatchDiscordNotification(ctx, testUpdates, setting.Config)+ case models.NotificationProviderEmail:+ return s.sendBatchEmailNotification(ctx, testUpdates, setting.Config)+ case models.NotificationProviderTelegram:+ return s.sendBatchTelegramNotification(ctx, testUpdates, setting.Config)+ case models.NotificationProviderSignal:+ return s.sendBatchSignalNotification(ctx, testUpdates, setting.Config)+ case models.NotificationProviderSlack:+ return s.sendBatchSlackNotification(ctx, testUpdates, setting.Config)+ case models.NotificationProviderNtfy:+ return s.sendBatchNtfyNotification(ctx, testUpdates, setting.Config)+ case models.NotificationProviderPushover:+ return s.sendBatchPushoverNotification(ctx, testUpdates, setting.Config)+ case models.NotificationProviderGotify:+ return s.sendBatchGotifyNotification(ctx, testUpdates, setting.Config)+ case models.NotificationProviderMatrix:+ return s.sendBatchMatrixNotification(ctx, testUpdates, setting.Config)+ case models.NotificationProviderGeneric:+ return s.sendBatchGenericNotification(ctx, testUpdates, setting.Config)+ default:+ return fmt.Errorf("unknown provider: %s", provider)+ }+ }++ imageRef := "nginx:latest"+ if testType == notificationTestTypeSimple {+ imageRef = "test/image:latest"+ }+switch provider {case models.NotificationProviderDiscord:- return s.sendDiscordNotification(ctx, "test/image:latest", testUpdate, setting.Config)+ return s.sendDiscordNotification(ctx, imageRef, testUpdate, setting.Config)case models.NotificationProviderEmail:- if testType == notificationTestTypeImageUpdate {- return s.sendEmailNotification(ctx, "nginx:latest", testUpdate, setting.Config)- }- if testType == notificationTestTypeBatchImageUpdate {- // Create test batch updates with multiple images- testUpdates := map[string]*imageupdate.Response{- "nginx:latest": {- HasUpdate: true,- UpdateType: "digest",- CurrentDigest: "sha256:abc123def456789012345678901234567890",- LatestDigest: "sha256:xyz789ghi012345678901234567890123456",- CheckTime: time.Now(),- ResponseTimeMs: 100,- },- "postgres:16-alpine": {- HasUpdate: true,- UpdateType: "digest",- CurrentDigest: "sha256:def456abc123789012345678901234567890",- LatestDigest: "sha256:ghi789xyz012345678901234567890123456",- CheckTime: time.Now(),- ResponseTimeMs: 120,- },- "redis:7.2-alpine": {- HasUpdate: true,- UpdateType: "digest",- CurrentDigest: "sha256:123456789abc012345678901234567890def",- LatestDigest: "sha256:456789012def345678901234567890123abc",- CheckTime: time.Now(),- ResponseTimeMs: 95,- },- }- return s.sendBatchEmailNotification(ctx, testUpdates, setting.Config)+ if testType == notificationTestTypeSimple {+ return s.sendTestEmail(ctx, setting.Config)}- return s.sendTestEmail(ctx, setting.Config)+ return s.sendEmailNotification(ctx, imageRef, testUpdate, setting.Config)case models.NotificationProviderTelegram:- return s.sendTelegramNotification(ctx, "nginx:latest", testUpdate, setting.Config)+ return s.sendTelegramNotification(ctx, imageRef, testUpdate, setting.Config)case models.NotificationProviderSignal:- return s.sendSignalNotification(ctx, "nginx:latest", testUpdate, setting.Config)+ return s.sendSignalNotification(ctx, imageRef, testUpdate, setting.Config)case models.NotificationProviderSlack:- return s.sendSlackNotification(ctx, "nginx:latest", testUpdate, setting.Config)+ return s.sendSlackNotification(ctx, imageRef, testUpdate, setting.Config)case models.NotificationProviderNtfy:- return s.sendNtfyNotification(ctx, "test/image:latest", testUpdate, setting.Config)+ return s.sendNtfyNotification(ctx, imageRef, testUpdate, setting.Config)case models.NotificationProviderPushover:- return s.sendPushoverNotification(ctx, "test/image:latest", testUpdate, setting.Config)+ return s.sendPushoverNotification(ctx, imageRef, testUpdate, setting.Config)case models.NotificationProviderGotify:- return s.sendGotifyNotification(ctx, "test/image:latest", testUpdate, setting.Config)+ return s.sendGotifyNotification(ctx, imageRef, testUpdate, setting.Config)case models.NotificationProviderMatrix:- return s.sendMatrixNotification(ctx, "test/image:latest", testUpdate, setting.Config)+ return s.sendMatrixNotification(ctx, imageRef, testUpdate, setting.Config)case models.NotificationProviderGeneric:- return s.sendGenericNotification(ctx, "test/image:latest", testUpdate, setting.Config)+ return s.sendGenericNotification(ctx, imageRef, testUpdate, setting.Config)default:return fmt.Errorf("unknown provider: %s", provider)}diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex 630fedc9b..ee4770332 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -1677,10 +1677,10 @@"notifications_email_tls_mode_label": "TLS Mode","notifications_email_tls_mode_placeholder": "Select TLS mode","notifications_email_tls_mode_description": "StartTLS (default) upgrades from plain connection. SSL/TLS uses encryption from start. None uses no encryption.",- "notifications_email_test_simple": "Simple Test Email",- "notifications_email_test_image_update": "Image Update Email",- "notifications_email_test_batch_image_update": "Batch Image Updates Email",- "notifications_email_test_vulnerability_found": "Vulnerability Found Email",+ "notifications_email_test_simple": "Simple Test Notification",+ "notifications_email_test_image_update": "Image Update Notification",+ "notifications_email_test_batch_image_update": "Batch Image Updates Notification",+ "notifications_email_test_vulnerability_found": "Vulnerability Found Notification","notifications_test_vulnerability_notification": "Test Vulnerability Notification","notifications_test_prune_report_notification": "Test Prune Report Notification","notifications_apprise_title": "Apprise Integration",diff --git a/frontend/src/lib/services/notification-service.ts b/frontend/src/lib/services/notification-service.tsindex ee7e00fbc..4f06071e2 100644--- a/frontend/src/lib/services/notification-service.ts+++ b/frontend/src/lib/services/notification-service.ts@@ -33,9 +33,9 @@ export default class NotificationService extends BaseAPIService {return res.data;}- async testAppriseNotification(): Promise<TestNotificationResponse> {+ async testAppriseNotification(type: string = 'simple'): Promise<TestNotificationResponse> {const envId = await environmentStore.getCurrentEnvironmentId();- return this.handleResponse(this.api.post(`/environments/${envId}/notifications/apprise/test`));+ return this.handleResponse(this.api.post(`/environments/${envId}/notifications/apprise/test?type=${type}`));}}diff --git a/frontend/src/routes/(app)/settings/notifications/+page.svelte b/frontend/src/routes/(app)/settings/notifications/+page.svelteindex ef9ccd5a1..d769860d1 100644--- a/frontend/src/routes/(app)/settings/notifications/+page.svelte+++ b/frontend/src/routes/(app)/settings/notifications/+page.svelte@@ -48,19 +48,7 @@appriseFormValuesToSettings} from '$lib/types/notification-providers';import { NotificationsIcon } from '$lib/icons';- import {- EmailProviderForm,- DiscordProviderForm,- TelegramProviderForm,- SignalProviderForm,- SlackProviderForm,- NtfyProviderForm,- PushoverProviderForm,- GotifyProviderForm,- MatrixProviderForm,- GenericProviderForm,- AppriseProviderForm- } from './providers';+ import { BuiltInProviderForm, AppriseProviderForm } from './providers';let { data } = $props();@@ -83,16 +71,16 @@}// Provider form references for validation- let emailFormRef: EmailProviderForm;- let discordFormRef: DiscordProviderForm;- let telegramFormRef: TelegramProviderForm;- let signalFormRef: SignalProviderForm;- let slackFormRef: SlackProviderForm;- let ntfyFormRef: NtfyProviderForm;- let pushoverFormRef: PushoverProviderForm;- let gotifyFormRef: GotifyProviderForm;- let matrixFormRef: MatrixProviderForm;- let genericFormRef: GenericProviderForm;+ let emailFormRef: BuiltInProviderForm;+ let discordFormRef: BuiltInProviderForm;+ let telegramFormRef: BuiltInProviderForm;+ let signalFormRef: BuiltInProviderForm;+ let slackFormRef: BuiltInProviderForm;+ let ntfyFormRef: BuiltInProviderForm;+ let pushoverFormRef: BuiltInProviderForm;+ let gotifyFormRef: BuiltInProviderForm;+ let matrixFormRef: BuiltInProviderForm;+ let genericFormRef: BuiltInProviderForm;// Saved settings from server (used to detect if settings exist)let savedSettings = $state<Record<NotificationProviderKey, NotificationSettings | null>>({@@ -446,19 +434,19 @@}}- async function testAppriseNotification() {+ async function testAppriseNotification(testType: string = 'simple') {if (hasChanges) {- pendingTestAction = executeAppriseTest;+ pendingTestAction = () => executeAppriseTest(testType);showUnsavedDialog = true;return;}- await executeAppriseTest();+ await executeAppriseTest(testType);}- async function executeAppriseTest() {+ async function executeAppriseTest(testType: string = 'simple') {isTesting = true;try {- await notificationService.testAppriseNotification();+ await notificationService.testAppriseNotification(testType);toast.success(m.notifications_test_success({ provider: 'Apprise' }));} catch (error: any) {const errorMsg = error?.response?.data?.error || error.message || m.common_unknown();@@ -512,8 +500,9 @@</Tabs.List><Tabs.Content value="email" class="mt-4 space-y-4">- <EmailProviderForm+ <BuiltInProviderFormbind:this={emailFormRef}+ provider="email"bind:values={emailValues}disabled={isReadOnly}{isTesting}@@ -522,8 +511,9 @@</Tabs.Content><Tabs.Content value="discord" class="mt-4 space-y-4">- <DiscordProviderForm+ <BuiltInProviderFormbind:this={discordFormRef}+ provider="discord"bind:values={discordValues}disabled={isReadOnly}{isTesting}@@ -532,8 +522,9 @@</Tabs.Content><Tabs.Content value="telegram" class="mt-4 space-y-4">- <TelegramProviderForm+ <BuiltInProviderFormbind:this={telegramFormRef}+ provider="telegram"bind:values={telegramValues}disabled={isReadOnly}{isTesting}@@ -542,8 +533,9 @@</Tabs.Content><Tabs.Content value="signal" class="mt-4 space-y-4">- <SignalProviderForm+ <BuiltInProviderFormbind:this={signalFormRef}+ provider="signal"bind:values={signalValues}disabled={isReadOnly}{isTesting}@@ -552,8 +544,9 @@</Tabs.Content><Tabs.Content value="slack" class="mt-4 space-y-4">- <SlackProviderForm+ <BuiltInProviderFormbind:this={slackFormRef}+ provider="slack"bind:values={slackValues}disabled={isReadOnly}{isTesting}@@ -562,8 +555,9 @@</Tabs.Content><Tabs.Content value="ntfy" class="mt-4 space-y-4">- <NtfyProviderForm+ <BuiltInProviderFormbind:this={ntfyFormRef}+ provider="ntfy"bind:values={ntfyValues}disabled={isReadOnly}{isTesting}@@ -572,8 +566,9 @@</Tabs.Content><Tabs.Content value="pushover" class="mt-4 space-y-4">- <PushoverProviderForm+ <BuiltInProviderFormbind:this={pushoverFormRef}+ provider="pushover"bind:values={pushoverValues}disabled={isReadOnly}{isTesting}@@ -582,8 +577,9 @@</Tabs.Content><Tabs.Content value="gotify" class="mt-4 space-y-4">- <GotifyProviderForm+ <BuiltInProviderFormbind:this={gotifyFormRef}+ provider="gotify"bind:values={gotifyValues}disabled={isReadOnly}{isTesting}@@ -592,8 +588,9 @@</Tabs.Content><Tabs.Content value="matrix" class="mt-4 space-y-4">- <MatrixProviderForm+ <BuiltInProviderFormbind:this={matrixFormRef}+ provider="matrix"bind:values={matrixValues}disabled={isReadOnly}{isTesting}@@ -602,8 +599,9 @@</Tabs.Content><Tabs.Content value="generic" class="mt-4 space-y-4">- <GenericProviderForm+ <BuiltInProviderFormbind:this={genericFormRef}+ provider="generic"bind:values={genericValues}disabled={isReadOnly}{isTesting}diff --git a/frontend/src/routes/(app)/settings/notifications/providers/AppriseProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/AppriseProviderForm.svelteindex 0eb53b14c..4b19bfb62 100644--- a/frontend/src/routes/(app)/settings/notifications/providers/AppriseProviderForm.svelte+++ b/frontend/src/routes/(app)/settings/notifications/providers/AppriseProviderForm.svelte@@ -1,20 +1,48 @@<script lang="ts">- import { ArcaneButton } from '$lib/components/arcane-button/index.js';- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';import { m } from '$lib/paraglide/messages';- import { SendEmailIcon } from '$lib/icons';import type { AppriseFormValues } from '$lib/types/notification-providers';import ProviderFormWrapper from './ProviderFormWrapper.svelte';+ import DynamicProviderFormBuilder from './DynamicProviderFormBuilder.svelte';+ import NotificationProviderTestMenu from './NotificationProviderTestMenu.svelte';+ import type { ProviderFormSchema } from './provider-form-schema';interface Props {values: AppriseFormValues;disabled?: boolean;isTesting?: boolean;- onTest?: () => void;+ onTest?: (testType?: string) => void;}let { values = $bindable(), disabled = false, isTesting = false, onTest }: Props = $props();+ const formSchema: ProviderFormSchema<AppriseFormValues> = [+ {+ kind: 'input',+ key: 'apiUrl',+ id: 'apprise-api-url',+ label: m.notifications_apprise_api_url_label(),+ placeholder: m.notifications_apprise_api_url_placeholder(),+ helpText: m.notifications_apprise_api_url_help(),+ inputType: 'url'+ },+ {+ kind: 'input',+ key: 'imageUpdateTag',+ id: 'apprise-image-update-tag',+ label: m.notifications_apprise_image_tag_label(),+ placeholder: m.notifications_apprise_image_tag_placeholder(),+ helpText: m.notifications_apprise_image_tag_help()+ },+ {+ kind: 'input',+ key: 'containerUpdateTag',+ id: 'apprise-container-update-tag',+ label: m.notifications_apprise_container_tag_label(),+ placeholder: m.notifications_apprise_container_tag_placeholder(),+ helpText: m.notifications_apprise_container_tag_help()+ }+ ];+export function isValid(): boolean {if (!values.enabled) return true;return values.apiUrl.trim().length > 0;@@ -29,45 +57,7 @@bind:enabled={values.enabled}{disabled}>- <TextInputWithLabel- bind:value={values.apiUrl}- {disabled}- label={m.notifications_apprise_api_url_label()}- placeholder={m.notifications_apprise_api_url_placeholder()}- type="url"- autocomplete="off"- helpText={m.notifications_apprise_api_url_help()}- />- <TextInputWithLabel- bind:value={values.imageUpdateTag}- {disabled}- label={m.notifications_apprise_image_tag_label()}- placeholder={m.notifications_apprise_image_tag_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_apprise_image_tag_help()}- />- <TextInputWithLabel- bind:value={values.containerUpdateTag}- {disabled}- label={m.notifications_apprise_container_tag_label()}- placeholder={m.notifications_apprise_container_tag_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_apprise_container_tag_help()}- />+ <DynamicProviderFormBuilder bind:values {disabled} schema={formSchema} />- {#if onTest}- <div class="pt-2">- <ArcaneButton- action="base"- tone="outline"- onclick={onTest}- disabled={disabled || isTesting}- loading={isTesting}- icon={SendEmailIcon}- customLabel={m.notifications_test_notification()}- />- </div>- {/if}+ <NotificationProviderTestMenu {disabled} {isTesting} {onTest} /></ProviderFormWrapper>diff --git a/frontend/src/routes/(app)/settings/notifications/providers/BuiltInProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/BuiltInProviderForm.sveltenew file mode 100644index 000000000..05d517101--- /dev/null+++ b/frontend/src/routes/(app)/settings/notifications/providers/BuiltInProviderForm.svelte@@ -0,0 +1,1095 @@+<script lang="ts">+ import { m } from '$lib/paraglide/messages';+ import { z } from 'zod/v4';+ import type {+ NotificationProviderKey,+ ProviderFormValuesMap,+ DiscordFormValues,+ EmailFormValues,+ TelegramFormValues,+ SignalFormValues,+ SlackFormValues,+ NtfyFormValues,+ PushoverFormValues,+ GotifyFormValues,+ MatrixFormValues,+ GenericFormValues+ } from '$lib/types/notification-providers';+ import ProviderFormWrapper from './ProviderFormWrapper.svelte';+ import EventSubscriptions from './EventSubscriptions.svelte';+ import DynamicProviderFormBuilder from './DynamicProviderFormBuilder.svelte';+ import NotificationProviderTestMenu from './NotificationProviderTestMenu.svelte';+ import type { NotificationProviderTestOption } from './NotificationProviderTestMenu.svelte';+ import { mapZodFieldErrors } from './provider-form-validation';+ import type { ProviderFormSchema } from './provider-form-schema';++ type AnyBuiltInValues = ProviderFormValuesMap[NotificationProviderKey];++ interface Props {+ provider: NotificationProviderKey;+ values: AnyBuiltInValues;+ disabled?: boolean;+ isTesting?: boolean;+ onTest?: (testType?: string) => void;+ }++ let { provider, values = $bindable(), disabled = false, isTesting = false, onTest }: Props = $props();++ const providerMeta: Record<NotificationProviderKey, { title: string; description: string; enabledLabel: string }> = {+ discord: {+ title: 'Discord',+ description: m.notifications_discord_description(),+ enabledLabel: m.notifications_discord_enabled_label()+ },+ email: {+ title: 'Email',+ description: m.notifications_email_description(),+ enabledLabel: m.notifications_email_enabled_label()+ },+ telegram: {+ title: 'Telegram',+ description: 'Send notifications via Telegram bot',+ enabledLabel: 'Enable Telegram Notifications'+ },+ signal: {+ title: m.notifications_signal_title(),+ description: m.notifications_signal_description(),+ enabledLabel: m.notifications_signal_enabled_label()+ },+ slack: {+ title: m.notifications_slack_title(),+ description: m.notifications_slack_description(),+ enabledLabel: m.notifications_slack_enabled_label()+ },+ ntfy: {+ title: 'Ntfy',+ description: m.notifications_ntfy_description(),+ enabledLabel: m.notifications_ntfy_enabled_label()+ },+ pushover: {+ title: 'Pushover',+ description: m.notifications_pushover_description(),+ enabledLabel: m.notifications_pushover_enabled_label()+ },+ gotify: {+ title: 'Gotify',+ description: m.notifications_gotify_description(),+ enabledLabel: m.notifications_gotify_enabled_label()+ },+ matrix: {+ title: 'Matrix',+ description: m.notifications_matrix_description(),+ enabledLabel: m.notifications_matrix_enabled_label()+ },+ generic: {+ title: m.notifications_generic_title(),+ description: m.notifications_generic_description(),+ enabledLabel: m.notifications_generic_enabled_label()+ }+ };++ const providerSchemas: Record<NotificationProviderKey, z.ZodTypeAny> = {+ discord: z+ .object({+ enabled: z.boolean(),+ webhookId: z.string(),+ token: z.string(),+ username: z.string(),+ avatarUrl: z.string(),+ eventImageUpdate: z.boolean(),+ eventContainerUpdate: z.boolean(),+ eventVulnerabilityFound: z.boolean(),+ eventPruneReport: z.boolean()+ })+ .superRefine((d, ctx) => {+ if (!d.enabled) return;+ if (!d.webhookId.trim()) {+ ctx.addIssue({ code: 'custom', message: 'Webhook ID is required when Discord is enabled', path: ['webhookId'] });+ }+ if (!d.token.trim()) {+ ctx.addIssue({ code: 'custom', message: 'Webhook Token is required when Discord is enabled', path: ['token'] });+ }+ }),+ email: z+ .object({+ enabled: z.boolean(),+ smtpHost: z.string(),+ smtpPort: z.coerce.number().int().min(1).max(65535),+ smtpUsername: z.string(),+ smtpPassword: z.string(),+ fromAddress: z.string(),+ toAddresses: z.string(),+ tlsMode: z.enum(['none', 'starttls', 'ssl']),+ eventImageUpdate: z.boolean(),+ eventContainerUpdate: z.boolean(),+ eventVulnerabilityFound: z.boolean(),+ eventPruneReport: z.boolean()+ })+ .superRefine((d, ctx) => {+ if (!d.enabled) return;+ if (!d.smtpHost.trim()) {+ ctx.addIssue({ code: 'custom', message: 'SMTP host is required when email is enabled', path: ['smtpHost'] });+ }+ if (!d.fromAddress.trim()) {+ ctx.addIssue({ code: 'custom', message: 'From address is required when email is enabled', path: ['fromAddress'] });+ } else {+ const v = z.string().email().safeParse(d.fromAddress.trim());+ if (!v.success) {+ ctx.addIssue({ code: 'custom', message: 'Invalid email address format', path: ['fromAddress'] });+ }+ }+ if (!d.toAddresses.trim()) {+ ctx.addIssue({+ code: 'custom',+ message: 'At least one recipient address is required when email is enabled',+ path: ['toAddresses']+ });+ } else {+ const addresses = d.toAddresses+ .split(',')+ .map((addr) => addr.trim())+ .filter((addr) => addr.length > 0);+ const invalid: string[] = [];+ addresses.forEach((addr) => {+ const v = z.string().email().safeParse(addr);+ if (!v.success) invalid.push(addr);+ });+ if (invalid.length > 0) {+ ctx.addIssue({+ code: 'custom',+ message: `Invalid email addresses: ${invalid.join(', ')}`,+ path: ['toAddresses']+ });+ }+ }+ }),+ telegram: z+ .object({+ enabled: z.boolean(),+ botToken: z.string(),+ chatIds: z.string(),+ preview: z.boolean(),+ notification: z.boolean(),+ title: z.string(),+ eventImageUpdate: z.boolean(),+ eventContainerUpdate: z.boolean(),+ eventVulnerabilityFound: z.boolean(),+ eventPruneReport: z.boolean()+ })+ .superRefine((d, ctx) => {+ if (!d.enabled) return;+ if (!d.botToken.trim()) {+ ctx.addIssue({ code: 'custom', message: 'Bot Token is required when Telegram is enabled', path: ['botToken'] });+ }+ if (!d.chatIds.trim()) {+ ctx.addIssue({+ code: 'custom',+ message: 'At least one Chat ID is required when Telegram is enabled',+ path: ['chatIds']+ });+ }+ }),+ signal: z+ .object({+ enabled: z.boolean(),+ host: z.string(),+ port: z.number().min(1).max(65535),+ user: z.string(),+ password: z.string(),+ token: z.string(),+ source: z.string(),+ recipients: z.string(),+ disableTls: z.boolean(),+ eventImageUpdate: z.boolean(),+ eventContainerUpdate: z.boolean(),+ eventVulnerabilityFound: z.boolean(),+ eventPruneReport: z.boolean()+ })+ .superRefine((d, ctx) => {+ if (!d.enabled) return;++ if (!d.host.trim()) {+ ctx.addIssue({ code: 'custom', message: m.notifications_signal_host_required(), path: ['host'] });+ }++ if (d.port < 1 || d.port > 65535) {+ ctx.addIssue({ code: 'custom', message: m.notifications_signal_port_invalid(), path: ['port'] });+ }++ if (!d.source.trim()) {+ ctx.addIssue({ code: 'custom', message: m.notifications_signal_source_required(), path: ['source'] });+ } else if (!d.source.startsWith('+')) {+ ctx.addIssue({ code: 'custom', message: m.notifications_signal_source_format(), path: ['source'] });+ }++ if (!d.recipients.trim()) {+ ctx.addIssue({ code: 'custom', message: m.notifications_signal_recipients_required(), path: ['recipients'] });+ }++ const hasBasicAuth = d.user.trim() && d.password.trim();+ const hasTokenAuth = d.token.trim();+ if (!hasBasicAuth && !hasTokenAuth) {+ ctx.addIssue({+ code: 'custom',+ message: m.notifications_signal_auth_required(),+ path: ['user']+ });+ }+ if (hasBasicAuth && hasTokenAuth) {+ ctx.addIssue({+ code: 'custom',+ message: m.notifications_signal_auth_conflict(),+ path: ['token']+ });+ }+ }),+ slack: z+ .object({+ enabled: z.boolean(),+ token: z.string(),+ botName: z.string(),+ icon: z.string(),+ color: z.string(),+ title: z.string(),+ channel: z.string(),+ threadTs: z.string(),+ eventImageUpdate: z.boolean(),+ eventContainerUpdate: z.boolean(),+ eventVulnerabilityFound: z.boolean(),+ eventPruneReport: z.boolean()+ })+ .superRefine((d, ctx) => {+ if (!d.enabled) return;+ if (!d.token.trim()) {+ ctx.addIssue({ code: 'custom', message: m.notifications_slack_token_required(), path: ['token'] });+ }+ }),+ ntfy: z+ .object({+ enabled: z.boolean(),+ host: z.string(),+ port: z.number().min(0).max(65535),+ topic: z.string(),+ username: z.string(),+ password: z.string(),+ priority: z.string(),+ tags: z.string(),+ icon: z.string(),+ cache: z.boolean(),+ firebase: z.boolean(),+ disableTlsVerification: z.boolean(),+ eventImageUpdate: z.boolean(),+ eventContainerUpdate: z.boolean(),+ eventVulnerabilityFound: z.boolean(),+ eventPruneReport: z.boolean()+ })+ .superRefine((d, ctx) => {+ if (!d.enabled) return;+ if (!d.topic.trim()) {+ ctx.addIssue({ code: 'custom', message: 'Topic is required when Ntfy is enabled', path: ['topic'] });+ }+ if (d.port > 0 && (d.port < 1 || d.port > 65535)) {+ ctx.addIssue({ code: 'custom', message: 'Port must be between 1 and 65535', path: ['port'] });+ }+ }),+ pushover: z+ .object({+ enabled: z.boolean(),+ token: z.string(),+ user: z.string(),+ devices: z.string(),+ priority: z.coerce.number().int().min(-2).max(2),+ title: z.string(),+ eventImageUpdate: z.boolean(),+ eventContainerUpdate: z.boolean(),+ eventVulnerabilityFound: z.boolean(),+ eventPruneReport: z.boolean()+ })+ .superRefine((d, ctx) => {+ if (!d.enabled) return;+ if (!d.token.trim()) {+ ctx.addIssue({ code: 'custom', message: m.common_required(), path: ['token'] });+ }+ if (!d.user.trim()) {+ ctx.addIssue({ code: 'custom', message: m.common_required(), path: ['user'] });+ }+ }),+ gotify: z+ .object({+ enabled: z.boolean(),+ host: z.string(),+ port: z.coerce.number().int().min(0).max(65535),+ token: z.string(),+ path: z.string(),+ priority: z.coerce.number().int(),+ title: z.string(),+ disableTls: z.boolean(),+ eventImageUpdate: z.boolean(),+ eventContainerUpdate: z.boolean(),+ eventVulnerabilityFound: z.boolean(),+ eventPruneReport: z.boolean()+ })+ .superRefine((d, ctx) => {+ if (!d.enabled) return;+ if (!d.host.trim()) {+ ctx.addIssue({ code: 'custom', message: m.common_required(), path: ['host'] });+ }+ if (!d.token.trim()) {+ ctx.addIssue({ code: 'custom', message: m.common_required(), path: ['token'] });+ }+ }),+ matrix: z+ .object({+ enabled: z.boolean(),+ host: z.string(),+ port: z.coerce.number().int().min(0).max(65535),+ rooms: z.string(),+ username: z.string(),+ password: z.string(),+ disableTlsVerification: z.boolean(),+ eventImageUpdate: z.boolean(),+ eventContainerUpdate: z.boolean(),+ eventVulnerabilityFound: z.boolean(),+ eventPruneReport: z.boolean()+ })+ .superRefine((d, ctx) => {+ if (!d.enabled) return;+ if (!d.host.trim()) {+ ctx.addIssue({ code: 'custom', message: m.common_required(), path: ['host'] });+ }+ }),+ generic: z+ .object({+ enabled: z.boolean(),+ webhookUrl: z.string(),+ method: z.string(),+ contentType: z.string(),+ titleKey: z.string(),+ messageKey: z.string(),+ customHeaders: z.string(),+ eventImageUpdate: z.boolean(),+ eventContainerUpdate: z.boolean(),+ eventVulnerabilityFound: z.boolean(),+ eventPruneReport: z.boolean()+ })+ .superRefine((d, ctx) => {+ if (!d.enabled) return;+ if (!d.webhookUrl.trim()) {+ ctx.addIssue({+ code: 'custom',+ message: 'Webhook URL is required when Generic Webhook is enabled',+ path: ['webhookUrl']+ });+ }+ })+ };++ const providerFormSchemas: { [K in NotificationProviderKey]: ProviderFormSchema<ProviderFormValuesMap[K]> } = {+ discord: [+ {+ kind: 'input',+ key: 'webhookId',+ id: 'discord-webhook-id',+ label: m.notifications_discord_webhook_id_label(),+ placeholder: m.notifications_discord_webhook_id_placeholder(),+ helpText: m.notifications_discord_webhook_id_help()+ },+ {+ kind: 'input',+ key: 'token',+ id: 'discord-token',+ label: m.notifications_discord_token_label(),+ placeholder: m.notifications_discord_token_placeholder(),+ helpText: m.notifications_discord_token_help(),+ inputType: 'password'+ },+ {+ kind: 'input',+ key: 'username',+ id: 'discord-username',+ label: m.notifications_discord_username_label(),+ placeholder: m.notifications_discord_username_placeholder(),+ helpText: m.notifications_discord_username_help()+ },+ {+ kind: 'input',+ key: 'avatarUrl',+ id: 'discord-avatar-url',+ label: m.notifications_discord_avatar_url_label(),+ placeholder: m.notifications_discord_avatar_url_placeholder(),+ helpText: m.notifications_discord_avatar_url_help()+ }+ ],+ email: [+ {+ kind: 'row',+ className: 'grid grid-cols-2 gap-4',+ fields: [+ {+ kind: 'input',+ key: 'smtpHost',+ id: 'smtp-host',+ label: m.notifications_email_smtp_host_label(),+ placeholder: m.notifications_email_smtp_host_placeholder(),+ helpText: m.notifications_email_smtp_host_help()+ },+ {+ kind: 'input',+ key: 'smtpPort',+ id: 'smtp-port',+ label: m.notifications_email_smtp_port_label(),+ placeholder: m.notifications_email_smtp_port_placeholder(),+ helpText: m.notifications_email_smtp_port_help(),+ inputType: 'number'+ }+ ]+ },+ {+ kind: 'row',+ className: 'grid grid-cols-2 gap-4',+ fields: [+ {+ kind: 'input',+ key: 'smtpUsername',+ id: 'smtp-username',+ label: m.notifications_email_username_label(),+ placeholder: m.notifications_email_username_placeholder(),+ helpText: m.notifications_email_username_help()+ },+ {+ kind: 'input',+ key: 'smtpPassword',+ id: 'smtp-password',+ label: m.notifications_email_password_label(),+ placeholder: m.notifications_email_password_placeholder(),+ helpText: m.notifications_email_password_help(),+ inputType: 'password',+ autocomplete: 'new-password'+ }+ ]+ },+ {+ kind: 'input',+ key: 'fromAddress',+ id: 'from-address',+ label: m.notifications_email_from_address_label(),+ placeholder: m.notifications_email_from_address_placeholder(),+ helpText: m.notifications_email_from_address_help(),+ inputType: 'email'+ },+ {+ kind: 'textarea',+ key: 'toAddresses',+ id: 'to-addresses',+ label: m.notifications_email_to_addresses_label(),+ placeholder: m.notifications_email_to_addresses_placeholder(),+ helpText: m.notifications_email_to_addresses_help(),+ rows: 2+ },+ {+ kind: 'select',+ key: 'tlsMode',+ id: 'email-tls-mode',+ label: m.notifications_email_tls_mode_label(),+ placeholder: m.notifications_email_tls_mode_placeholder(),+ description: m.notifications_email_tls_mode_description(),+ options: [+ { value: 'none', label: 'None' },+ { value: 'starttls', label: 'StartTLS' },+ { value: 'ssl', label: 'SSL/TLS' }+ ]+ }+ ],+ telegram: [+ {+ kind: 'input',+ key: 'botToken',+ id: 'telegram-bot-token',+ label: 'Bot Token',+ placeholder: '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11',+ helpText: 'The bot token from @BotFather',+ inputType: 'password'+ },+ {+ kind: 'textarea',+ key: 'chatIds',+ id: 'telegram-chat-ids',+ label: 'Chat IDs',+ placeholder: '@channel, 123456789, @another_channel',+ helpText: 'Comma-separated list of chat IDs or @channel names',+ rows: 2+ },+ {+ kind: 'input',+ key: 'title',+ id: 'telegram-title',+ label: 'Title (Optional)',+ placeholder: 'Arcane Notifications',+ helpText: 'Custom title for notifications'+ },+ {+ kind: 'row',+ className: 'space-y-3',+ fields: [+ {+ kind: 'switch',+ key: 'preview',+ id: 'telegram-preview',+ label: 'Enable Link Previews',+ description: 'Show web page previews for URLs in messages'+ },+ {+ kind: 'switch',+ key: 'notification',+ id: 'telegram-notification',+ label: 'Enable Notification Sound',+ description: 'Play notification sound when messages are received'+ }+ ]+ }+ ],+ signal: [+ {+ kind: 'row',+ className: 'grid grid-cols-2 gap-4',+ fields: [+ {+ kind: 'input',+ key: 'host',+ id: 'signal-host',+ label: m.notifications_signal_host_label(),+ placeholder: m.notifications_signal_host_placeholder(),+ helpText: m.notifications_signal_host_help()+ },+ {+ kind: 'input',+ key: 'port',+ id: 'signal-port',+ label: m.notifications_signal_port_label(),+ placeholder: m.notifications_signal_port_placeholder(),+ helpText: m.notifications_signal_port_help(),+ inputType: 'number'+ }+ ]+ },+ {+ kind: 'row',+ className: 'grid grid-cols-2 gap-4',+ fields: [+ {+ kind: 'input',+ key: 'user',+ id: 'signal-user',+ label: m.notifications_signal_user_label(),+ placeholder: m.notifications_signal_user_placeholder(),+ helpText: m.notifications_signal_user_help()+ },+ {+ kind: 'input',+ key: 'password',+ id: 'signal-password',+ label: m.notifications_signal_password_label(),+ placeholder: m.notifications_signal_password_placeholder(),+ helpText: m.notifications_signal_password_help(),+ inputType: 'password'+ }+ ]+ },+ {+ kind: 'input',+ key: 'token',+ id: 'signal-token',+ label: m.notifications_signal_token_label(),+ placeholder: m.notifications_signal_token_placeholder(),+ helpText: m.notifications_signal_token_help(),+ inputType: 'password'+ },+ {+ kind: 'input',+ key: 'source',+ id: 'signal-source',+ label: m.notifications_signal_source_label(),+ placeholder: m.notifications_signal_source_placeholder(),+ helpText: m.notifications_signal_source_help()+ },+ {+ kind: 'textarea',+ key: 'recipients',+ id: 'signal-recipients',+ label: m.notifications_signal_recipients_label(),+ placeholder: m.notifications_signal_recipients_placeholder(),+ helpText: m.notifications_signal_recipients_help(),+ rows: 3+ },+ {+ kind: 'switch',+ key: 'disableTls',+ id: 'signal-disable-tls',+ label: m.notifications_signal_disable_tls_label(),+ description: m.notifications_signal_disable_tls_description()+ }+ ],+ slack: [+ {+ kind: 'input',+ key: 'token',+ id: 'slack-token',+ label: m.notifications_slack_token_label(),+ placeholder: m.notifications_slack_token_placeholder(),+ helpText: m.notifications_slack_token_help(),+ inputType: 'password'+ },+ {+ kind: 'row',+ className: 'grid grid-cols-2 gap-4',+ fields: [+ {+ kind: 'input',+ key: 'botName',+ id: 'slack-bot-name',+ label: m.notifications_slack_bot_name_label(),+ placeholder: m.notifications_slack_bot_name_placeholder(),+ helpText: m.notifications_slack_bot_name_help()+ },+ {+ kind: 'input',+ key: 'channel',+ id: 'slack-channel',+ label: m.notifications_slack_channel_label(),+ placeholder: m.notifications_slack_channel_placeholder(),+ helpText: m.notifications_slack_channel_help()+ }+ ]+ },+ {+ kind: 'row',+ className: 'grid grid-cols-2 gap-4',+ fields: [+ {+ kind: 'input',+ key: 'icon',+ id: 'slack-icon',+ label: m.notifications_slack_icon_label(),+ placeholder: m.notifications_slack_icon_placeholder(),+ helpText: m.notifications_slack_icon_help()+ },+ {+ kind: 'input',+ key: 'color',+ id: 'slack-color',+ label: m.notifications_slack_color_label(),+ placeholder: m.notifications_slack_color_placeholder(),+ helpText: m.notifications_slack_color_help()+ }+ ]+ },+ {+ kind: 'row',+ className: 'grid grid-cols-2 gap-4',+ fields: [+ {+ kind: 'input',+ key: 'title',+ id: 'slack-title',+ label: m.notifications_slack_title_label(),+ placeholder: m.notifications_slack_title_placeholder(),+ helpText: m.notifications_slack_title_help()+ },+ {+ kind: 'input',+ key: 'threadTs',+ id: 'slack-thread-ts',+ label: m.notifications_slack_thread_ts_label(),+ placeholder: m.notifications_slack_thread_ts_placeholder(),+ helpText: m.notifications_slack_thread_ts_help()+ }+ ]+ }+ ],+ ntfy: [+ {+ kind: 'input',+ key: 'host',+ id: 'ntfy-host',+ label: m.notifications_ntfy_host_label(),+ placeholder: m.notifications_ntfy_host_placeholder(),+ helpText: m.notifications_ntfy_host_help()+ },+ {+ kind: 'input',+ key: 'port',+ id: 'ntfy-port',+ label: m.notifications_ntfy_port_label(),+ placeholder: m.notifications_ntfy_port_placeholder(),+ helpText: m.notifications_ntfy_port_help(),+ inputType: 'number'+ },+ {+ kind: 'input',+ key: 'topic',+ id: 'ntfy-topic',+ label: m.notifications_ntfy_topic_label(),+ placeholder: m.notifications_ntfy_topic_placeholder(),+ helpText: m.notifications_ntfy_topic_help()+ },+ {+ kind: 'input',+ key: 'username',+ id: 'ntfy-username',+ label: m.notifications_ntfy_username_label(),+ placeholder: m.notifications_ntfy_username_placeholder(),+ helpText: m.notifications_ntfy_username_help()+ },+ {+ kind: 'input',+ key: 'password',+ id: 'ntfy-password',+ label: m.notifications_ntfy_password_label(),+ placeholder: m.notifications_ntfy_password_placeholder(),+ helpText: m.notifications_ntfy_password_help(),+ inputType: 'password'+ },+ {+ kind: 'native-select',+ key: 'priority',+ id: 'ntfy-priority',+ label: m.notifications_ntfy_priority_label(),+ description: m.notifications_ntfy_priority_help(),+ options: [+ { value: 'min', label: 'Min (1)' },+ { value: 'low', label: 'Low (2)' },+ { value: 'default', label: 'Default (3)' },+ { value: 'high', label: 'High (4)' },+ { value: 'max', label: 'Max/Urgent (5)' }+ ]+ },+ {+ kind: 'textarea',+ key: 'tags',+ id: 'ntfy-tags',+ label: m.notifications_ntfy_tags_label(),+ placeholder: m.notifications_ntfy_tags_placeholder(),+ helpText: m.notifications_ntfy_tags_help(),+ rows: 2+ },+ {+ kind: 'input',+ key: 'icon',+ id: 'ntfy-icon',+ label: m.notifications_ntfy_icon_label(),+ placeholder: m.notifications_ntfy_icon_placeholder(),+ helpText: m.notifications_ntfy_icon_help()+ },+ {+ kind: 'row',+ className: 'space-y-3',+ fields: [+ {+ kind: 'switch',+ key: 'cache',+ id: 'ntfy-cache',+ label: m.notifications_ntfy_cache_label(),+ description: m.notifications_ntfy_cache_help()+ },+ {+ kind: 'switch',+ key: 'firebase',+ id: 'ntfy-firebase',+ label: m.notifications_ntfy_firebase_label(),+ description: m.notifications_ntfy_firebase_help()+ },+ {+ kind: 'switch',+ key: 'disableTlsVerification',+ id: 'ntfy-disable-tls',+ label: m.notifications_ntfy_disable_tls_label(),+ description: m.notifications_ntfy_disable_tls_help()+ }+ ]+ }+ ],+ pushover: [+ {+ kind: 'input',+ key: 'token',+ id: 'pushover-token',+ label: m.notifications_pushover_token_label(),+ placeholder: m.notifications_pushover_token_placeholder(),+ helpText: m.notifications_pushover_token_help(),+ inputType: 'password'+ },+ {+ kind: 'input',+ key: 'user',+ id: 'pushover-user',+ label: m.notifications_pushover_user_label(),+ placeholder: m.notifications_pushover_user_placeholder(),+ helpText: m.notifications_pushover_user_help()+ },+ {+ kind: 'textarea',+ key: 'devices',+ id: 'pushover-devices',+ label: m.notifications_pushover_devices_label(),+ placeholder: m.notifications_pushover_devices_placeholder(),+ helpText: m.notifications_pushover_devices_help(),+ rows: 2+ },+ {+ kind: 'select',+ key: 'priority',+ id: 'pushover-priority',+ label: m.notifications_pushover_priority_label(),+ description: m.notifications_pushover_priority_help(),+ valueType: 'number',+ options: [+ { value: '-2', label: '-2' },+ { value: '-1', label: '-1' },+ { value: '0', label: '0' },+ { value: '1', label: '1' },+ { value: '2', label: '2' }+ ]+ },+ {+ kind: 'input',+ key: 'title',+ id: 'pushover-title',+ label: m.notifications_pushover_title_label(),+ placeholder: m.notifications_pushover_title_placeholder(),+ helpText: m.notifications_pushover_title_help()+ }+ ],+ gotify: [+ {+ kind: 'row',+ className: 'grid grid-cols-1 gap-4 md:grid-cols-4',+ fields: [+ {+ kind: 'input',+ key: 'host',+ id: 'gotify-host',+ label: m.notifications_gotify_host_label(),+ placeholder: m.notifications_gotify_host_placeholder(),+ helpText: m.notifications_gotify_host_help(),+ wrapperClass: 'md:col-span-3'+ },+ {+ kind: 'input',+ key: 'port',+ id: 'gotify-port',+ label: m.notifications_gotify_port_label(),+ placeholder: m.notifications_gotify_port_placeholder(),+ helpText: m.notifications_gotify_port_help(),+ inputType: 'number',+ wrapperClass: 'md:col-span-1'+ }+ ]+ },+ {+ kind: 'input',+ key: 'token',+ id: 'gotify-token',+ label: m.notifications_gotify_token_label(),+ placeholder: m.notifications_gotify_token_placeholder(),+ helpText: m.notifications_gotify_token_help(),+ inputType: 'password'+ },+ {+ kind: 'input',+ key: 'path',+ id: 'gotify-path',+ label: m.notifications_gotify_path_label(),+ placeholder: m.notifications_gotify_path_placeholder(),+ helpText: m.notifications_gotify_path_help()+ },+ {+ kind: 'select',+ key: 'priority',+ id: 'gotify-priority',+ label: m.notifications_gotify_priority_label(),+ description: m.notifications_gotify_priority_help(),+ valueType: 'number',+ options: [+ { value: '-2', label: '-2 (Min)' },+ { value: '-1', label: '-1 (Low)' },+ { value: '0', label: '0 (None)' },+ { value: '1', label: '1 (Low)' },+ { value: '2', label: '2' },+ { value: '3', label: '3' },+ { value: '4', label: '4 (Normal)' },+ { value: '5', label: '5' },+ { value: '6', label: '6' },+ { value: '7', label: '7 (High)' },+ { value: '8', label: '8' },+ { value: '9', label: '9' },+ { value: '10', label: '10 (Max)' }+ ]+ },+ {+ kind: 'input',+ key: 'title',+ id: 'gotify-title',+ label: m.notifications_gotify_title_label(),+ placeholder: m.notifications_gotify_title_placeholder(),+ helpText: m.notifications_gotify_title_help()+ },+ {+ kind: 'switch',+ key: 'disableTls',+ id: 'gotify-disable-tls',+ label: m.notifications_gotify_disable_tls_label(),+ description: m.notifications_gotify_disable_tls_help()+ }+ ],+ matrix: [+ {+ kind: 'row',+ className: 'grid grid-cols-1 gap-4 md:grid-cols-4',+ fields: [+ {+ kind: 'input',+ key: 'host',+ id: 'matrix-host',+ label: m.notifications_matrix_host_label(),+ placeholder: m.notifications_matrix_host_placeholder(),+ helpText: m.notifications_matrix_host_help(),+ wrapperClass: 'md:col-span-3'+ },+ {+ kind: 'input',+ key: 'port',+ id: 'matrix-port',+ label: m.notifications_matrix_port_label(),+ placeholder: m.notifications_matrix_port_placeholder(),+ helpText: m.notifications_matrix_port_help(),+ inputType: 'number',+ wrapperClass: 'md:col-span-1'+ }+ ]+ },+ {+ kind: 'input',+ key: 'rooms',+ id: 'matrix-rooms',+ label: m.notifications_matrix_rooms_label(),+ placeholder: m.notifications_matrix_rooms_placeholder(),+ helpText: m.notifications_matrix_rooms_help()+ },+ {+ kind: 'input',+ key: 'username',+ id: 'matrix-username',+ label: m.notifications_matrix_username_label(),+ placeholder: m.notifications_matrix_username_placeholder(),+ helpText: m.notifications_matrix_username_help()+ },+ {+ kind: 'input',+ key: 'password',+ id: 'matrix-password',+ label: m.notifications_matrix_password_label(),+ placeholder: m.notifications_matrix_password_placeholder(),+ helpText: m.notifications_matrix_password_help(),+ inputType: 'password'+ },+ {+ kind: 'switch',+ key: 'disableTlsVerification',+ id: 'matrix-disable-tls',+ label: m.notifications_matrix_disable_tls_label(),+ description: m.notifications_matrix_disable_tls_help()+ }+ ],+ generic: [+ {+ kind: 'input',+ key: 'webhookUrl',+ id: 'generic-webhook-url',+ label: m.notifications_generic_webhook_url_label(),+ placeholder: m.notifications_generic_webhook_url_placeholder(),+ helpText: m.notifications_generic_webhook_url_help()+ },+ {+ kind: 'input',+ key: 'method',+ id: 'generic-method',+ label: m.notifications_generic_method_label(),+ placeholder: m.notifications_generic_method_placeholder(),+ helpText: m.notifications_generic_method_help()+ },+ {+ kind: 'input',+ key: 'contentType',+ id: 'generic-content-type',+ label: m.notifications_generic_content_type_label(),+ placeholder: m.notifications_generic_content_type_placeholder(),+ helpText: m.notifications_generic_content_type_help()+ },+ {+ kind: 'input',+ key: 'titleKey',+ id: 'generic-title-key',+ label: m.notifications_generic_title_key_label(),+ placeholder: m.notifications_generic_title_key_placeholder(),+ helpText: m.notifications_generic_title_key_help()+ },+ {+ kind: 'input',+ key: 'messageKey',+ id: 'generic-message-key',+ label: m.notifications_generic_message_key_label(),+ placeholder: m.notifications_generic_message_key_placeholder(),+ helpText: m.notifications_generic_message_key_help()+ },+ {+ kind: 'input',+ key: 'customHeaders',+ id: 'generic-custom-headers',+ label: m.notifications_generic_custom_headers_label(),+ placeholder: m.notifications_generic_custom_headers_placeholder(),+ helpText: m.notifications_generic_custom_headers_help()+ }+ ]+ };++ const testOptions: NotificationProviderTestOption[] = [+ { label: m.notifications_email_test_simple(), testType: 'simple' },+ { label: m.notifications_email_test_image_update(), testType: 'image-update' },+ { label: m.notifications_email_test_batch_image_update(), testType: 'batch-image-update' },+ { label: m.notifications_test_vulnerability_notification(), testType: 'vulnerability-found' },+ { label: m.notifications_test_prune_report_notification(), testType: 'prune-report' }+ ];++ const validation = $derived.by(() => providerSchemas[provider].safeParse(values));+ const fieldErrors = $derived.by(() =>+ mapZodFieldErrors<AnyBuiltInValues>(validation as z.ZodSafeParseResult<AnyBuiltInValues>)+ );+ const selectedSchema = $derived(providerFormSchemas[provider] as ProviderFormSchema<AnyBuiltInValues>);+ const selectedMeta = $derived(providerMeta[provider]);++ export function isValid(): boolean {+ return validation.success;+ }+</script>++<ProviderFormWrapper+ id={provider}+ title={selectedMeta.title}+ description={selectedMeta.description}+ enabledLabel={selectedMeta.enabledLabel}+ bind:enabled={values.enabled}+ {disabled}+>+ <DynamicProviderFormBuilder bind:values {disabled} errors={fieldErrors} schema={selectedSchema} />++ <EventSubscriptions+ providerId={provider}+ bind:eventImageUpdate={values.eventImageUpdate}+ bind:eventContainerUpdate={values.eventContainerUpdate}+ bind:eventVulnerabilityFound={values.eventVulnerabilityFound}+ bind:eventPruneReport={values.eventPruneReport}+ {disabled}+ />++ <NotificationProviderTestMenu {disabled} {isTesting} {onTest} options={testOptions} />+</ProviderFormWrapper>diff --git a/frontend/src/routes/(app)/settings/notifications/providers/DiscordProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/DiscordProviderForm.sveltedeleted file mode 100644index c4ed48651..000000000--- a/frontend/src/routes/(app)/settings/notifications/providers/DiscordProviderForm.svelte+++ /dev/null@@ -1,152 +0,0 @@-<script lang="ts">- import * as DropdownMenu from '$lib/components/ui/dropdown-menu';- import { ArcaneButton } from '$lib/components/arcane-button/index.js';- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';- import { m } from '$lib/paraglide/messages';- import { ArrowDownIcon, SendEmailIcon } from '$lib/icons';- import { z } from 'zod/v4';- import type { DiscordFormValues } from '$lib/types/notification-providers';- import ProviderFormWrapper from './ProviderFormWrapper.svelte';- import EventSubscriptions from './EventSubscriptions.svelte';-- interface Props {- values: DiscordFormValues;- disabled?: boolean;- isTesting?: boolean;- onTest?: (testType?: string) => void;- }-- let { values = $bindable(), disabled = false, isTesting = false, onTest }: Props = $props();-- const schema = z- .object({- enabled: z.boolean(),- webhookId: z.string(),- token: z.string(),- username: z.string(),- avatarUrl: z.string(),- eventImageUpdate: z.boolean(),- eventContainerUpdate: z.boolean(),- eventVulnerabilityFound: z.boolean(),- eventPruneReport: z.boolean()- })- .superRefine((d, ctx) => {- if (!d.enabled) return;- if (!d.webhookId.trim()) {- ctx.addIssue({ code: 'custom', message: 'Webhook ID is required when Discord is enabled', path: ['webhookId'] });- }- if (!d.token.trim()) {- ctx.addIssue({ code: 'custom', message: 'Webhook Token is required when Discord is enabled', path: ['token'] });- }- });-- const validation = $derived.by(() => schema.safeParse(values));-- const fieldErrors = $derived.by(() => {- const errs: Partial<Record<keyof DiscordFormValues, string>> = {};- if (validation.success) return errs;- for (const issue of validation.error.issues) {- const key = issue.path?.[0] as keyof DiscordFormValues | undefined;- if (!key || errs[key]) continue;- errs[key] = issue.message;- }- return errs;- });-- export function isValid(): boolean {- return validation.success;- }-</script>--<ProviderFormWrapper- id="discord"- title="Discord"- description={m.notifications_discord_description()}- enabledLabel={m.notifications_discord_enabled_label()}- bind:enabled={values.enabled}- {disabled}->- <TextInputWithLabel- bind:value={values.webhookId}- {disabled}- label={m.notifications_discord_webhook_id_label()}- placeholder={m.notifications_discord_webhook_id_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_discord_webhook_id_help()}- error={fieldErrors.webhookId}- />-- <TextInputWithLabel- bind:value={values.token}- {disabled}- label={m.notifications_discord_token_label()}- placeholder={m.notifications_discord_token_placeholder()}- type="password"- autocomplete="off"- helpText={m.notifications_discord_token_help()}- error={fieldErrors.token}- />-- <TextInputWithLabel- bind:value={values.username}- {disabled}- label={m.notifications_discord_username_label()}- placeholder={m.notifications_discord_username_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_discord_username_help()}- />-- <TextInputWithLabel- bind:value={values.avatarUrl}- {disabled}- label={m.notifications_discord_avatar_url_label()}- placeholder={m.notifications_discord_avatar_url_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_discord_avatar_url_help()}- />-- <EventSubscriptions- providerId="discord"- bind:eventImageUpdate={values.eventImageUpdate}- bind:eventContainerUpdate={values.eventContainerUpdate}- bind:eventVulnerabilityFound={values.eventVulnerabilityFound}- bind:eventPruneReport={values.eventPruneReport}- {disabled}- />-- {#if onTest}- <div class="pt-2">- <DropdownMenu.Root>- <DropdownMenu.Trigger>- <ArcaneButton- action="base"- tone="outline"- disabled={disabled || isTesting}- loading={isTesting}- icon={SendEmailIcon}- customLabel={m.notifications_test_notification()}- >- <ArrowDownIcon class="ml-2 size-4" />- </ArcaneButton>- </DropdownMenu.Trigger>- <DropdownMenu.Content align="start">- <DropdownMenu.Item onclick={() => onTest()}>- <SendEmailIcon class="size-4" />- {m.notifications_test_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('vulnerability-found')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_vulnerability_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('prune-report')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_prune_report_notification()}- </DropdownMenu.Item>- </DropdownMenu.Content>- </DropdownMenu.Root>- </div>- {/if}-</ProviderFormWrapper>diff --git a/frontend/src/routes/(app)/settings/notifications/providers/DynamicProviderFormBuilder.svelte b/frontend/src/routes/(app)/settings/notifications/providers/DynamicProviderFormBuilder.sveltenew file mode 100644index 000000000..624112a5b--- /dev/null+++ b/frontend/src/routes/(app)/settings/notifications/providers/DynamicProviderFormBuilder.svelte@@ -0,0 +1,185 @@+<script lang="ts" generics="T extends object">+ import { Label } from '$lib/components/ui/label';+ import Textarea from '$lib/components/ui/textarea/textarea.svelte';+ import SelectWithLabel from '$lib/components/form/select-with-label.svelte';+ import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';+ import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';+ import type {+ ProviderFieldKey,+ ProviderFormField,+ ProviderFormSchema,+ ProviderNativeSelectField+ } from './provider-form-schema';++ interface Props {+ values: T;+ schema: ProviderFormSchema<T>;+ errors?: Partial<Record<keyof T, string>>;+ disabled?: boolean;+ }++ let { values = $bindable(), schema, errors = {}, disabled = false }: Props = $props();++ function getFieldId(field: ProviderFormField<T>): string {+ return field.id ?? String(field.key);+ }++ function getFieldError(field: ProviderFormField<T>): string | undefined {+ const key = (field.errorKey ?? field.key) as keyof T;+ return errors[key];+ }++ function getInputValue(key: ProviderFieldKey<T>): string | number {+ const value = values[key];+ if (typeof value === 'number') {+ return value;+ }++ return String(value ?? '');+ }++ function getStringValue(key: ProviderFieldKey<T>): string {+ return String(values[key] ?? '');+ }++ function getBooleanValue(key: ProviderFieldKey<T>): boolean {+ return Boolean(values[key]);+ }++ function setValue(key: ProviderFieldKey<T>, value: unknown): void {+ (values as Record<string, unknown>)[key] = value;+ }++ function setInputValue(field: Extract<ProviderFormField<T>, { kind: 'input' }>, value: string): void {+ if (field.inputType === 'number') {+ setValue(field.key, value === '' ? '' : Number(value));+ return;+ }++ setValue(field.key, value);+ }++ function setStringValue(key: ProviderFieldKey<T>, value: string): void {+ setValue(key, value);+ }++ function setBooleanValue(key: ProviderFieldKey<T>, value: boolean): void {+ setValue(key, value);+ }++ function setNativeSelectValue(field: ProviderNativeSelectField<T>, value: string): void {+ const currentValue = values[field.key];+ if (field.valueType === 'number' || typeof currentValue === 'number') {+ setValue(field.key, Number(value));+ return;+ }++ setValue(field.key, value);+ }++ function setSelectValue(field: Extract<ProviderFormField<T>, { kind: 'select' }>, value: string): void {+ const currentValue = values[field.key];+ if (field.valueType === 'number' || typeof currentValue === 'number') {+ setValue(field.key, Number(value));+ return;+ }++ setValue(field.key, value);+ }+</script>++{#snippet renderField(field: ProviderFormField<T>)}+ {#if field.kind === 'input'}+ <TextInputWithLabel+ id={getFieldId(field)}+ value={getInputValue(field.key)}+ onChange={(value) => setInputValue(field, value)}+ {disabled}+ label={field.label}+ placeholder={field.placeholder ?? ''}+ type={field.inputType ?? 'text'}+ autocomplete={field.autocomplete ?? 'off'}+ helpText={field.helpText}+ error={getFieldError(field)}+ required={field.required ?? false}+ />+ {:else if field.kind === 'textarea'}+ <div class="space-y-2">+ <Label for={getFieldId(field)}>{field.label}</Label>+ <Textarea+ id={getFieldId(field)}+ value={getStringValue(field.key)}+ oninput={(event) => setStringValue(field.key, (event.target as HTMLTextAreaElement).value)}+ {disabled}+ autocomplete={field.autocomplete ?? 'off'}+ placeholder={field.placeholder ?? ''}+ rows={field.rows ?? 2}+ />+ {#if getFieldError(field)}+ <p class="text-destructive text-sm">{getFieldError(field)}</p>+ {:else if field.helpText}+ <p class="text-muted-foreground text-sm">{field.helpText}</p>+ {/if}+ </div>+ {:else if field.kind === 'switch'}+ <SwitchWithLabel+ id={getFieldId(field)}+ checked={getBooleanValue(field.key)}+ onCheckedChange={(value) => setBooleanValue(field.key, value)}+ {disabled}+ label={field.label}+ description={field.description}+ error={getFieldError(field)}+ />+ {:else if field.kind === 'select'}+ <SelectWithLabel+ id={getFieldId(field)}+ value={getStringValue(field.key)}+ onValueChange={(value) => setSelectValue(field, value)}+ {disabled}+ label={field.label}+ placeholder={field.placeholder}+ description={field.description}+ error={getFieldError(field)}+ options={field.options}+ />+ {:else if field.kind === 'native-select'}+ <div class="space-y-2">+ <Label for={getFieldId(field)}>{field.label}</Label>+ <select+ id={getFieldId(field)}+ value={getStringValue(field.key)}+ onchange={(event) => setNativeSelectValue(field, (event.target as HTMLSelectElement).value)}+ {disabled}+ class="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 rounded-md border px-3 py-2 text-base focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"+ >+ {#each field.options as option (option.value)}+ <option value={option.value}>{option.label}</option>+ {/each}+ </select>+ {#if getFieldError(field)}+ <p class="text-destructive text-sm">{getFieldError(field)}</p>+ {:else if field.description}+ <p class="text-muted-foreground text-sm">{field.description}</p>+ {/if}+ </div>+ {/if}+{/snippet}++{#each schema as node, index (`${index}-${node.kind}`)}+ {#if node.kind === 'row'}+ <div class={node.className ?? 'grid grid-cols-2 gap-4'}>+ {#each node.fields as field, fieldIndex (`${fieldIndex}-${field.key}`)}+ <div class={field.wrapperClass ?? ''}>+ {@render renderField(field)}+ </div>+ {/each}+ </div>+ {:else if node.wrapperClass}+ <div class={node.wrapperClass}>+ {@render renderField(node)}+ </div>+ {:else}+ {@render renderField(node)}+ {/if}+{/each}diff --git a/frontend/src/routes/(app)/settings/notifications/providers/EmailProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/EmailProviderForm.sveltedeleted file mode 100644index 1e024b278..000000000--- a/frontend/src/routes/(app)/settings/notifications/providers/EmailProviderForm.svelte+++ /dev/null@@ -1,244 +0,0 @@-<script lang="ts">- import * as DropdownMenu from '$lib/components/ui/dropdown-menu';- import { ArcaneButton } from '$lib/components/arcane-button/index.js';- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';- import SelectWithLabel from '$lib/components/form/select-with-label.svelte';- import { Label } from '$lib/components/ui/label';- import Textarea from '$lib/components/ui/textarea/textarea.svelte';- import { m } from '$lib/paraglide/messages';- import { ArrowDownIcon, SendEmailIcon } from '$lib/icons';- import { z } from 'zod/v4';- import type { EmailFormValues } from '$lib/types/notification-providers';- import ProviderFormWrapper from './ProviderFormWrapper.svelte';- import EventSubscriptions from './EventSubscriptions.svelte';-- interface Props {- values: EmailFormValues;- disabled?: boolean;- isTesting?: boolean;- onTest?: (testType: string) => void;- }-- let { values = $bindable(), disabled = false, isTesting = false, onTest }: Props = $props();-- const schema = z- .object({- enabled: z.boolean(),- smtpHost: z.string(),- smtpPort: z.coerce.number().int().min(1).max(65535),- smtpUsername: z.string(),- smtpPassword: z.string(),- fromAddress: z.string(),- toAddresses: z.string(),- tlsMode: z.enum(['none', 'starttls', 'ssl']),- eventImageUpdate: z.boolean(),- eventContainerUpdate: z.boolean(),- eventVulnerabilityFound: z.boolean(),- eventPruneReport: z.boolean()- })- .superRefine((d, ctx) => {- if (!d.enabled) return;- if (!d.smtpHost.trim()) {- ctx.addIssue({ code: 'custom', message: 'SMTP host is required when email is enabled', path: ['smtpHost'] });- }- if (!d.fromAddress.trim()) {- ctx.addIssue({ code: 'custom', message: 'From address is required when email is enabled', path: ['fromAddress'] });- } else {- const v = z.string().email().safeParse(d.fromAddress.trim());- if (!v.success) {- ctx.addIssue({ code: 'custom', message: 'Invalid email address format', path: ['fromAddress'] });- }- }- if (!d.toAddresses.trim()) {- ctx.addIssue({- code: 'custom',- message: 'At least one recipient address is required when email is enabled',- path: ['toAddresses']- });- } else {- const addresses = d.toAddresses- .split(',')- .map((addr) => addr.trim())- .filter((addr) => addr.length > 0);- const invalid: string[] = [];- addresses.forEach((addr) => {- const v = z.string().email().safeParse(addr);- if (!v.success) invalid.push(addr);- });- if (invalid.length > 0) {- ctx.addIssue({- code: 'custom',- message: `Invalid email addresses: ${invalid.join(', ')}`,- path: ['toAddresses']- });- }- }- });-- const validation = $derived.by(() => schema.safeParse(values));-- const fieldErrors = $derived.by(() => {- const errs: Partial<Record<keyof EmailFormValues, string>> = {};- if (validation.success) return errs;- for (const issue of validation.error.issues) {- const key = issue.path?.[0] as keyof EmailFormValues | undefined;- if (!key || errs[key]) continue;- errs[key] = issue.message;- }- return errs;- });-- export function isValid(): boolean {- return validation.success;- }-</script>--<ProviderFormWrapper- id="email"- title="Email"- description={m.notifications_email_description()}- enabledLabel={m.notifications_email_enabled_label()}- bind:enabled={values.enabled}- {disabled}->- <div class="grid grid-cols-2 gap-4">- <TextInputWithLabel- bind:value={values.smtpHost}- {disabled}- label={m.notifications_email_smtp_host_label()}- placeholder={m.notifications_email_smtp_host_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_email_smtp_host_help()}- error={fieldErrors.smtpHost}- />-- <div class="space-y-2">- <Label for="smtp-port">{m.notifications_email_smtp_port_label()}</Label>- <input- id="smtp-port"- type="number"- class="border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"- bind:value={values.smtpPort}- {disabled}- autocomplete="off"- placeholder={m.notifications_email_smtp_port_placeholder()}- />- <p class="text-muted-foreground text-sm">{m.notifications_email_smtp_port_help()}</p>- </div>- </div>-- <div class="grid grid-cols-2 gap-4">- <TextInputWithLabel- bind:value={values.smtpUsername}- {disabled}- label={m.notifications_email_username_label()}- placeholder={m.notifications_email_username_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_email_username_help()}- />-- <TextInputWithLabel- bind:value={values.smtpPassword}- {disabled}- label={m.notifications_email_password_label()}- placeholder={m.notifications_email_password_placeholder()}- type="password"- autocomplete="new-password"- helpText={m.notifications_email_password_help()}- />- </div>-- <TextInputWithLabel- bind:value={values.fromAddress}- {disabled}- label={m.notifications_email_from_address_label()}- placeholder={m.notifications_email_from_address_placeholder()}- type="email"- autocomplete="off"- helpText={m.notifications_email_from_address_help()}- error={fieldErrors.fromAddress}- />-- <div class="space-y-2">- <Label for="to-addresses">{m.notifications_email_to_addresses_label()}</Label>- <Textarea- id="to-addresses"- bind:value={values.toAddresses}- {disabled}- autocomplete="off"- placeholder={m.notifications_email_to_addresses_placeholder()}- rows={2}- />- {#if fieldErrors.toAddresses}- <p class="text-destructive text-sm">{fieldErrors.toAddresses}</p>- {:else}- <p class="text-muted-foreground text-sm">{m.notifications_email_to_addresses_help()}</p>- {/if}- </div>-- <SelectWithLabel- id="email-tls-mode"- label={m.notifications_email_tls_mode_label()}- bind:value={values.tlsMode}- {disabled}- placeholder={m.notifications_email_tls_mode_placeholder()}- options={[- { value: 'none', label: 'None' },- { value: 'starttls', label: 'StartTLS' },- { value: 'ssl', label: 'SSL/TLS' }- ]}- description={m.notifications_email_tls_mode_description()}- />-- <EventSubscriptions- providerId="email"- bind:eventImageUpdate={values.eventImageUpdate}- bind:eventContainerUpdate={values.eventContainerUpdate}- bind:eventVulnerabilityFound={values.eventVulnerabilityFound}- bind:eventPruneReport={values.eventPruneReport}- {disabled}- />-- {#if onTest}- <div class="pt-2">- <DropdownMenu.Root>- <DropdownMenu.Trigger>- <ArcaneButton- action="base"- tone="outline"- disabled={disabled || isTesting}- loading={isTesting}- icon={SendEmailIcon}- customLabel={m.notifications_test_notification()}- >- <ArrowDownIcon class="ml-2 size-4" />- </ArcaneButton>- </DropdownMenu.Trigger>- <DropdownMenu.Content align="start">- <DropdownMenu.Item onclick={() => onTest('simple')}>- <SendEmailIcon class="size-4" />- {m.notifications_email_test_simple()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('image-update')}>- <SendEmailIcon class="size-4" />- {m.notifications_email_test_image_update()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('batch-image-update')}>- <SendEmailIcon class="size-4" />- {m.notifications_email_test_batch_image_update()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('vulnerability-found')}>- <SendEmailIcon class="size-4" />- {m.notifications_email_test_vulnerability_found()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('prune-report')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_prune_report_notification()}- </DropdownMenu.Item>- </DropdownMenu.Content>- </DropdownMenu.Root>- </div>- {/if}-</ProviderFormWrapper>diff --git a/frontend/src/routes/(app)/settings/notifications/providers/GenericProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/GenericProviderForm.sveltedeleted file mode 100644index f507decec..000000000--- a/frontend/src/routes/(app)/settings/notifications/providers/GenericProviderForm.svelte+++ /dev/null@@ -1,174 +0,0 @@-<script lang="ts">- import * as DropdownMenu from '$lib/components/ui/dropdown-menu';- import { ArcaneButton } from '$lib/components/arcane-button/index.js';- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';- import { m } from '$lib/paraglide/messages';- import { ArrowDownIcon, SendEmailIcon } from '$lib/icons';- import { z } from 'zod/v4';- import type { GenericFormValues } from '$lib/types/notification-providers';- import ProviderFormWrapper from './ProviderFormWrapper.svelte';- import EventSubscriptions from './EventSubscriptions.svelte';-- interface Props {- values: GenericFormValues;- disabled?: boolean;- isTesting?: boolean;- onTest?: (testType?: string) => void;- }-- let { values = $bindable(), disabled = false, isTesting = false, onTest }: Props = $props();-- const schema = z- .object({- enabled: z.boolean(),- webhookUrl: z.string(),- method: z.string(),- contentType: z.string(),- titleKey: z.string(),- messageKey: z.string(),- customHeaders: z.string(),- eventImageUpdate: z.boolean(),- eventContainerUpdate: z.boolean(),- eventVulnerabilityFound: z.boolean(),- eventPruneReport: z.boolean()- })- .superRefine((d, ctx) => {- if (!d.enabled) return;- if (!d.webhookUrl.trim()) {- ctx.addIssue({- code: 'custom',- message: 'Webhook URL is required when Generic Webhook is enabled',- path: ['webhookUrl']- });- }- });-- const validation = $derived.by(() => schema.safeParse(values));-- const fieldErrors = $derived.by(() => {- const errs: Partial<Record<keyof GenericFormValues, string>> = {};- if (validation.success) return errs;- for (const issue of validation.error.issues) {- const key = issue.path?.[0] as keyof GenericFormValues | undefined;- if (!key || errs[key]) continue;- errs[key] = issue.message;- }- return errs;- });-- export function isValid(): boolean {- return validation.success;- }-</script>--<ProviderFormWrapper- id="generic"- title={m.notifications_generic_title()}- description={m.notifications_generic_description()}- enabledLabel={m.notifications_generic_enabled_label()}- bind:enabled={values.enabled}- {disabled}->- <TextInputWithLabel- bind:value={values.webhookUrl}- {disabled}- label={m.notifications_generic_webhook_url_label()}- placeholder={m.notifications_generic_webhook_url_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_generic_webhook_url_help()}- error={fieldErrors.webhookUrl}- />-- <TextInputWithLabel- bind:value={values.method}- {disabled}- label={m.notifications_generic_method_label()}- placeholder={m.notifications_generic_method_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_generic_method_help()}- />-- <TextInputWithLabel- bind:value={values.contentType}- {disabled}- label={m.notifications_generic_content_type_label()}- placeholder={m.notifications_generic_content_type_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_generic_content_type_help()}- />-- <TextInputWithLabel- bind:value={values.titleKey}- {disabled}- label={m.notifications_generic_title_key_label()}- placeholder={m.notifications_generic_title_key_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_generic_title_key_help()}- />-- <TextInputWithLabel- bind:value={values.messageKey}- {disabled}- label={m.notifications_generic_message_key_label()}- placeholder={m.notifications_generic_message_key_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_generic_message_key_help()}- />-- <TextInputWithLabel- bind:value={values.customHeaders}- {disabled}- label={m.notifications_generic_custom_headers_label()}- placeholder={m.notifications_generic_custom_headers_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_generic_custom_headers_help()}- />-- <EventSubscriptions- providerId="generic"- bind:eventImageUpdate={values.eventImageUpdate}- bind:eventContainerUpdate={values.eventContainerUpdate}- bind:eventVulnerabilityFound={values.eventVulnerabilityFound}- bind:eventPruneReport={values.eventPruneReport}- {disabled}- />-- {#if onTest}- <div class="pt-2">- <DropdownMenu.Root>- <DropdownMenu.Trigger>- <ArcaneButton- action="base"- tone="outline"- disabled={disabled || isTesting}- loading={isTesting}- icon={SendEmailIcon}- customLabel={m.notifications_test_notification()}- >- <ArrowDownIcon class="ml-2 size-4" />- </ArcaneButton>- </DropdownMenu.Trigger>- <DropdownMenu.Content align="start">- <DropdownMenu.Item onclick={() => onTest()}>- <SendEmailIcon class="size-4" />- {m.notifications_test_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('vulnerability-found')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_vulnerability_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('prune-report')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_prune_report_notification()}- </DropdownMenu.Item>- </DropdownMenu.Content>- </DropdownMenu.Root>- </div>- {/if}-</ProviderFormWrapper>diff --git a/frontend/src/routes/(app)/settings/notifications/providers/GotifyProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/GotifyProviderForm.sveltedeleted file mode 100644index 558389194..000000000--- a/frontend/src/routes/(app)/settings/notifications/providers/GotifyProviderForm.svelte+++ /dev/null@@ -1,227 +0,0 @@-<script lang="ts">- import * as DropdownMenu from '$lib/components/ui/dropdown-menu';- import { ArcaneButton } from '$lib/components/arcane-button/index.js';- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';- import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';- import { Label } from '$lib/components/ui/label';- import * as Select from '$lib/components/ui/select/index.js';- import { m } from '$lib/paraglide/messages';- import { ArrowDownIcon, SendEmailIcon } from '$lib/icons';- import { z } from 'zod/v4';- import type { GotifyFormValues } from '$lib/types/notification-providers';- import ProviderFormWrapper from './ProviderFormWrapper.svelte';- import EventSubscriptions from './EventSubscriptions.svelte';-- interface Props {- values: GotifyFormValues;- disabled?: boolean;- isTesting?: boolean;- onTest?: (testType?: string) => void;- }-- let { values = $bindable(), disabled = false, isTesting = false, onTest }: Props = $props();-- const priorityOptions = [- { value: '-2', label: '-2 (Min)' },- { value: '-1', label: '-1 (Low)' },- { value: '0', label: '0 (None)' },- { value: '1', label: '1 (Low)' },- { value: '2', label: '2' },- { value: '3', label: '3' },- { value: '4', label: '4 (Normal)' },- { value: '5', label: '5' },- { value: '6', label: '6' },- { value: '7', label: '7 (High)' },- { value: '8', label: '8' },- { value: '9', label: '9' },- { value: '10', label: '10 (Max)' }- ];-- const priorityValue = $derived(String(values.priority ?? 0));-- const schema = z- .object({- enabled: z.boolean(),- host: z.string(),- port: z.coerce.number().int().min(0).max(65535),- token: z.string(),- path: z.string(),- priority: z.coerce.number().int(),- title: z.string(),- disableTls: z.boolean(),- eventImageUpdate: z.boolean(),- eventContainerUpdate: z.boolean(),- eventVulnerabilityFound: z.boolean(),- eventPruneReport: z.boolean()- })- .superRefine((d, ctx) => {- if (!d.enabled) return;- if (!d.host.trim()) {- ctx.addIssue({ code: 'custom', message: m.common_required(), path: ['host'] });- }- if (!d.token.trim()) {- ctx.addIssue({ code: 'custom', message: m.common_required(), path: ['token'] });- }- });-- const validation = $derived.by(() => schema.safeParse(values));-- const selectedPriorityLabel = $derived(- priorityOptions.find((option) => option.value === priorityValue)?.label ?? priorityValue- );-- const fieldErrors = $derived.by(() => {- const errs: Partial<Record<keyof GotifyFormValues, string>> = {};- if (validation.success) return errs;- for (const issue of validation.error.issues) {- const key = issue.path?.[0] as keyof GotifyFormValues | undefined;- if (!key || errs[key]) continue;- errs[key] = issue.message;- }- return errs;- });-- export function isValid(): boolean {- return validation.success;- }-</script>--<ProviderFormWrapper- id="gotify"- title="Gotify"- description={m.notifications_gotify_description()}- enabledLabel={m.notifications_gotify_enabled_label()}- bind:enabled={values.enabled}- {disabled}->- <div class="grid grid-cols-1 gap-4 md:grid-cols-4">- <div class="md:col-span-3">- <TextInputWithLabel- bind:value={values.host}- {disabled}- label={m.notifications_gotify_host_label()}- placeholder={m.notifications_gotify_host_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_gotify_host_help()}- error={fieldErrors.host}- />- </div>- <div class="md:col-span-1">- <TextInputWithLabel- bind:value={values.port}- {disabled}- label={m.notifications_gotify_port_label()}- placeholder={m.notifications_gotify_port_placeholder()}- type="number"- autocomplete="off"- helpText={m.notifications_gotify_port_help()}- error={fieldErrors.port}- />- </div>- </div>-- <TextInputWithLabel- bind:value={values.token}- {disabled}- label={m.notifications_gotify_token_label()}- placeholder={m.notifications_gotify_token_placeholder()}- type="password"- autocomplete="off"- helpText={m.notifications_gotify_token_help()}- error={fieldErrors.token}- />-- <TextInputWithLabel- bind:value={values.path}- {disabled}- label={m.notifications_gotify_path_label()}- placeholder={m.notifications_gotify_path_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_gotify_path_help()}- error={fieldErrors.path}- />-- <div class="space-y-2">- <Label for="gotify-priority">{m.notifications_gotify_priority_label()}</Label>- <Select.Root- type="single"- value={priorityValue}- {disabled}- onValueChange={(value) => {- values.priority = Number(value);- }}- >- <Select.Trigger id="gotify-priority" class="h-10 w-full">- <span>{selectedPriorityLabel}</span>- </Select.Trigger>- <Select.Content>- {#each priorityOptions as option (option.value)}- <Select.Item value={option.value}>{option.label}</Select.Item>- {/each}- </Select.Content>- </Select.Root>- <p class="text-muted-foreground text-sm">{m.notifications_gotify_priority_help()}</p>- </div>-- <TextInputWithLabel- bind:value={values.title}- {disabled}- label={m.notifications_gotify_title_label()}- placeholder={m.notifications_gotify_title_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_gotify_title_help()}- />-- <SwitchWithLabel- id="gotify-disable-tls"- bind:checked={values.disableTls}- {disabled}- label={m.notifications_gotify_disable_tls_label()}- description={m.notifications_gotify_disable_tls_help()}- />-- <EventSubscriptions- providerId="gotify"- bind:eventImageUpdate={values.eventImageUpdate}- bind:eventContainerUpdate={values.eventContainerUpdate}- bind:eventVulnerabilityFound={values.eventVulnerabilityFound}- bind:eventPruneReport={values.eventPruneReport}- {disabled}- />-- {#if onTest}- <div class="pt-2">- <DropdownMenu.Root>- <DropdownMenu.Trigger>- <ArcaneButton- action="base"- tone="outline"- disabled={disabled || isTesting}- loading={isTesting}- icon={SendEmailIcon}- customLabel={m.notifications_test_notification()}- >- <ArrowDownIcon class="ml-2 size-4" />- </ArcaneButton>- </DropdownMenu.Trigger>- <DropdownMenu.Content align="start">- <DropdownMenu.Item onclick={() => onTest()}>- <SendEmailIcon class="size-4" />- {m.notifications_test_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('vulnerability-found')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_vulnerability_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('prune-report')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_prune_report_notification()}- </DropdownMenu.Item>- </DropdownMenu.Content>- </DropdownMenu.Root>- </div>- {/if}-</ProviderFormWrapper>diff --git a/frontend/src/routes/(app)/settings/notifications/providers/MatrixProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/MatrixProviderForm.sveltedeleted file mode 100644index 721a641b5..000000000--- a/frontend/src/routes/(app)/settings/notifications/providers/MatrixProviderForm.svelte+++ /dev/null@@ -1,180 +0,0 @@-<script lang="ts">- import * as DropdownMenu from '$lib/components/ui/dropdown-menu';- import { ArcaneButton } from '$lib/components/arcane-button/index.js';- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';- import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';- import { Label } from '$lib/components/ui/label';- import * as Select from '$lib/components/ui/select/index.js';- import { m } from '$lib/paraglide/messages';- import { ArrowDownIcon, SendEmailIcon } from '$lib/icons';- import { z } from 'zod/v4';- import type { MatrixFormValues } from '$lib/types/notification-providers';- import ProviderFormWrapper from './ProviderFormWrapper.svelte';- import EventSubscriptions from './EventSubscriptions.svelte';-- interface Props {- values: MatrixFormValues;- disabled?: boolean;- isTesting?: boolean;- onTest?: (testType?: string) => void;- }-- let { values = $bindable(), disabled = false, isTesting = false, onTest }: Props = $props();-- const schema = z- .object({- enabled: z.boolean(),- host: z.string(),- port: z.coerce.number().int().min(0).max(65535),- rooms: z.string(),- username: z.string(),- password: z.string(),- disableTlsVerification: z.boolean(),- eventImageUpdate: z.boolean(),- eventContainerUpdate: z.boolean(),- eventVulnerabilityFound: z.boolean(),- eventPruneReport: z.boolean()- })- .superRefine((d, ctx) => {- if (!d.enabled) return;- if (!d.host.trim()) {- ctx.addIssue({ code: 'custom', message: m.common_required(), path: ['host'] });- }- });-- const validation = $derived.by(() => schema.safeParse(values));-- const fieldErrors = $derived.by(() => {- const errs: Partial<Record<keyof MatrixFormValues, string>> = {};- if (validation.success) return errs;- for (const issue of validation.error.issues) {- const key = issue.path?.[0] as keyof MatrixFormValues | undefined;- if (!key || errs[key]) continue;- errs[key] = issue.message;- }- return errs;- });-- export function isValid(): boolean {- return validation.success;- }-</script>--<ProviderFormWrapper- id="matrix"- title="Matrix"- description={m.notifications_matrix_description()}- enabledLabel={m.notifications_matrix_enabled_label()}- bind:enabled={values.enabled}- {disabled}->- <div class="grid grid-cols-1 gap-4 md:grid-cols-4">- <div class="md:col-span-3">- <TextInputWithLabel- bind:value={values.host}- {disabled}- label={m.notifications_matrix_host_label()}- placeholder={m.notifications_matrix_host_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_matrix_host_help()}- error={fieldErrors.host}- />- </div>- <div class="md:col-span-1">- <TextInputWithLabel- bind:value={values.port}- {disabled}- label={m.notifications_matrix_port_label()}- placeholder={m.notifications_matrix_port_placeholder()}- type="number"- autocomplete="off"- helpText={m.notifications_matrix_port_help()}- error={fieldErrors.port}- />- </div>- </div>-- <TextInputWithLabel- bind:value={values.rooms}- {disabled}- label={m.notifications_matrix_rooms_label()}- placeholder={m.notifications_matrix_rooms_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_matrix_rooms_help()}- error={fieldErrors.rooms}- />-- <TextInputWithLabel- bind:value={values.username}- {disabled}- label={m.notifications_matrix_username_label()}- placeholder={m.notifications_matrix_username_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_matrix_username_help()}- error={fieldErrors.username}- />-- <TextInputWithLabel- bind:value={values.password}- {disabled}- label={m.notifications_matrix_password_label()}- placeholder={m.notifications_matrix_password_placeholder()}- type="password"- autocomplete="off"- helpText={m.notifications_matrix_password_help()}- error={fieldErrors.password}- />-- <SwitchWithLabel- id="matrix-disable-tls"- bind:checked={values.disableTlsVerification}- {disabled}- label={m.notifications_matrix_disable_tls_label()}- description={m.notifications_matrix_disable_tls_help()}- />-- <EventSubscriptions- providerId="matrix"- bind:eventImageUpdate={values.eventImageUpdate}- bind:eventContainerUpdate={values.eventContainerUpdate}- bind:eventVulnerabilityFound={values.eventVulnerabilityFound}- bind:eventPruneReport={values.eventPruneReport}- {disabled}- />-- {#if onTest}- <div class="pt-2">- <DropdownMenu.Root>- <DropdownMenu.Trigger>- <ArcaneButton- action="base"- tone="outline"- disabled={disabled || isTesting}- loading={isTesting}- icon={SendEmailIcon}- customLabel={m.notifications_test_notification()}- >- <ArrowDownIcon class="ml-2 size-4" />- </ArcaneButton>- </DropdownMenu.Trigger>- <DropdownMenu.Content align="start">- <DropdownMenu.Item onclick={() => onTest()}>- <SendEmailIcon class="size-4" />- {m.notifications_test_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('vulnerability-found')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_vulnerability_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('prune-report')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_prune_report_notification()}- </DropdownMenu.Item>- </DropdownMenu.Content>- </DropdownMenu.Root>- </div>- {/if}-</ProviderFormWrapper>diff --git a/frontend/src/routes/(app)/settings/notifications/providers/NotificationProviderTestMenu.svelte b/frontend/src/routes/(app)/settings/notifications/providers/NotificationProviderTestMenu.sveltenew file mode 100644index 000000000..330621852--- /dev/null+++ b/frontend/src/routes/(app)/settings/notifications/providers/NotificationProviderTestMenu.svelte@@ -0,0 +1,58 @@+<script lang="ts">+ import * as DropdownMenu from '$lib/components/ui/dropdown-menu';+ import { ArcaneButton } from '$lib/components/arcane-button/index.js';+ import { m } from '$lib/paraglide/messages';+ import { ArrowDownIcon, SendEmailIcon } from '$lib/icons';++ export interface NotificationProviderTestOption {+ label: string;+ testType?: string;+ }++ interface Props {+ disabled?: boolean;+ isTesting?: boolean;+ onTest?: (testType?: string) => void;+ options?: NotificationProviderTestOption[];+ }++ let {+ disabled = false,+ isTesting = false,+ onTest,+ options = [+ { label: m.notifications_email_test_simple(), testType: 'simple' },+ { label: m.notifications_email_test_image_update(), testType: 'image-update' },+ { label: m.notifications_email_test_batch_image_update(), testType: 'batch-image-update' },+ { label: m.notifications_test_vulnerability_notification(), testType: 'vulnerability-found' },+ { label: m.notifications_test_prune_report_notification(), testType: 'prune-report' }+ ]+ }: Props = $props();+</script>++{#if onTest}+ <div class="pt-2">+ <DropdownMenu.Root>+ <DropdownMenu.Trigger>+ <ArcaneButton+ action="base"+ tone="outline"+ disabled={disabled || isTesting}+ loading={isTesting}+ icon={SendEmailIcon}+ customLabel={m.notifications_test_notification()}+ >+ <ArrowDownIcon class="ml-2 size-4" />+ </ArcaneButton>+ </DropdownMenu.Trigger>+ <DropdownMenu.Content align="start">+ {#each options as option (`${option.label}-${option.testType ?? 'default'}`)}+ <DropdownMenu.Item onclick={() => onTest(option.testType)}>+ <SendEmailIcon class="size-4" />+ {option.label}+ </DropdownMenu.Item>+ {/each}+ </DropdownMenu.Content>+ </DropdownMenu.Root>+ </div>+{/if}diff --git a/frontend/src/routes/(app)/settings/notifications/providers/NtfyProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/NtfyProviderForm.sveltedeleted file mode 100644index cb1873d1b..000000000--- a/frontend/src/routes/(app)/settings/notifications/providers/NtfyProviderForm.svelte+++ /dev/null@@ -1,235 +0,0 @@-<script lang="ts">- import * as DropdownMenu from '$lib/components/ui/dropdown-menu';- import { ArcaneButton } from '$lib/components/arcane-button/index.js';- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';- import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';- import { Label } from '$lib/components/ui/label';- import Textarea from '$lib/components/ui/textarea/textarea.svelte';- import { m } from '$lib/paraglide/messages';- import { ArrowDownIcon, SendEmailIcon } from '$lib/icons';- import { z } from 'zod/v4';- import type { NtfyFormValues } from '$lib/types/notification-providers';- import ProviderFormWrapper from './ProviderFormWrapper.svelte';- import EventSubscriptions from './EventSubscriptions.svelte';-- interface Props {- values: NtfyFormValues;- disabled?: boolean;- isTesting?: boolean;- onTest?: (testType?: string) => void;- }-- let { values = $bindable(), disabled = false, isTesting = false, onTest }: Props = $props();-- const schema = z- .object({- enabled: z.boolean(),- host: z.string(),- port: z.number().min(0).max(65535),- topic: z.string(),- username: z.string(),- password: z.string(),- priority: z.string(),- tags: z.string(),- icon: z.string(),- cache: z.boolean(),- firebase: z.boolean(),- disableTlsVerification: z.boolean(),- eventImageUpdate: z.boolean(),- eventContainerUpdate: z.boolean(),- eventVulnerabilityFound: z.boolean(),- eventPruneReport: z.boolean()- })- .superRefine((d, ctx) => {- if (!d.enabled) return;- if (!d.topic.trim()) {- ctx.addIssue({ code: 'custom', message: 'Topic is required when Ntfy is enabled', path: ['topic'] });- }- if (d.port > 0 && (d.port < 1 || d.port > 65535)) {- ctx.addIssue({ code: 'custom', message: 'Port must be between 1 and 65535', path: ['port'] });- }- });-- const validation = $derived.by(() => schema.safeParse(values));-- const fieldErrors = $derived.by(() => {- const errs: Partial<Record<keyof NtfyFormValues, string>> = {};- if (validation.success) return errs;- for (const issue of validation.error.issues) {- const key = issue.path?.[0] as keyof NtfyFormValues | undefined;- if (!key || errs[key]) continue;- errs[key] = issue.message;- }- return errs;- });-- export function isValid(): boolean {- return validation.success;- }-</script>--<ProviderFormWrapper- id="ntfy"- title="Ntfy"- description={m.notifications_ntfy_description()}- enabledLabel={m.notifications_ntfy_enabled_label()}- bind:enabled={values.enabled}- {disabled}->- <TextInputWithLabel- bind:value={values.host}- {disabled}- label={m.notifications_ntfy_host_label()}- placeholder={m.notifications_ntfy_host_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_ntfy_host_help()}- />-- <TextInputWithLabel- bind:value={values.port}- {disabled}- label={m.notifications_ntfy_port_label()}- placeholder={m.notifications_ntfy_port_placeholder()}- type="number"- autocomplete="off"- helpText={m.notifications_ntfy_port_help()}- />-- <TextInputWithLabel- bind:value={values.topic}- {disabled}- label={m.notifications_ntfy_topic_label()}- placeholder={m.notifications_ntfy_topic_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_ntfy_topic_help()}- error={fieldErrors.topic}- />-- <TextInputWithLabel- bind:value={values.username}- {disabled}- label={m.notifications_ntfy_username_label()}- placeholder={m.notifications_ntfy_username_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_ntfy_username_help()}- />-- <TextInputWithLabel- bind:value={values.password}- {disabled}- label={m.notifications_ntfy_password_label()}- placeholder={m.notifications_ntfy_password_placeholder()}- type="password"- autocomplete="off"- helpText={m.notifications_ntfy_password_help()}- />-- <div class="space-y-2">- <Label for="ntfy-priority">{m.notifications_ntfy_priority_label()}</Label>- <select- id="ntfy-priority"- bind:value={values.priority}- {disabled}- class="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 rounded-md border px-3 py-2 text-base focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"- >- <option value="min">Min (1)</option>- <option value="low">Low (2)</option>- <option value="default">Default (3)</option>- <option value="high">High (4)</option>- <option value="max">Max/Urgent (5)</option>- </select>- <p class="text-muted-foreground text-sm">{m.notifications_ntfy_priority_help()}</p>- </div>-- <div class="space-y-2">- <Label for="ntfy-tags">{m.notifications_ntfy_tags_label()}</Label>- <Textarea- id="ntfy-tags"- bind:value={values.tags}- {disabled}- autocomplete="off"- placeholder={m.notifications_ntfy_tags_placeholder()}- rows={2}- />- <p class="text-muted-foreground text-sm">{m.notifications_ntfy_tags_help()}</p>- </div>-- <TextInputWithLabel- bind:value={values.icon}- {disabled}- label={m.notifications_ntfy_icon_label()}- placeholder={m.notifications_ntfy_icon_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_ntfy_icon_help()}- />-- <div class="space-y-3">- <SwitchWithLabel- id="ntfy-cache"- bind:checked={values.cache}- {disabled}- label={m.notifications_ntfy_cache_label()}- description={m.notifications_ntfy_cache_help()}- />- <SwitchWithLabel- id="ntfy-firebase"- bind:checked={values.firebase}- {disabled}- label={m.notifications_ntfy_firebase_label()}- description={m.notifications_ntfy_firebase_help()}- />- <SwitchWithLabel- id="ntfy-disable-tls"- bind:checked={values.disableTlsVerification}- {disabled}- label={m.notifications_ntfy_disable_tls_label()}- description={m.notifications_ntfy_disable_tls_help()}- />- </div>-- <EventSubscriptions- providerId="ntfy"- bind:eventImageUpdate={values.eventImageUpdate}- bind:eventContainerUpdate={values.eventContainerUpdate}- bind:eventVulnerabilityFound={values.eventVulnerabilityFound}- bind:eventPruneReport={values.eventPruneReport}- {disabled}- />-- {#if onTest}- <div class="pt-2">- <DropdownMenu.Root>- <DropdownMenu.Trigger>- <ArcaneButton- action="base"- tone="outline"- disabled={disabled || isTesting}- loading={isTesting}- icon={SendEmailIcon}- customLabel={m.notifications_test_notification()}- >- <ArrowDownIcon class="ml-2 size-4" />- </ArcaneButton>- </DropdownMenu.Trigger>- <DropdownMenu.Content align="start">- <DropdownMenu.Item onclick={() => onTest()}>- <SendEmailIcon class="size-4" />- {m.notifications_test_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('vulnerability-found')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_vulnerability_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('prune-report')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_prune_report_notification()}- </DropdownMenu.Item>- </DropdownMenu.Content>- </DropdownMenu.Root>- </div>- {/if}-</ProviderFormWrapper>diff --git a/frontend/src/routes/(app)/settings/notifications/providers/PushoverProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/PushoverProviderForm.sveltedeleted file mode 100644index ccff5ecc7..000000000--- a/frontend/src/routes/(app)/settings/notifications/providers/PushoverProviderForm.svelte+++ /dev/null@@ -1,195 +0,0 @@-<script lang="ts">- import * as DropdownMenu from '$lib/components/ui/dropdown-menu';- import { ArcaneButton } from '$lib/components/arcane-button/index.js';- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';- import { Label } from '$lib/components/ui/label';- import Textarea from '$lib/components/ui/textarea/textarea.svelte';- import * as Select from '$lib/components/ui/select/index.js';- import { m } from '$lib/paraglide/messages';- import { ArrowDownIcon, SendEmailIcon } from '$lib/icons';- import { z } from 'zod/v4';- import type { PushoverFormValues } from '$lib/types/notification-providers';- import ProviderFormWrapper from './ProviderFormWrapper.svelte';- import EventSubscriptions from './EventSubscriptions.svelte';-- interface Props {- values: PushoverFormValues;- disabled?: boolean;- isTesting?: boolean;- onTest?: (testType?: string) => void;- }-- let { values = $bindable(), disabled = false, isTesting = false, onTest }: Props = $props();-- const priorityOptions = [- { value: '-2', label: '-2' },- { value: '-1', label: '-1' },- { value: '0', label: '0' },- { value: '1', label: '1' },- { value: '2', label: '2' }- ];-- const priorityValue = $derived(String(values.priority ?? 0));-- const schema = z- .object({- enabled: z.boolean(),- token: z.string(),- user: z.string(),- devices: z.string(),- priority: z.coerce.number().int().min(-2).max(2),- title: z.string(),- eventImageUpdate: z.boolean(),- eventContainerUpdate: z.boolean(),- eventVulnerabilityFound: z.boolean(),- eventPruneReport: z.boolean()- })- .superRefine((d, ctx) => {- if (!d.enabled) return;- if (!d.token.trim()) {- ctx.addIssue({ code: 'custom', message: m.common_required(), path: ['token'] });- }- if (!d.user.trim()) {- ctx.addIssue({ code: 'custom', message: m.common_required(), path: ['user'] });- }- });-- const validation = $derived.by(() => schema.safeParse(values));-- const selectedPriorityLabel = $derived(- priorityOptions.find((option) => option.value === priorityValue)?.label ?? priorityValue- );-- const fieldErrors = $derived.by(() => {- const errs: Partial<Record<keyof PushoverFormValues, string>> = {};- if (validation.success) return errs;- for (const issue of validation.error.issues) {- const key = issue.path?.[0] as keyof PushoverFormValues | undefined;- if (!key || errs[key]) continue;- errs[key] = issue.message;- }- return errs;- });-- export function isValid(): boolean {- return validation.success;- }-</script>--<ProviderFormWrapper- id="pushover"- title="Pushover"- description={m.notifications_pushover_description()}- enabledLabel={m.notifications_pushover_enabled_label()}- bind:enabled={values.enabled}- {disabled}->- <TextInputWithLabel- bind:value={values.token}- {disabled}- label={m.notifications_pushover_token_label()}- placeholder={m.notifications_pushover_token_placeholder()}- type="password"- autocomplete="off"- helpText={m.notifications_pushover_token_help()}- error={fieldErrors.token}- />-- <TextInputWithLabel- bind:value={values.user}- {disabled}- label={m.notifications_pushover_user_label()}- placeholder={m.notifications_pushover_user_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_pushover_user_help()}- error={fieldErrors.user}- />-- <div class="space-y-2">- <Label for="pushover-devices">{m.notifications_pushover_devices_label()}</Label>- <Textarea- id="pushover-devices"- bind:value={values.devices}- {disabled}- autocomplete="off"- placeholder={m.notifications_pushover_devices_placeholder()}- rows={2}- />- <p class="text-muted-foreground text-sm">{m.notifications_pushover_devices_help()}</p>- </div>-- <div class="space-y-2">- <Label for="pushover-priority">{m.notifications_pushover_priority_label()}</Label>- <Select.Root- type="single"- value={priorityValue}- {disabled}- onValueChange={(value) => {- values.priority = Number(value);- }}- >- <Select.Trigger id="pushover-priority" class="h-10 w-full">- <span>{selectedPriorityLabel}</span>- </Select.Trigger>- <Select.Content>- {#each priorityOptions as option (option.value)}- <Select.Item value={option.value}>{option.label}</Select.Item>- {/each}- </Select.Content>- </Select.Root>- <p class="text-muted-foreground text-sm">{m.notifications_pushover_priority_help()}</p>- </div>-- <TextInputWithLabel- bind:value={values.title}- {disabled}- label={m.notifications_pushover_title_label()}- placeholder={m.notifications_pushover_title_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_pushover_title_help()}- />-- <EventSubscriptions- providerId="pushover"- bind:eventImageUpdate={values.eventImageUpdate}- bind:eventContainerUpdate={values.eventContainerUpdate}- bind:eventVulnerabilityFound={values.eventVulnerabilityFound}- bind:eventPruneReport={values.eventPruneReport}- {disabled}- />-- {#if onTest}- <div class="pt-2">- <DropdownMenu.Root>- <DropdownMenu.Trigger>- <ArcaneButton- action="base"- tone="outline"- disabled={disabled || isTesting}- loading={isTesting}- icon={SendEmailIcon}- customLabel={m.notifications_test_notification()}- >- <ArrowDownIcon class="ml-2 size-4" />- </ArcaneButton>- </DropdownMenu.Trigger>- <DropdownMenu.Content align="start">- <DropdownMenu.Item onclick={() => onTest()}>- <SendEmailIcon class="size-4" />- {m.notifications_test_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('vulnerability-found')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_vulnerability_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('prune-report')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_prune_report_notification()}- </DropdownMenu.Item>- </DropdownMenu.Content>- </DropdownMenu.Root>- </div>- {/if}-</ProviderFormWrapper>diff --git a/frontend/src/routes/(app)/settings/notifications/providers/SignalProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/SignalProviderForm.sveltedeleted file mode 100644index 4607dc382..000000000--- a/frontend/src/routes/(app)/settings/notifications/providers/SignalProviderForm.svelte+++ /dev/null@@ -1,263 +0,0 @@-<script lang="ts">- import * as DropdownMenu from '$lib/components/ui/dropdown-menu';- import { ArcaneButton } from '$lib/components/arcane-button/index.js';- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';- import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';- import { Label } from '$lib/components/ui/label';- import Textarea from '$lib/components/ui/textarea/textarea.svelte';- import { m } from '$lib/paraglide/messages';- import { ArrowDownIcon, SendEmailIcon } from '$lib/icons';- import { z } from 'zod/v4';- import type { SignalFormValues } from '$lib/types/notification-providers';- import ProviderFormWrapper from './ProviderFormWrapper.svelte';- import EventSubscriptions from './EventSubscriptions.svelte';-- interface Props {- values: SignalFormValues;- disabled?: boolean;- isTesting?: boolean;- onTest?: (testType?: string) => void;- }-- let { values = $bindable(), disabled = false, isTesting = false, onTest }: Props = $props();-- const schema = z- .object({- enabled: z.boolean(),- host: z.string(),- port: z.number().min(1).max(65535),- user: z.string(),- password: z.string(),- token: z.string(),- source: z.string(),- recipients: z.string(),- disableTls: z.boolean(),- eventImageUpdate: z.boolean(),- eventContainerUpdate: z.boolean(),- eventVulnerabilityFound: z.boolean(),- eventPruneReport: z.boolean()- })- .superRefine((d, ctx) => {- if (!d.enabled) return;-- // Host is required when enabled- if (!d.host.trim()) {- ctx.addIssue({ code: 'custom', message: m.notifications_signal_host_required(), path: ['host'] });- }-- // Port validation- if (d.port < 1 || d.port > 65535) {- ctx.addIssue({ code: 'custom', message: m.notifications_signal_port_invalid(), path: ['port'] });- }-- // Source phone number is required- if (!d.source.trim()) {- ctx.addIssue({ code: 'custom', message: m.notifications_signal_source_required(), path: ['source'] });- } else if (!d.source.startsWith('+')) {- ctx.addIssue({ code: 'custom', message: m.notifications_signal_source_format(), path: ['source'] });- }-- // Recipients are required- if (!d.recipients.trim()) {- ctx.addIssue({ code: 'custom', message: m.notifications_signal_recipients_required(), path: ['recipients'] });- }-- // Either user+password or token is required- const hasBasicAuth = d.user.trim() && d.password.trim();- const hasTokenAuth = d.token.trim();- if (!hasBasicAuth && !hasTokenAuth) {- ctx.addIssue({- code: 'custom',- message: m.notifications_signal_auth_required(),- path: ['user']- });- }- if (hasBasicAuth && hasTokenAuth) {- ctx.addIssue({- code: 'custom',- message: m.notifications_signal_auth_conflict(),- path: ['token']- });- }- });-- const validation = $derived.by(() => schema.safeParse(values));-- const fieldErrors = $derived.by(() => {- const errs: Partial<Record<keyof SignalFormValues, string>> = {};- if (validation.success) return errs;- for (const issue of validation.error.issues) {- const key = issue.path?.[0] as keyof SignalFormValues | undefined;- if (!key || errs[key]) continue;- errs[key] = issue.message;- }- return errs;- });-- export function isValid(): boolean {- return validation.success;- }-</script>--<ProviderFormWrapper- id="signal"- title={m.notifications_signal_title()}- description={m.notifications_signal_description()}- enabledLabel={m.notifications_signal_enabled_label()}- bind:enabled={values.enabled}- {disabled}->- <div class="grid grid-cols-2 gap-4">- <TextInputWithLabel- bind:value={values.host}- {disabled}- label={m.notifications_signal_host_label()}- placeholder={m.notifications_signal_host_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_signal_host_help()}- error={fieldErrors.host}- />-- <TextInputWithLabel- bind:value={values.port}- {disabled}- label={m.notifications_signal_port_label()}- placeholder={m.notifications_signal_port_placeholder()}- type="number"- autocomplete="off"- helpText={m.notifications_signal_port_help()}- error={fieldErrors.port}- />- </div>-- <div class="space-y-4">- <div class="rounded-lg border p-4">- <h4 class="mb-3 text-sm font-medium">{m.notifications_signal_auth_section()}</h4>- <p class="text-muted-foreground mb-4 text-sm">{m.notifications_signal_auth_help()}</p>-- <div class="space-y-4">- <TextInputWithLabel- bind:value={values.user}- {disabled}- label={m.notifications_signal_user_label()}- placeholder={m.notifications_signal_user_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_signal_user_help()}- />-- <TextInputWithLabel- bind:value={values.password}- {disabled}- label={m.notifications_signal_password_label()}- placeholder={m.notifications_signal_password_placeholder()}- type="password"- autocomplete="off"- helpText={m.notifications_signal_password_help()}- />-- <div class="relative">- <div class="absolute inset-0 flex items-center">- <span class="w-full border-t"></span>- </div>- <div class="relative flex justify-center text-xs uppercase">- <span class="bg-background text-muted-foreground px-2">{m.notifications_signal_auth_or()}</span>- </div>- </div>-- <TextInputWithLabel- bind:value={values.token}- {disabled}- label={m.notifications_signal_token_label()}- placeholder={m.notifications_signal_token_placeholder()}- type="password"- autocomplete="off"- helpText={m.notifications_signal_token_help()}- />- </div>-- {#if fieldErrors.user || fieldErrors.token}- <p class="text-destructive mt-2 text-sm">{fieldErrors.user || fieldErrors.token}</p>- {/if}- </div>- </div>-- <TextInputWithLabel- bind:value={values.source}- {disabled}- label={m.notifications_signal_source_label()}- placeholder={m.notifications_signal_source_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_signal_source_help()}- error={fieldErrors.source}- />-- <div class="space-y-2">- <Label for="signal-recipients">{m.notifications_signal_recipients_label()}</Label>- <Textarea- id="signal-recipients"- bind:value={values.recipients}- {disabled}- autocomplete="off"- placeholder={m.notifications_signal_recipients_placeholder()}- rows={3}- />- {#if fieldErrors.recipients}- <p class="text-destructive text-sm">{fieldErrors.recipients}</p>- {:else}- <p class="text-muted-foreground text-sm">{m.notifications_signal_recipients_help()}</p>- {/if}- </div>-- <SwitchWithLabel- id="signal-disable-tls"- bind:checked={values.disableTls}- {disabled}- label={m.notifications_signal_disable_tls_label()}- description={m.notifications_signal_disable_tls_description()}- />-- <EventSubscriptions- providerId="signal"- bind:eventImageUpdate={values.eventImageUpdate}- bind:eventContainerUpdate={values.eventContainerUpdate}- bind:eventVulnerabilityFound={values.eventVulnerabilityFound}- bind:eventPruneReport={values.eventPruneReport}- {disabled}- />-- {#if onTest}- <div class="pt-2">- <DropdownMenu.Root>- <DropdownMenu.Trigger>- <ArcaneButton- action="base"- tone="outline"- disabled={disabled || isTesting}- loading={isTesting}- icon={SendEmailIcon}- customLabel={m.notifications_test_notification()}- >- <ArrowDownIcon class="ml-2 size-4" />- </ArcaneButton>- </DropdownMenu.Trigger>- <DropdownMenu.Content align="start">- <DropdownMenu.Item onclick={() => onTest()}>- <SendEmailIcon class="size-4" />- {m.notifications_test_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('vulnerability-found')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_vulnerability_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('prune-report')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_prune_report_notification()}- </DropdownMenu.Item>- </DropdownMenu.Content>- </DropdownMenu.Root>- </div>- {/if}-</ProviderFormWrapper>diff --git a/frontend/src/routes/(app)/settings/notifications/providers/SlackProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/SlackProviderForm.sveltedeleted file mode 100644index e1b220e08..000000000--- a/frontend/src/routes/(app)/settings/notifications/providers/SlackProviderForm.svelte+++ /dev/null@@ -1,189 +0,0 @@-<script lang="ts">- import * as DropdownMenu from '$lib/components/ui/dropdown-menu';- import { ArcaneButton } from '$lib/components/arcane-button/index.js';- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';- import { m } from '$lib/paraglide/messages';- import { ArrowDownIcon, SendEmailIcon } from '$lib/icons';- import { z } from 'zod/v4';- import type { SlackFormValues } from '$lib/types/notification-providers';- import ProviderFormWrapper from './ProviderFormWrapper.svelte';- import EventSubscriptions from './EventSubscriptions.svelte';-- interface Props {- values: SlackFormValues;- disabled?: boolean;- isTesting?: boolean;- onTest?: (testType?: string) => void;- }-- let { values = $bindable(), disabled = false, isTesting = false, onTest }: Props = $props();-- const schema = z- .object({- enabled: z.boolean(),- token: z.string(),- botName: z.string(),- icon: z.string(),- color: z.string(),- title: z.string(),- channel: z.string(),- threadTs: z.string(),- eventImageUpdate: z.boolean(),- eventContainerUpdate: z.boolean(),- eventVulnerabilityFound: z.boolean(),- eventPruneReport: z.boolean()- })- .superRefine((d, ctx) => {- if (!d.enabled) return;-- // Token is required when enabled- if (!d.token.trim()) {- ctx.addIssue({ code: 'custom', message: m.notifications_slack_token_required(), path: ['token'] });- }- });-- const validation = $derived.by(() => schema.safeParse(values));-- const fieldErrors = $derived.by(() => {- const errs: Partial<Record<keyof SlackFormValues, string>> = {};- if (validation.success) return errs;- for (const issue of validation.error.issues) {- const key = issue.path?.[0] as keyof SlackFormValues | undefined;- if (!key || errs[key]) continue;- errs[key] = issue.message;- }- return errs;- });-- export function isValid(): boolean {- return validation.success;- }-</script>--<ProviderFormWrapper- id="slack"- title={m.notifications_slack_title()}- description={m.notifications_slack_description()}- enabledLabel={m.notifications_slack_enabled_label()}- bind:enabled={values.enabled}- {disabled}->- <TextInputWithLabel- bind:value={values.token}- {disabled}- label={m.notifications_slack_token_label()}- placeholder={m.notifications_slack_token_placeholder()}- type="password"- autocomplete="off"- helpText={m.notifications_slack_token_help()}- error={fieldErrors.token}- />-- <div class="grid grid-cols-2 gap-4">- <TextInputWithLabel- bind:value={values.botName}- {disabled}- label={m.notifications_slack_bot_name_label()}- placeholder={m.notifications_slack_bot_name_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_slack_bot_name_help()}- />-- <TextInputWithLabel- bind:value={values.channel}- {disabled}- label={m.notifications_slack_channel_label()}- placeholder={m.notifications_slack_channel_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_slack_channel_help()}- />- </div>-- <div class="grid grid-cols-2 gap-4">- <TextInputWithLabel- bind:value={values.icon}- {disabled}- label={m.notifications_slack_icon_label()}- placeholder={m.notifications_slack_icon_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_slack_icon_help()}- />-- <TextInputWithLabel- bind:value={values.color}- {disabled}- label={m.notifications_slack_color_label()}- placeholder={m.notifications_slack_color_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_slack_color_help()}- />- </div>-- <div class="grid grid-cols-2 gap-4">- <TextInputWithLabel- bind:value={values.title}- {disabled}- label={m.notifications_slack_title_label()}- placeholder={m.notifications_slack_title_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_slack_title_help()}- />-- <TextInputWithLabel- bind:value={values.threadTs}- {disabled}- label={m.notifications_slack_thread_ts_label()}- placeholder={m.notifications_slack_thread_ts_placeholder()}- type="text"- autocomplete="off"- helpText={m.notifications_slack_thread_ts_help()}- />- </div>-- <EventSubscriptions- providerId="slack"- bind:eventImageUpdate={values.eventImageUpdate}- bind:eventContainerUpdate={values.eventContainerUpdate}- bind:eventVulnerabilityFound={values.eventVulnerabilityFound}- bind:eventPruneReport={values.eventPruneReport}- {disabled}- />-- {#if onTest}- <div class="pt-2">- <DropdownMenu.Root>- <DropdownMenu.Trigger>- <ArcaneButton- action="base"- tone="outline"- disabled={disabled || isTesting}- loading={isTesting}- icon={SendEmailIcon}- customLabel={m.notifications_test_notification()}- >- <ArrowDownIcon class="ml-2 size-4" />- </ArcaneButton>- </DropdownMenu.Trigger>- <DropdownMenu.Content align="start">- <DropdownMenu.Item onclick={() => onTest()}>- <SendEmailIcon class="size-4" />- {m.notifications_test_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('vulnerability-found')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_vulnerability_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('prune-report')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_prune_report_notification()}- </DropdownMenu.Item>- </DropdownMenu.Content>- </DropdownMenu.Root>- </div>- {/if}-</ProviderFormWrapper>diff --git a/frontend/src/routes/(app)/settings/notifications/providers/TelegramProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/TelegramProviderForm.sveltedeleted file mode 100644index 3173e4e60..000000000--- a/frontend/src/routes/(app)/settings/notifications/providers/TelegramProviderForm.svelte+++ /dev/null@@ -1,169 +0,0 @@-<script lang="ts">- import * as DropdownMenu from '$lib/components/ui/dropdown-menu';- import { ArcaneButton } from '$lib/components/arcane-button/index.js';- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';- import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';- import { Label } from '$lib/components/ui/label';- import Textarea from '$lib/components/ui/textarea/textarea.svelte';- import { m } from '$lib/paraglide/messages';- import { ArrowDownIcon, SendEmailIcon } from '$lib/icons';- import { z } from 'zod/v4';- import type { TelegramFormValues } from '$lib/types/notification-providers';- import ProviderFormWrapper from './ProviderFormWrapper.svelte';- import EventSubscriptions from './EventSubscriptions.svelte';-- interface Props {- values: TelegramFormValues;- disabled?: boolean;- isTesting?: boolean;- onTest?: (testType?: string) => void;- }-- let { values = $bindable(), disabled = false, isTesting = false, onTest }: Props = $props();-- const schema = z- .object({- enabled: z.boolean(),- botToken: z.string(),- chatIds: z.string(),- preview: z.boolean(),- notification: z.boolean(),- title: z.string(),- eventImageUpdate: z.boolean(),- eventContainerUpdate: z.boolean(),- eventVulnerabilityFound: z.boolean(),- eventPruneReport: z.boolean()- })- .superRefine((d, ctx) => {- if (!d.enabled) return;- if (!d.botToken.trim()) {- ctx.addIssue({ code: 'custom', message: 'Bot Token is required when Telegram is enabled', path: ['botToken'] });- }- if (!d.chatIds.trim()) {- ctx.addIssue({ code: 'custom', message: 'At least one Chat ID is required when Telegram is enabled', path: ['chatIds'] });- }- });-- const validation = $derived.by(() => schema.safeParse(values));-- const fieldErrors = $derived.by(() => {- const errs: Partial<Record<keyof TelegramFormValues, string>> = {};- if (validation.success) return errs;- for (const issue of validation.error.issues) {- const key = issue.path?.[0] as keyof TelegramFormValues | undefined;- if (!key || errs[key]) continue;- errs[key] = issue.message;- }- return errs;- });-- export function isValid(): boolean {- return validation.success;- }-</script>--<ProviderFormWrapper- id="telegram"- title="Telegram"- description="Send notifications via Telegram bot"- enabledLabel="Enable Telegram Notifications"- bind:enabled={values.enabled}- {disabled}->- <TextInputWithLabel- bind:value={values.botToken}- {disabled}- label="Bot Token"- placeholder="123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"- type="password"- autocomplete="off"- helpText="The bot token from @BotFather"- error={fieldErrors.botToken}- />-- <div class="space-y-2">- <Label for="telegram-chat-ids">Chat IDs</Label>- <Textarea- id="telegram-chat-ids"- bind:value={values.chatIds}- {disabled}- autocomplete="off"- placeholder="@channel, 123456789, @another_channel"- rows={2}- />- {#if fieldErrors.chatIds}- <p class="text-destructive text-sm">{fieldErrors.chatIds}</p>- {:else}- <p class="text-muted-foreground text-sm">Comma-separated list of chat IDs or @channel names</p>- {/if}- </div>-- <TextInputWithLabel- bind:value={values.title}- {disabled}- label="Title (Optional)"- placeholder="Arcane Notifications"- type="text"- autocomplete="off"- helpText="Custom title for notifications"- />-- <div class="space-y-3">- <SwitchWithLabel- id="telegram-preview"- bind:checked={values.preview}- {disabled}- label="Enable Link Previews"- description="Show web page previews for URLs in messages"- />- <SwitchWithLabel- id="telegram-notification"- bind:checked={values.notification}- {disabled}- label="Enable Notification Sound"- description="Play notification sound when messages are received"- />- </div>-- <EventSubscriptions- providerId="telegram"- bind:eventImageUpdate={values.eventImageUpdate}- bind:eventContainerUpdate={values.eventContainerUpdate}- bind:eventVulnerabilityFound={values.eventVulnerabilityFound}- bind:eventPruneReport={values.eventPruneReport}- {disabled}- />-- {#if onTest}- <div class="pt-2">- <DropdownMenu.Root>- <DropdownMenu.Trigger>- <ArcaneButton- action="base"- tone="outline"- disabled={disabled || isTesting}- loading={isTesting}- icon={SendEmailIcon}- customLabel={m.notifications_test_notification()}- >- <ArrowDownIcon class="ml-2 size-4" />- </ArcaneButton>- </DropdownMenu.Trigger>- <DropdownMenu.Content align="start">- <DropdownMenu.Item onclick={() => onTest()}>- <SendEmailIcon class="size-4" />- {m.notifications_test_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('vulnerability-found')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_vulnerability_notification()}- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => onTest('prune-report')}>- <SendEmailIcon class="size-4" />- {m.notifications_test_prune_report_notification()}- </DropdownMenu.Item>- </DropdownMenu.Content>- </DropdownMenu.Root>- </div>- {/if}-</ProviderFormWrapper>diff --git a/frontend/src/routes/(app)/settings/notifications/providers/index.ts b/frontend/src/routes/(app)/settings/notifications/providers/index.tsindex 6e09eb249..d508d18c4 100644--- a/frontend/src/routes/(app)/settings/notifications/providers/index.ts+++ b/frontend/src/routes/(app)/settings/notifications/providers/index.ts@@ -1,13 +1,6 @@-export { default as EmailProviderForm } from './EmailProviderForm.svelte';-export { default as DiscordProviderForm } from './DiscordProviderForm.svelte';-export { default as TelegramProviderForm } from './TelegramProviderForm.svelte';-export { default as SignalProviderForm } from './SignalProviderForm.svelte';-export { default as SlackProviderForm } from './SlackProviderForm.svelte';export { default as AppriseProviderForm } from './AppriseProviderForm.svelte';+export { default as BuiltInProviderForm } from './BuiltInProviderForm.svelte';export { default as ProviderFormWrapper } from './ProviderFormWrapper.svelte';export { default as EventSubscriptions } from './EventSubscriptions.svelte';-export { default as NtfyProviderForm } from './NtfyProviderForm.svelte';-export { default as PushoverProviderForm } from './PushoverProviderForm.svelte';-export { default as GotifyProviderForm } from './GotifyProviderForm.svelte';-export { default as MatrixProviderForm } from './MatrixProviderForm.svelte';-export { default as GenericProviderForm } from './GenericProviderForm.svelte';+export { default as DynamicProviderFormBuilder } from './DynamicProviderFormBuilder.svelte';+export { default as NotificationProviderTestMenu } from './NotificationProviderTestMenu.svelte';diff --git a/frontend/src/routes/(app)/settings/notifications/providers/provider-form-schema.ts b/frontend/src/routes/(app)/settings/notifications/providers/provider-form-schema.tsnew file mode 100644index 000000000..93ea29345--- /dev/null+++ b/frontend/src/routes/(app)/settings/notifications/providers/provider-form-schema.ts@@ -0,0 +1,75 @@+export type ProviderFieldValue = string | number | boolean | null | undefined;++export type ProviderFieldKey<T extends object> = Extract<keyof T, string>;++export interface ProviderSelectOption {+ value: string;+ label: string;+ description?: string;+}++interface ProviderFieldBase<T extends object> {+ key: ProviderFieldKey<T>;+ id?: string;+ wrapperClass?: string;+ errorKey?: ProviderFieldKey<T>;+}++export interface ProviderInputField<T extends object> extends ProviderFieldBase<T> {+ kind: 'input';+ label: string;+ placeholder?: string;+ helpText?: string;+ inputType?: 'text' | 'email' | 'password' | 'number' | 'url';+ autocomplete?: HTMLInputElement['autocomplete'];+ required?: boolean;+}++export interface ProviderTextareaField<T extends object> extends ProviderFieldBase<T> {+ kind: 'textarea';+ label: string;+ placeholder?: string;+ helpText?: string;+ rows?: number;+ autocomplete?: HTMLTextAreaElement['autocomplete'];+}++export interface ProviderSwitchField<T extends object> extends ProviderFieldBase<T> {+ kind: 'switch';+ label: string;+ description?: string;+}++export interface ProviderSelectField<T extends object> extends ProviderFieldBase<T> {+ kind: 'select';+ label: string;+ placeholder?: string;+ description?: string;+ valueType?: 'string' | 'number';+ options: ProviderSelectOption[];+}++export interface ProviderNativeSelectField<T extends object> extends ProviderFieldBase<T> {+ kind: 'native-select';+ label: string;+ description?: string;+ valueType?: 'string' | 'number';+ options: ProviderSelectOption[];+}++export type ProviderFormField<T extends object> =+ | ProviderInputField<T>+ | ProviderTextareaField<T>+ | ProviderSwitchField<T>+ | ProviderSelectField<T>+ | ProviderNativeSelectField<T>;++export interface ProviderFormRow<T extends object> {+ kind: 'row';+ className?: string;+ fields: ProviderFormField<T>[];+}++export type ProviderFormNode<T extends object> = ProviderFormField<T> | ProviderFormRow<T>;++export type ProviderFormSchema<T extends object> = ProviderFormNode<T>[];diff --git a/frontend/src/routes/(app)/settings/notifications/providers/provider-form-validation.ts b/frontend/src/routes/(app)/settings/notifications/providers/provider-form-validation.tsnew file mode 100644index 000000000..ea58a2861--- /dev/null+++ b/frontend/src/routes/(app)/settings/notifications/providers/provider-form-validation.ts@@ -0,0 +1,19 @@+import type { z } from 'zod/v4';++export function mapZodFieldErrors<T extends object>(validation: z.ZodSafeParseResult<T>): Partial<Record<keyof T, string>> {+ const errors: Partial<Record<keyof T, string>> = {};+ if (validation.success) {+ return errors;+ }++ for (const issue of validation.error.issues) {+ const key = issue.path?.[0] as keyof T | undefined;+ if (!key || errors[key]) {+ continue;+ }++ errors[key] = issue.message;+ }++ return errors;+}diff --git a/tests/spec/settings-notifications.spec.ts b/tests/spec/settings-notifications.spec.tsindex e35154d05..43c8f05d3 100644--- a/tests/spec/settings-notifications.spec.ts+++ b/tests/spec/settings-notifications.spec.ts@@ -69,7 +69,7 @@ test.describe('Notification settings', () => {// Trigger testawait page.locator('[data-dropdown-menu-trigger]').filter({ hasText: 'Test' }).click();- await page.getByRole('menuitem', { name: 'Simple Test Email', exact: true }).click();+ await page.getByRole('menuitem', { name: 'Simple Test Notification', exact: true }).click();// Handle Save & Test if neededconst saveAndTestButton = page.getByRole('button', { name: 'Save & Test', exact: true });@@ -92,7 +92,7 @@ test.describe('Notification settings', () => {await page.getByPlaceholder('Enter webhook token').fill('abc-def-ghi');await page.locator('[data-dropdown-menu-trigger]').filter({ hasText: 'Test Provider' }).click();- await page.getByRole('menuitem', { name: 'Test Provider', exact: true }).click();+ await page.getByRole('menuitem', { name: 'Simple Test Notification', exact: true }).click();const saveAndTestButton = page.getByRole('button', { name: 'Save & Test', exact: true });if (await saveAndTestButton.isVisible().catch(() => false)) {@@ -113,7 +113,7 @@ test.describe('Notification settings', () => {await page.getByPlaceholder('xoxb-... or xoxp-...').fill('xoxb-123456789012-1234567890123-abcdefghijklmnopqrstuvwx');await page.locator('[data-dropdown-menu-trigger]').filter({ hasText: 'Test Provider' }).click();- await page.getByRole('menuitem', { name: 'Test Provider', exact: true }).click();+ await page.getByRole('menuitem', { name: 'Simple Test Notification', exact: true }).click();const saveAndTestButton = page.getByRole('button', { name: 'Save & Test', exact: true });if (await saveAndTestButton.isVisible().catch(() => false)) {@@ -135,7 +135,7 @@ test.describe('Notification settings', () => {await page.getByPlaceholder('@channel, 123456789, @another_channel').fill('123456789');await page.locator('[data-dropdown-menu-trigger]').filter({ hasText: 'Test Provider' }).click();- await page.getByRole('menuitem', { name: 'Test Provider', exact: true }).click();+ await page.getByRole('menuitem', { name: 'Simple Test Notification', exact: true }).click();const saveAndTestButton = page.getByRole('button', { name: 'Save & Test', exact: true });if (await saveAndTestButton.isVisible().catch(() => false)) {@@ -155,7 +155,7 @@ test.describe('Notification settings', () => {await page.getByPlaceholder('https://example.com/webhook').fill('https://example.com/webhook');await page.locator('[data-dropdown-menu-trigger]').filter({ hasText: 'Test Provider' }).click();- await page.getByRole('menuitem', { name: 'Test Provider', exact: true }).click();+ await page.getByRole('menuitem', { name: 'Simple Test Notification', exact: true }).click();const saveAndTestButton = page.getByRole('button', { name: 'Save & Test', exact: true });if (await saveAndTestButton.isVisible().catch(() => false)) {@@ -174,11 +174,11 @@ test.describe('Notification settings', () => {await page.getByPlaceholder('localhost').fill('signal-api.example.com');await page.getByPlaceholder('8080').fill('8080');- await page.getByRole('textbox', { name: '+' }).fill('+1234567890');- await page.getByRole('textbox', { name: 'Recipients' }).fill('+1987654321');+ await page.locator('#signal-source').fill('+1234567890');+ await page.locator('#signal-recipients').fill('+1987654321');await page.locator('[data-dropdown-menu-trigger]').filter({ hasText: 'Test Provider' }).click();- await page.getByRole('menuitem', { name: 'Test Provider', exact: true }).click();+ await page.getByRole('menuitem', { name: 'Simple Test Notification', exact: true }).click();const saveAndTestButton = page.getByRole('button', { name: 'Save & Test', exact: true });if (await saveAndTestButton.isVisible().catch(() => false)) {@@ -199,7 +199,7 @@ test.describe('Notification settings', () => {await page.getByPlaceholder('my-updates').fill('arcane-updates');await page.locator('[data-dropdown-menu-trigger]').filter({ hasText: 'Test Provider' }).click();- await page.getByRole('menuitem', { name: 'Test Provider', exact: true }).click();+ await page.getByRole('menuitem', { name: 'Simple Test Notification', exact: true }).click();const saveAndTestButton = page.getByRole('button', { name: 'Save & Test', exact: true });if (await saveAndTestButton.isVisible().catch(() => false)) {