diff --git a/app/client/api-client/types.gen.ts b/app/client/api-client/types.gen.ts index ddf355f3..e6e5f670 100644 --- a/app/client/api-client/types.gen.ts +++ b/app/client/api-client/types.gen.ts @@ -2434,6 +2434,18 @@ export type ListBackupSchedulesResponses = { includePatterns: Array | null; oneFileSystem: boolean; customResticParams: Array | null; + backupWebhooks: { + pre: { + url: string; + headers?: Array; + body?: string; + } | null; + post: { + url: string; + headers?: Array; + body?: string; + } | null; + } | null; maxRetries: number; retryDelay: number; lastBackupAt: number | null; @@ -2712,6 +2724,18 @@ export type CreateBackupScheduleData = { oneFileSystem?: boolean; tags?: Array; customResticParams?: Array; + backupWebhooks?: { + pre: { + url: string; + headers?: Array; + body?: string; + } | null; + post: { + url: string; + headers?: Array; + body?: string; + } | null; + } | null; maxRetries?: number; retryDelay?: number; }; @@ -2747,6 +2771,18 @@ export type CreateBackupScheduleResponses = { includePatterns: Array | null; oneFileSystem: boolean; customResticParams: Array | null; + backupWebhooks: { + pre: { + url: string; + headers?: Array; + body?: string; + } | null; + post: { + url: string; + headers?: Array; + body?: string; + } | null; + } | null; maxRetries: number; retryDelay: number; lastBackupAt: number | null; @@ -2816,6 +2852,18 @@ export type GetBackupScheduleResponses = { includePatterns: Array | null; oneFileSystem: boolean; customResticParams: Array | null; + backupWebhooks: { + pre: { + url: string; + headers?: Array; + body?: string; + } | null; + post: { + url: string; + headers?: Array; + body?: string; + } | null; + } | null; maxRetries: number; retryDelay: number; lastBackupAt: number | null; @@ -3093,6 +3141,18 @@ export type UpdateBackupScheduleData = { oneFileSystem?: boolean; tags?: Array; customResticParams?: Array; + backupWebhooks?: { + pre: { + url: string; + headers?: Array; + body?: string; + } | null; + post: { + url: string; + headers?: Array; + body?: string; + } | null; + } | null; maxRetries?: number; retryDelay?: number; }; @@ -3130,6 +3190,18 @@ export type UpdateBackupScheduleResponses = { includePatterns: Array | null; oneFileSystem: boolean; customResticParams: Array | null; + backupWebhooks: { + pre: { + url: string; + headers?: Array; + body?: string; + } | null; + post: { + url: string; + headers?: Array; + body?: string; + } | null; + } | null; maxRetries: number; retryDelay: number; lastBackupAt: number | null; @@ -3179,6 +3251,18 @@ export type GetBackupScheduleForVolumeResponses = { includePatterns: Array | null; oneFileSystem: boolean; customResticParams: Array | null; + backupWebhooks: { + pre: { + url: string; + headers?: Array; + body?: string; + } | null; + post: { + url: string; + headers?: Array; + body?: string; + } | null; + } | null; maxRetries: number; retryDelay: number; lastBackupAt: number | null; diff --git a/app/client/components/webhook-request-preview.tsx b/app/client/components/webhook-request-preview.tsx new file mode 100644 index 00000000..1b1c132f --- /dev/null +++ b/app/client/components/webhook-request-preview.tsx @@ -0,0 +1,25 @@ +import { CodeBlock } from "~/client/components/ui/code-block"; +import { Label } from "~/client/components/ui/label"; + +type WebhookRequestPreviewProps = { + method: string; + url?: string; + contentType?: string; + headers?: string[]; + body: string; +}; + +export const WebhookRequestPreview = ({ method, url, contentType, headers, body }: WebhookRequestPreviewProps) => { + const headerLines = [contentType ? `Content-Type: ${contentType}` : undefined, ...(headers ?? [])].filter(Boolean); + const previewCode = `${method} ${url || "https://api.example.com/webhook"}${headerLines.length > 0 ? `\n${headerLines.join("\n")}` : ""} + +${body}`; + + return ( +
+ + +

This is a preview of the HTTP request that will be sent.

+
+ ); +}; diff --git a/app/client/modules/backups/components/create-schedule-form/advanced-section.tsx b/app/client/modules/backups/components/create-schedule-form/advanced-section.tsx index a6d865a3..0b6c3d33 100644 --- a/app/client/modules/backups/components/create-schedule-form/advanced-section.tsx +++ b/app/client/modules/backups/components/create-schedule-form/advanced-section.tsx @@ -1,6 +1,6 @@ import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "~/client/components/ui/form"; import { Textarea } from "~/client/components/ui/textarea"; -import type { UseFormReturn } from "react-hook-form"; +import { type UseFormReturn } from "react-hook-form"; import type { InternalFormValues } from "./types"; import { Input } from "~/client/components/ui/input"; @@ -8,6 +8,72 @@ type AdvancedSectionProps = { form: UseFormReturn; }; +type WebhookFieldsProps = { + form: UseFormReturn; + phase: "pre" | "post"; + urlPlaceholder: string; + bodyPlaceholder: string; + description: string; +}; + +const WebhookFields = ({ form, phase, urlPlaceholder, bodyPlaceholder, description }: WebhookFieldsProps) => { + const labelPrefix = phase === "pre" ? "Pre-backup" : "Post-backup"; + const fieldPrefix = phase === "pre" ? "preBackupWebhook" : "postBackupWebhook"; + + return ( + <> + ( + + {labelPrefix} webhook + + + + {description} + + + )} + /> + ( + + {labelPrefix} webhook headers + +