mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-26 21:59:02 +03:00
move util
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
import mergeWith from "lodash/mergeWith";
|
||||
import type { SectionConfig } from "./sections/BaseSection";
|
||||
import { sectionConfigs } from "./sectionConfigs";
|
||||
|
||||
const mergeSectionConfig = (
|
||||
base: SectionConfig | undefined,
|
||||
overrides: Partial<SectionConfig> | undefined,
|
||||
): SectionConfig =>
|
||||
mergeWith({}, base ?? {}, overrides ?? {}, (objValue, srcValue, key) => {
|
||||
if (Array.isArray(objValue) || Array.isArray(srcValue)) {
|
||||
return srcValue ?? objValue;
|
||||
}
|
||||
|
||||
if (key === "uiSchema" && srcValue !== undefined) {
|
||||
return srcValue;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
});
|
||||
|
||||
export function getSectionConfig(
|
||||
sectionKey: string,
|
||||
level: "global" | "camera",
|
||||
): SectionConfig {
|
||||
const entry = sectionConfigs[sectionKey];
|
||||
if (!entry) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const overrides = level === "global" ? entry.global : entry.camera;
|
||||
return mergeSectionConfig(entry.base, overrides);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMemo } from "react";
|
||||
import { createConfigSection } from "./BaseSection";
|
||||
import type { BaseSectionProps, SectionConfig } from "./BaseSection";
|
||||
import { getSectionConfig } from "@/components/config-form/sectionConfigsUtils";
|
||||
import { getSectionConfig } from "@/utils/sectionConfigsUtils";
|
||||
|
||||
export type ConfigSectionTemplateProps = BaseSectionProps & {
|
||||
sectionKey: string;
|
||||
|
||||
Reference in New Issue
Block a user