moving things around
This commit is contained in:
1 parent
549f52655b
commit
d22bba8c4d
41 files changed
+227
-337
No files matched your search
@@ -1,33 +1,31 @@
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { FireEventAction } from "types/automations/actions";
|
||||
import { OptionManager, updateActionData } from "./OptionManager";
|
||||
|
||||
|
||||
export const ActionEventState: OptionManager<FireEventAction> = {
|
||||
defaultState: () => ({
|
||||
alias: "Fire Event",
|
||||
event: "",
|
||||
event_data: {},
|
||||
}),
|
||||
isReady: ({ alias, event }) => (
|
||||
alias !== '' &&
|
||||
event !== ""
|
||||
),
|
||||
isReady: ({ alias, event }) => alias !== "" && event !== "",
|
||||
renderOptionList: (state, setState) => {
|
||||
const update = updateActionData(state, setState);
|
||||
return <>
|
||||
<InputText
|
||||
textBoxFor="event"
|
||||
label="Event"
|
||||
value={state.event}
|
||||
onChange={event => update({ event })}
|
||||
/>
|
||||
<InputYaml
|
||||
label="Event Data"
|
||||
value={state.event_data}
|
||||
onChange={event_data => update({ event_data })}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<InputText
|
||||
textBoxFor="event"
|
||||
label="Event"
|
||||
value={state.event}
|
||||
onChange={(event) => update({ event })}
|
||||
/>
|
||||
<InputYaml
|
||||
label="Event Data"
|
||||
value={state.event_data}
|
||||
onChange={(event_data) => update({ event_data })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import InputNumber from "components/Inputs/InputNumber";
|
||||
import InputNumber from "components/Inputs/Base/InputNumber";
|
||||
import { RepeatAction } from "types/automations/actions";
|
||||
import { OptionManager } from "./OptionManager";
|
||||
import { InputAutoComplete } from "components/Inputs/AutoComplete/InputAutoComplete";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { StopAction } from "types/automations/actions";
|
||||
import { OptionManager } from "./OptionManager";
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import "./ActionWait.css";
|
||||
import InputBoolean from "components/Inputs/InputBoolean";
|
||||
import InputBoolean from "components/Inputs/Base/InputBoolean";
|
||||
import { InputList } from "components/Inputs/InputList";
|
||||
import InputNumber from "components/Inputs/InputNumber";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import { InputTime } from "components/Inputs/InputTime";
|
||||
import InputNumber from "components/Inputs/Base/InputNumber";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { InputTime } from "components/Inputs/Base/InputTime";
|
||||
import { useState } from "react";
|
||||
import { DelayAction, WaitAction } from "types/automations/actions";
|
||||
import { OptionManager, updateActionData } from './OptionManager';
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import { OptionManager, updateActionData } from "./OptionManager";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
|
||||
type ThisAction = WaitAction | DelayAction;
|
||||
type Option = 'delay' | 'template' | 'trigger'
|
||||
type Option = "delay" | "template" | "trigger";
|
||||
const getCurrentOption = (node: ThisAction): Option => {
|
||||
if ('delay' in node) {
|
||||
return 'delay'
|
||||
if ("delay" in node) {
|
||||
return "delay";
|
||||
} else {
|
||||
return 'template'
|
||||
return "template";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const ActionWaitState: OptionManager<ThisAction> = {
|
||||
defaultState: () => ({
|
||||
@@ -32,78 +32,108 @@ export const ActionWaitState: OptionManager<ThisAction> = {
|
||||
const base: any = {
|
||||
alias: state.alias,
|
||||
variables: state.variables,
|
||||
}
|
||||
if (opt === 'delay') {
|
||||
};
|
||||
if (opt === "delay") {
|
||||
setState({
|
||||
...base,
|
||||
delay: (state as any).delay ?? "",
|
||||
})
|
||||
});
|
||||
} else {
|
||||
base.timeout = (state as any).timeout
|
||||
base.continue_on_timeout = (state as any).continue_on_timeout
|
||||
if (opt === 'template') {
|
||||
base.timeout = (state as any).timeout;
|
||||
base.continue_on_timeout = (state as any).continue_on_timeout;
|
||||
if (opt === "template") {
|
||||
setState({
|
||||
...base,
|
||||
wait_template: (state as any).wait_template ?? "",
|
||||
})
|
||||
});
|
||||
} else {
|
||||
setState({
|
||||
...base,
|
||||
wait_for_trigger: (state as any).wait_for_trigger ?? "",
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
_setCurrent(opt)
|
||||
}
|
||||
_setCurrent(opt);
|
||||
};
|
||||
|
||||
// determine options
|
||||
let option: JSX.Element = <></>;
|
||||
if (current === "delay") {
|
||||
option = <>
|
||||
<InputTime className="for" label="for" value={(state as any).delay} onChange={delay => update({ delay })} />
|
||||
</>
|
||||
} else if (current === 'template') {
|
||||
option = (
|
||||
<>
|
||||
<InputTime
|
||||
className="for"
|
||||
label="for"
|
||||
value={(state as any).delay}
|
||||
onChange={(delay) => update({ delay })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
} else if (current === "template") {
|
||||
state = state as WaitAction;
|
||||
option = <>
|
||||
<InputText
|
||||
label="Template"
|
||||
className="template"
|
||||
value={state.wait_template ?? ""}
|
||||
onChange={wait_template => update({ wait_template })}
|
||||
/>
|
||||
</>
|
||||
} else if (current === 'trigger') {
|
||||
option = (
|
||||
<>
|
||||
<InputText
|
||||
label="Template"
|
||||
className="template"
|
||||
value={state.wait_template ?? ""}
|
||||
onChange={(wait_template) => update({ wait_template })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
} else if (current === "trigger") {
|
||||
state = state as WaitAction;
|
||||
option = <>
|
||||
<InputYaml
|
||||
className="triggers"
|
||||
label="Triggers"
|
||||
value={state.wait_for_trigger ?? []}
|
||||
onChange={wait_for_trigger => update({ wait_for_trigger })}
|
||||
/>
|
||||
</>
|
||||
option = (
|
||||
<>
|
||||
<InputYaml
|
||||
className="triggers"
|
||||
label="Triggers"
|
||||
value={state.wait_for_trigger ?? []}
|
||||
onChange={(wait_for_trigger) => update({ wait_for_trigger })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// render
|
||||
return <div className="node-editor--action-wait">
|
||||
<InputList
|
||||
className="wait-type"
|
||||
label="Wait Type" prettyOptionLabels
|
||||
options={["template", 'trigger', "delay"]}
|
||||
current={current} onChange={setCurrent} />
|
||||
{option}
|
||||
{current !== 'delay' ? <div className="wait-options">
|
||||
<InputNumber
|
||||
label="Timeout"
|
||||
value={(state as any).timeout ? Number((state as any).timeout) : undefined}
|
||||
onChange={timeout => update({ timeout: timeout === undefined ? undefined : String(timeout) })}
|
||||
return (
|
||||
<div className="node-editor--action-wait">
|
||||
<InputList
|
||||
className="wait-type"
|
||||
label="Wait Type"
|
||||
prettyOptionLabels
|
||||
options={["template", "trigger", "delay"]}
|
||||
current={current}
|
||||
onChange={setCurrent}
|
||||
/>
|
||||
<InputBoolean
|
||||
label="Continue on Timeout"
|
||||
value={(state as any).continue_on_timeout ?? false}
|
||||
onChange={continue_on_timeout => update({ continue_on_timeout })}
|
||||
/>
|
||||
</div> : <></>}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
{option}
|
||||
{current !== "delay" ? (
|
||||
<div className="wait-options">
|
||||
<InputNumber
|
||||
label="Timeout"
|
||||
value={
|
||||
(state as any).timeout
|
||||
? Number((state as any).timeout)
|
||||
: undefined
|
||||
}
|
||||
onChange={(timeout) =>
|
||||
update({
|
||||
timeout: timeout === undefined ? undefined : String(timeout),
|
||||
})
|
||||
}
|
||||
/>
|
||||
<InputBoolean
|
||||
label="Continue on Timeout"
|
||||
value={(state as any).continue_on_timeout ?? false}
|
||||
onChange={(continue_on_timeout) =>
|
||||
update({ continue_on_timeout })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { OptionManager } from "./OptionManager";
|
||||
import { AutomationTriggerEvent } from "../../../types/automations/triggers";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
|
||||
export const TriggerEventState: OptionManager<AutomationTriggerEvent> = {
|
||||
defaultState: () => ({
|
||||
|
||||
@@ -1,33 +1,34 @@
|
||||
import { OptionManager } from './OptionManager';
|
||||
import { AutomationTriggerMQTT } from 'types/automations/triggers';
|
||||
import InputText from 'components/Inputs/InputText';
|
||||
|
||||
import { OptionManager } from "./OptionManager";
|
||||
import { AutomationTriggerMQTT } from "types/automations/triggers";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
|
||||
export const TriggerMQTTState: OptionManager<AutomationTriggerMQTT> = {
|
||||
defaultState: () => ({
|
||||
"platform": "mqtt",
|
||||
"payload": "",
|
||||
"topic": "",
|
||||
"value_template": ""
|
||||
platform: "mqtt",
|
||||
payload: "",
|
||||
topic: "",
|
||||
value_template: "",
|
||||
}),
|
||||
isReady: () => true,
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
<InputText
|
||||
label='Payload'
|
||||
value={state.payload}
|
||||
onChange={payload => setState({ ...state, payload })}
|
||||
/>
|
||||
<InputText
|
||||
label='Topic'
|
||||
value={state.topic}
|
||||
onChange={topic => setState({ ...state, topic })}
|
||||
/>
|
||||
<InputText
|
||||
label='Template'
|
||||
value={state.value_template}
|
||||
onChange={value_template => setState({ ...state, value_template })}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<InputText
|
||||
label="Payload"
|
||||
value={state.payload}
|
||||
onChange={(payload) => setState({ ...state, payload })}
|
||||
/>
|
||||
<InputText
|
||||
label="Topic"
|
||||
value={state.topic}
|
||||
onChange={(topic) => setState({ ...state, topic })}
|
||||
/>
|
||||
<InputText
|
||||
label="Template"
|
||||
value={state.value_template}
|
||||
onChange={(value_template) => setState({ ...state, value_template })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -1,10 +1,10 @@
|
||||
import { OptionManager } from "./OptionManager";
|
||||
import { AutomationTriggerNumericState } from "types/automations/triggers";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { InputEntity } from "components/Inputs/AutoComplete/InputEntities";
|
||||
import InputNumber from "components/Inputs/InputNumber";
|
||||
import { InputTime } from "components/Inputs/InputTime";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputNumber from "components/Inputs/Base/InputNumber";
|
||||
import { InputTime } from "components/Inputs/Base/InputTime";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
|
||||
export const TriggerNumericState: OptionManager<AutomationTriggerNumericState> =
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { OptionManager } from "./OptionManager";
|
||||
import { AutomationTriggerState } from "types/automations/triggers";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { InputEntity } from "components/Inputs/AutoComplete/InputEntities";
|
||||
import { InputTime } from "components/Inputs/InputTime";
|
||||
import { InputTime } from "components/Inputs/Base/InputTime";
|
||||
import { InputAutoComplete } from "components/Inputs/AutoComplete/InputAutoComplete";
|
||||
import { FC } from "react";
|
||||
import { getEntityDomains } from "utils/automations";
|
||||
|
||||
@@ -1,30 +1,33 @@
|
||||
import { OptionManager } from './OptionManager';
|
||||
import { AutomationTriggerTemplate } from 'types/automations/triggers';
|
||||
import InputText from 'components/Inputs/InputText';
|
||||
import { InputTime } from 'components/Inputs/InputTime';
|
||||
|
||||
import { OptionManager } from "./OptionManager";
|
||||
import { AutomationTriggerTemplate } from "types/automations/triggers";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { InputTime } from "components/Inputs/Base/InputTime";
|
||||
|
||||
export const TriggerTemplate: OptionManager<AutomationTriggerTemplate> = {
|
||||
defaultState: () => ({
|
||||
"platform": 'template',
|
||||
"value_template": "",
|
||||
platform: "template",
|
||||
value_template: "",
|
||||
}),
|
||||
isReady: () => true,
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
<InputText
|
||||
label='Template'
|
||||
value={state.value_template}
|
||||
onChange={value_template => setState({ ...state, value_template })}
|
||||
/>
|
||||
<InputTime
|
||||
label="For"
|
||||
value={state.for}
|
||||
onChange={_for => setState({
|
||||
...state,
|
||||
for: _for,
|
||||
})}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<InputText
|
||||
label="Template"
|
||||
value={state.value_template}
|
||||
onChange={(value_template) => setState({ ...state, value_template })}
|
||||
/>
|
||||
<InputTime
|
||||
label="For"
|
||||
value={state.for}
|
||||
onChange={(_for) =>
|
||||
setState({
|
||||
...state,
|
||||
for: _for,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
AutomationTriggerExactTime,
|
||||
AutomationTriggerTimePattern,
|
||||
} from "types/automations/triggers";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { FC } from "react";
|
||||
import { InputList } from "components/Inputs/InputList";
|
||||
import { Button } from "components/Inputs/Buttons/Button";
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
import { OptionManager } from './OptionManager';
|
||||
import { AutomationTriggerWebhook } from 'types/automations/triggers';
|
||||
import InputText from 'components/Inputs/InputText';
|
||||
|
||||
import { OptionManager } from "./OptionManager";
|
||||
import { AutomationTriggerWebhook } from "types/automations/triggers";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
|
||||
export const TriggerWebhook: OptionManager<AutomationTriggerWebhook> = {
|
||||
defaultState: () => ({
|
||||
"platform": 'webhook',
|
||||
"webhook_id": "",
|
||||
platform: "webhook",
|
||||
webhook_id: "",
|
||||
}),
|
||||
isReady: () => true,
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
<InputText label="Webhook ID" value={state.webhook_id ?? ""} onChange={webhook_id => setState({
|
||||
...state,
|
||||
webhook_id
|
||||
})} />
|
||||
</>
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<InputText
|
||||
label="Webhook ID"
|
||||
value={state.webhook_id ?? ""}
|
||||
onChange={(webhook_id) =>
|
||||
setState({
|
||||
...state,
|
||||
webhook_id,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
getSubTypeList,
|
||||
validateNode,
|
||||
} from "utils/automations";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import InputText from "components/Inputs/InputText";
|
||||
import InputYaml from "components/Inputs/Base/InputYaml";
|
||||
import InputText from "components/Inputs/Base/InputText";
|
||||
import { getDescriptionFromAutomationNode } from "utils/formatting";
|
||||
import { useHA } from "haService";
|
||||
import { Generic } from "./Generic";
|
||||
|
||||
@@ -5,7 +5,7 @@ import { AutomationNode, AutomationNodeMapping } from "types/automations/index";
|
||||
import { useEditorNodeState } from "./OptionManager";
|
||||
import { InputList } from "components/Inputs/InputList";
|
||||
import { Button } from "components/Inputs/Buttons/Button";
|
||||
import InputBoolean from "components/Inputs/InputBoolean";
|
||||
import InputBoolean from "components/Inputs/Base/InputBoolean";
|
||||
import { useConfirm } from "material-ui-confirm";
|
||||
import { getNodeSubTypeDescription } from "./utils";
|
||||
|
||||
|
||||
Reference in new issue
Block a user