added more support for trigger types
This commit is contained in:
1 parent
1cb40288b1
commit
754cc2ef98
9 files changed
+190
-73
No files matched your search
@@ -1,57 +1,55 @@
|
||||
import React from "react";
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { NodeEditor } from ".";
|
||||
import { ComponentStory } from "@storybook/react";
|
||||
import { NodeEditor, NodeEditorProps } from ".";
|
||||
|
||||
import { AutomationCondition } from "types/automations/conditions";
|
||||
import { Button } from "components/Inputs/Buttons/Button";
|
||||
import { useState } from "react";
|
||||
import { Modal } from "components/Modal";
|
||||
import { Page } from "components/Page";
|
||||
import { makeStory } from "devUtils";
|
||||
|
||||
export default {
|
||||
title: "NodeEditor",
|
||||
component: NodeEditor,
|
||||
parameters: { actions: { argTypesRegex: "^on.*" } },
|
||||
args: {
|
||||
node: {
|
||||
data: {},
|
||||
service: "",
|
||||
target: "",
|
||||
const { componentMeta, make } = makeStory({
|
||||
meta: {
|
||||
title: "NodeEditor",
|
||||
args: {
|
||||
node: {
|
||||
data: {},
|
||||
service: "",
|
||||
target: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
} as ComponentMeta<typeof NodeEditor>;
|
||||
Component: (props: NodeEditorProps) => {
|
||||
const [state, setState] = useState(props.node);
|
||||
return (
|
||||
<Page>
|
||||
<NodeEditor
|
||||
{...props}
|
||||
node={state}
|
||||
onSave={(s) => {
|
||||
setState(s);
|
||||
props.onSave && props.onSave(s);
|
||||
}}
|
||||
/>
|
||||
</Page>
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
const Base: ComponentStory<typeof NodeEditor> = (props) => {
|
||||
const [state, setState] = useState(props.node);
|
||||
return (
|
||||
<Page>
|
||||
<NodeEditor
|
||||
{...props}
|
||||
node={state}
|
||||
onSave={(s) => {
|
||||
setState(s);
|
||||
props.onSave && props.onSave(s);
|
||||
}}
|
||||
/>
|
||||
</Page>
|
||||
);
|
||||
};
|
||||
export const Action = Base.bind({});
|
||||
export const SingleOption = Action.bind({});
|
||||
SingleOption.args = {
|
||||
...SingleOption.args,
|
||||
export default componentMeta;
|
||||
|
||||
export const Action = make({});
|
||||
export const SingleOption = make({
|
||||
allowedTypes: ["action"],
|
||||
};
|
||||
export const Condition = Action.bind({});
|
||||
Condition.args = {
|
||||
...Condition.args,
|
||||
});
|
||||
export const Condition = make({
|
||||
node: {
|
||||
condition: "and",
|
||||
conditions: [
|
||||
{
|
||||
condition: "numeric_state",
|
||||
entity_id: ["sensor.kitchen_humidity"],
|
||||
conditions: [],
|
||||
above: "40",
|
||||
},
|
||||
{
|
||||
@@ -59,26 +57,22 @@ Condition.args = {
|
||||
value_template: "states('switch.kitchen') == 'on'",
|
||||
},
|
||||
],
|
||||
} as AutomationCondition,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export const UnSupported = Action.bind({});
|
||||
UnSupported.args = {
|
||||
...UnSupported.args,
|
||||
export const UnSupported = make({
|
||||
node: {
|
||||
condition: "bargs",
|
||||
platform: "rouge",
|
||||
} as any,
|
||||
};
|
||||
});
|
||||
|
||||
export const DeviceTriggerExample = Action.bind({});
|
||||
DeviceTriggerExample.args = {
|
||||
...DeviceTriggerExample.args,
|
||||
export const DeviceTriggerExample = make({
|
||||
node: {
|
||||
platform: "device",
|
||||
device_id: "bd83b10cb1c7aa028c12dade5b4e87d5",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
export const InAModal: ComponentStory<typeof NodeEditor> = (props) => {
|
||||
const [open, setOpen] = useState(false);
|
||||
@@ -92,19 +86,15 @@ export const InAModal: ComponentStory<typeof NodeEditor> = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const ServiceExample = Action.bind({});
|
||||
ServiceExample.args = {
|
||||
...ServiceExample.args,
|
||||
export const ServiceExample = make({
|
||||
node: {
|
||||
target: {},
|
||||
data: {},
|
||||
service: "",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
export const ServiceWithDataExample = Action.bind({});
|
||||
ServiceWithDataExample.args = {
|
||||
...ServiceWithDataExample.args,
|
||||
export const ServiceWithDataExample = make({
|
||||
node: {
|
||||
target: {
|
||||
entity: "light.switch_baby",
|
||||
@@ -114,37 +104,29 @@ ServiceWithDataExample.args = {
|
||||
},
|
||||
service: "light.turn_on",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
export const DelayExample = Action.bind({});
|
||||
DelayExample.args = {
|
||||
...DelayExample.args,
|
||||
export const DelayExample = make({
|
||||
node: {
|
||||
wait_template: "",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
export const StateTriggerExample = Action.bind({});
|
||||
StateTriggerExample.args = {
|
||||
...StateTriggerExample.args,
|
||||
export const StateTriggerExample = make({
|
||||
node: {
|
||||
platform: "state",
|
||||
entity_id: "binary_sensor.door_main",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
export const DeviceActionFilledExample = Action.bind({});
|
||||
DeviceActionFilledExample.args = {
|
||||
...DeviceActionFilledExample.args,
|
||||
export const DeviceActionFilledExample = make({
|
||||
node: {
|
||||
type: "toggle",
|
||||
device_id: "c9711be86b0301955f72380509285485",
|
||||
},
|
||||
};
|
||||
} as any,
|
||||
});
|
||||
|
||||
export const NotifyPhoneViaDeviceAction = Action.bind({});
|
||||
NotifyPhoneViaDeviceAction.args = {
|
||||
...NotifyPhoneViaDeviceAction.args,
|
||||
export const NotifyPhoneViaDeviceAction = make({
|
||||
node: {
|
||||
device_id: "2a98db84af7526c7ec3cc7aebd1a9e1c",
|
||||
domain: "mobile_app",
|
||||
@@ -152,4 +134,11 @@ NotifyPhoneViaDeviceAction.args = {
|
||||
title: "Hassio Status",
|
||||
message: "Hassio Is turning off...",
|
||||
} as any,
|
||||
};
|
||||
});
|
||||
|
||||
export const Sun = make({
|
||||
node: {
|
||||
platform: "sun",
|
||||
event: "sunset",
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user