This commit is contained in:
ari committed 2021-12-16 15:07:20 -05:00
1 parent e9fa762827
commit 40db8d41d7
4 files changed
+64 -4

No files matched your search

@@ -251,3 +251,50 @@ SubsequentIssue.args = {
...SubsequentIssue.args,
sequence: [{ "$smType": "condition", "condition": "and", "condition_data": { "conditions": [{ "$smType": "condition", "condition": "numeric_state", "condition_data": { "entity_id": "sensor.temperature_kitchen", "below": "15" } }, { "$smType": "condition", "condition": "template", "condition_data": { "value_template": "states(switch.kitchen_light) == \"on\"" } }] } }, { "$smType": "action", "action": "service", "action_data": { "alias": "Start Music In Kitchen", "service": "media_player.play_media", "target": { "entity_id": "media_player.kitchen_dot" }, "data": { "media_content_id": "Good Morning", "media_content_type": "SPOTIFY" } } }, { "$smType": "action", "action": "choose", "action_data": { "choose": [], "default": [{ "$smType": "action", "action": "choose", "action_data": { "choose": [], "default": [] } }] } }, { "$smType": "action", "action": "choose", "action_data": { "choose": [], "default": [] } }, { "$smType": "action", "action": "choose", "action_data": { "choose": [], "default": [] } }]
}
export const ChooseNestingIssue = Template.bind({})
ChooseNestingIssue.args = {
...ChooseNestingIssue.args,
sequence: [
{
"$smType": "condition",
"condition": "and",
"condition_data": {
"conditions": [
{
"$smType": "condition",
"condition": "numeric_state",
"condition_data": {
"entity_id": "sensor.temperature_kitchen",
"below": "15"
}
},
{
"$smType": "condition",
"condition": "template",
"condition_data": {
"value_template": "states(switch.kitchen_light) == \"on\""
}
}
]
}
},
{
"$smType": "action",
"action": "choose",
"action_data": {
"choose": [],
"default": [
{
"$smType": "action",
"action": "choose",
"action_data": {
"choose": [],
"default": []
}
}
]
}
}
]
}
@@ -31,12 +31,16 @@ export const SequenceNodes: FC<SequenceNodeProps & { zoomLevel: number }> = (pro
...modalState.node.slice(i + 1),
]); setModalState(null)
}}
onAdd={n => modalState.update([...modalState.node, n as any])}
onRemove={(i) => {
onAdd={(n, slide) => {
modalState.update([...modalState.node, n as any]);
slide(modalState.node.length)
}}
onRemove={(i, slide) => {
modalState.update([
...modalState.node.slice(0, i),
...modalState.node.slice(i + 1),
]);
slide(modalState.node.length - 2);
}}
allowedTypes={modalState.onlyConditions ? ['condition'] : ['action', 'condition']}
/>
@@ -0,0 +1,10 @@
import { computeNodesEdgesPos } from "./positions"
test('empty nodes', () => {
const onChange = () => {}
const openModal = () => { }
const out = Array.from(computeNodesEdgesPos([0, 0], [], onChange, openModal));
expect(out).toHaveLength(0)
})
@@ -5,7 +5,6 @@ import { makeUpdater, Updater } from './updater';
import { ChooseAction } from 'types/automations/actions';
import { AutomationCondition } from "types/automations/conditions";
import { ModalState } from "./types";
import { AutomationNode } from '../../types/automations/index';
export type UpdateModalState = (
s: ModalState
@@ -131,7 +130,7 @@ function* dealWithChoose(
// add new conditions
const newCondLoc = offsetPoint(
nodeLoc,
[1, node.action_data.choose.length + 1 + offset.y],
[1, node.action_data.choose.length + 3 + offset.y],
);
yield {
type: 'circle',