diff --git a/web/src/components/config-form/sections/ConfigSectionTemplate.tsx b/web/src/components/config-form/sections/ConfigSectionTemplate.tsx index 8c6063ec9..e4b560457 100644 --- a/web/src/components/config-form/sections/ConfigSectionTemplate.tsx +++ b/web/src/components/config-form/sections/ConfigSectionTemplate.tsx @@ -1,5 +1,5 @@ import { useMemo } from "react"; -import { createConfigSection } from "./BaseSection"; +import { ConfigSection } from "./BaseSection"; import type { BaseSectionProps, SectionConfig } from "./BaseSection"; import { getSectionConfig } from "@/utils/sectionConfigsUtils"; @@ -19,17 +19,10 @@ export function ConfigSectionTemplate({ [sectionKey, level], ); - const SectionComponent = useMemo( - () => - createConfigSection({ - sectionPath: sectionKey, - defaultConfig, - }), - [sectionKey, defaultConfig], - ); - return ( - ( + +); -const CameraMqttSettingsPage = createSingleSectionPage({ - sectionKey: "mqtt", - level: "camera", - showOverrideIndicator: false, -}); +const CameraMqttSettingsPage = (props: SettingsPageProps) => ( + +); const settingsGroups = [ { diff --git a/web/src/views/settings/SingleSectionPage.tsx b/web/src/views/settings/SingleSectionPage.tsx index 24f9cfbc9..6bb494115 100644 --- a/web/src/views/settings/SingleSectionPage.tsx +++ b/web/src/views/settings/SingleSectionPage.tsx @@ -18,58 +18,58 @@ export type SingleSectionPageOptions = { showOverrideIndicator?: boolean; }; -export function createSingleSectionPage({ +export type SingleSectionPageProps = SettingsPageProps & + SingleSectionPageOptions; + +export function SingleSectionPage({ sectionKey, level, sectionConfig, requiresRestart, showOverrideIndicator = true, -}: SingleSectionPageOptions) { - return function SingleSectionPage({ - selectedCamera, - setUnsavedChanges, - }: SettingsPageProps) { - const sectionNamespace = - level === "camera" ? "config/cameras" : "config/global"; - const { t, i18n } = useTranslation([ - sectionNamespace, - "views/settings", - "common", - ]); - - if (level === "camera" && !selectedCamera) { - return ( -
- {t("configForm.camera.noCameras", { ns: "views/settings" })} -
- ); - } + selectedCamera, + setUnsavedChanges, +}: SingleSectionPageProps) { + const sectionNamespace = + level === "camera" ? "config/cameras" : "config/global"; + const { t, i18n } = useTranslation([ + sectionNamespace, + "views/settings", + "common", + ]); + if (level === "camera" && !selectedCamera) { return ( -
-
- - {t(`${sectionKey}.label`, { ns: sectionNamespace })} - - {i18n.exists(`${sectionKey}.description`, { - ns: sectionNamespace, - }) && ( -

- {t(`${sectionKey}.description`, { ns: sectionNamespace })} -

- )} -
- setUnsavedChanges?.(false)} - showTitle={false} - sectionConfig={sectionConfig} - requiresRestart={requiresRestart} - /> +
+ {t("configForm.camera.noCameras", { ns: "views/settings" })}
); - }; + } + + return ( +
+
+ + {t(`${sectionKey}.label`, { ns: sectionNamespace })} + + {i18n.exists(`${sectionKey}.description`, { + ns: sectionNamespace, + }) && ( +

+ {t(`${sectionKey}.description`, { ns: sectionNamespace })} +

+ )} +
+ setUnsavedChanges?.(false)} + showTitle={false} + sectionConfig={sectionConfig} + requiresRestart={requiresRestart} + /> +
+ ); }