diff --git a/web/src/components/config-form/section-configs/types.ts b/web/src/components/config-form/section-configs/types.ts index e2b308e08..9efeb2b32 100644 --- a/web/src/components/config-form/section-configs/types.ts +++ b/web/src/components/config-form/section-configs/types.ts @@ -1,5 +1,39 @@ +import type { FrigateConfig, CameraConfig } from "@/types/frigateConfig"; +import type { ConfigSectionData } from "@/types/configForm"; import type { SectionConfig } from "../sections/BaseSection"; +/** Context provided to message condition functions */ +export type MessageConditionContext = { + fullConfig: FrigateConfig; + fullCameraConfig?: CameraConfig; + level: "global" | "camera"; + cameraName?: string; + formData: ConfigSectionData; +}; + +/** Severity levels for conditional messages */ +export type MessageSeverity = "info" | "warning" | "error"; + +/** A conditional message definition */ +export type ConditionalMessage = { + /** Unique key for React list rendering and deduplication */ + key: string; + /** Translation key resolved via t() in the views/settings namespace */ + messageKey: string; + /** Severity level controlling visual styling */ + severity: MessageSeverity; + /** Function returning true when the message should be shown */ + condition: (ctx: MessageConditionContext) => boolean; +}; + +/** Field-level conditional message, adds field targeting */ +export type FieldConditionalMessage = ConditionalMessage & { + /** Dot-separated field path (e.g., "enabled", "alerts.labels") */ + field: string; + /** Whether to render before or after the field (default: "before") */ + position?: "before" | "after"; +}; + export type SectionConfigOverrides = { base?: SectionConfig; global?: Partial;