namer in conditions
This commit is contained in:
1 parent
ac1ee86cc7
commit
61000f2ff1
2 files changed
+7
-3
No files matched your search
@@ -9,6 +9,7 @@ import { getEditor } from "./editorRender";
|
||||
import { useStyles } from "./style";
|
||||
import { getViewer } from "./viewRender";
|
||||
import useWindowSize from "utils/useWindowSize";
|
||||
import { useHA } from "haService";
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +34,7 @@ export const ConditionNode: FC<{
|
||||
const [internalDisplayMode, setInternalDisplayMode] = useState(displayMode);
|
||||
const [yamlMode, setYamlMode] = useState(false);
|
||||
const { isMobile } = useWindowSize();
|
||||
const { namer } = useHA();
|
||||
// alias
|
||||
const effectiveDM = internalDisplayMode || yamlMode;
|
||||
// effect
|
||||
@@ -64,7 +66,7 @@ export const ConditionNode: FC<{
|
||||
let childrenConditions: JSX.Element;
|
||||
if (effectiveDM) {
|
||||
const Viewer = getViewer(condition);
|
||||
childrenConditions = <Viewer condition={condition} onChange={onUpdate} />
|
||||
childrenConditions = <Viewer condition={condition} onChange={onUpdate} namer={namer} />
|
||||
} else {
|
||||
const Editor = getEditor(condition);
|
||||
childrenConditions = <Editor condition={condition} onChange={onUpdate} />
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { FC } from "react";
|
||||
import { AutomationCondition, LogicCondition } from "types/automations/conditions";
|
||||
import { getDescriptionFromAutomationNode } from "utils/formatting";
|
||||
import { getDescriptionFromAutomationNode, Namer } from "utils/formatting";
|
||||
import { ConditionNode } from "./ConditionNode";
|
||||
import { genUpdateMethods } from "./nestedUpdater";
|
||||
|
||||
|
||||
interface Viewer<C extends AutomationCondition> extends FC<{
|
||||
condition: C;
|
||||
namer: Namer;
|
||||
onChange: (condition: C) => void;
|
||||
}> { }
|
||||
|
||||
@@ -23,9 +24,10 @@ export const getViewer = (condition: AutomationCondition): Viewer<any> => {
|
||||
|
||||
export const GenericViewer: Viewer<AutomationCondition> = ({
|
||||
condition,
|
||||
namer,
|
||||
}) => {
|
||||
return <>
|
||||
{getDescriptionFromAutomationNode(condition)}
|
||||
{getDescriptionFromAutomationNode(condition, namer)}
|
||||
</>
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user