From 3bc1ae2f77d6db0c4e4b98b7b3df1da3ae0efe65 Mon Sep 17 00:00:00 2001
From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
Date: Tue, 12 May 2026 16:43:14 -0500
Subject: [PATCH] hide switch in optionalfieldwidget if editing a profile
---
.../components/config-form/sections/BaseSection.tsx | 1 +
.../theme/widgets/OptionalFieldWidget.tsx | 12 +++++++++++-
web/src/types/configForm.ts | 1 +
3 files changed, 13 insertions(+), 1 deletion(-)
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