diff --git a/web/src/components/config-form/sections/BaseSection.tsx b/web/src/components/config-form/sections/BaseSection.tsx index 7727b92201..7ad88fd3d2 100644 --- a/web/src/components/config-form/sections/BaseSection.tsx +++ b/web/src/components/config-form/sections/BaseSection.tsx @@ -1047,6 +1047,7 @@ export function ConfigSection({ hiddenFields: effectiveHiddenFields, restartRequired: sectionConfig.restartRequired, requiresRestart, + isProfile: !!profileName, }} /> diff --git a/web/src/components/config-form/theme/widgets/OptionalFieldWidget.tsx b/web/src/components/config-form/theme/widgets/OptionalFieldWidget.tsx index 7f05d64664..9a89f89717 100644 --- a/web/src/components/config-form/theme/widgets/OptionalFieldWidget.tsx +++ b/web/src/components/config-form/theme/widgets/OptionalFieldWidget.tsx @@ -6,6 +6,7 @@ import { getWidget } from "@rjsf/utils"; import { Switch } from "@/components/ui/switch"; import { cn } from "@/lib/utils"; import { getNonNullSchema } from "../fields/nullableUtils"; +import type { ConfigFormContext } from "@/types/configForm"; export function OptionalFieldWidget(props: WidgetProps) { const { id, value, disabled, readonly, onChange, schema, options, registry } = @@ -13,6 +14,8 @@ export function OptionalFieldWidget(props: WidgetProps) { const innerWidgetName = (options.innerWidget as string) || undefined; const isEnabled = value !== undefined && value !== null; + const formContext = registry?.formContext as ConfigFormContext | undefined; + const isProfile = !!formContext?.isProfile; // Extract the non-null branch from anyOf [Type, null] const innerSchema = getNonNullSchema(schema) ?? schema; @@ -42,10 +45,17 @@ export function OptionalFieldWidget(props: WidgetProps) { const innerProps: WidgetProps = { ...props, schema: innerSchema, - disabled: disabled || readonly || !isEnabled, + disabled: disabled || readonly || (!isProfile && !isEnabled), value: isEnabled ? value : getDefaultValue(), }; + // don't show the switch if we're editing in a profile + // to disable in a profile, users should edit the config manually, eg: + // skip_motion_threshold: None + if (isProfile) { + return ; + } + return (
) => string; renderers?: Record; + isProfile?: boolean; };