From b47947683363328112b29b1e1f2a5f29cac2fe1c Mon Sep 17 00:00:00 2001 From: Ari Date: Sat, 6 Aug 2022 15:29:41 -0400 Subject: [PATCH] fixed up invalid node issue --- .../AutomationManager/index.stories.tsx | 51 +++++++++++++++++++ .../src/components/DAGGraph/elements/state.ts | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/webapp/src/components/AutomationManager/index.stories.tsx b/webapp/src/components/AutomationManager/index.stories.tsx index eeb8bf8..0b0939c 100644 --- a/webapp/src/components/AutomationManager/index.stories.tsx +++ b/webapp/src/components/AutomationManager/index.stories.tsx @@ -120,3 +120,54 @@ export const MissingAutoInConfig = make({ entitySource: {}, }, }); +export const BadAutomation = make({ + haProps: { + loading: false, + entities: { + [`automation.${auto1.metadata.id}`]: { + entity_id: `automation.${auto1.metadata.id}`, + attributes: { + id: "test", + }, + context: { id: "", parent_id: null, user_id: null }, + last_changed: "", + last_updated: "", + state: "on", + }, + }, + entitySource: {}, + }, + automations: [ + { + tags: {}, + metadata: { + id: "test", + mode: "single", + alias: "Light.Tank_Day", + description: "", + }, + trigger: [ + { + platform: "sun", + event: "sunrise", + offset: "30", + } as any, + { whoAmI: "bad node is who" } as any, + ], + condition: [{ whoAmI: "bad node is who" } as any], + sequence: [ + { scene: "scene.light_day" } as any, + { whoAmI: "bad node is who" } as any, + { + service: "input_select.set_options", + target: { + entity_id: "input_select.tank_light_mode", + }, + data: { + options: "day", + }, + }, + ], + }, + ], +}); diff --git a/webapp/src/components/DAGGraph/elements/state.ts b/webapp/src/components/DAGGraph/elements/state.ts index 67dc455..8ec105f 100644 --- a/webapp/src/components/DAGGraph/elements/state.ts +++ b/webapp/src/components/DAGGraph/elements/state.ts @@ -29,7 +29,7 @@ export const useDAGElementsState = () => { }, getIsClosedActions(nodeId: string, node: AutomationNode) { - if (isSpecialNode(getNodeSubType(node))) { + if (isSpecialNode(getNodeSubType(node, true))) { return { isClosed: this.get(nodeId).isClosed ?? false, setIsClosed: (v: boolean) => this.set(nodeId, "isClosed", v),