handling missing ids better + more tranlsations

This commit is contained in:
ari committed 2022-09-01 17:21:00 -04:00
1 parent 69a9805c02
commit 774ebe482a
45 files changed
+556 -262

No files matched your search

@@ -10,18 +10,18 @@ export const ActionEventState: OptionManager<FireEventAction> = {
event_data: {},
}),
isReady: ({ alias, event }) => alias !== "" && event !== "",
renderOptionList: (state, setState) => {
Component: ({ state, setState, langStore }) => {
const update = updateActionData(state, setState);
return (
<>
<InputText
textBoxFor="event"
label="Event"
label={langStore.get("EVENT")}
value={state.event}
onChange={(event) => update({ event })}
/>
<InputYaml
label="Event Data"
label={langStore.get("EVENT_DATA")}
value={state.event_data}
onChange={(event_data) => update({ event_data })}
/>
@@ -15,12 +15,12 @@ export const ActionRepeatState: OptionManager<RepeatAction> = {
},
}),
isReady: () => true,
Component: ({ state, setState }) => {
Component: ({ state, setState, langStore }) => {
const repeatType = determineType(state.repeat);
return (
<>
<InputAutoComplete
label="Type"
label={langStore.get("TYPE")}
value={repeatType}
options={["while", "until", "count"]}
onChange={(v) => {
@@ -53,7 +53,7 @@ export const ActionRepeatState: OptionManager<RepeatAction> = {
/>
{"count" in state.repeat && (
<InputNumber
label="How many times?"
label={langStore.get("HOW_MANY_TIMES")}
value={state.repeat.count}
onChange={(count = 1) =>
setState({
@@ -7,11 +7,11 @@ export const ActionSceneState: OptionManager<SceneAction> = {
scene: "",
}),
isReady: () => true,
Component: ({ state, setState }) => {
Component: ({ state, setState, langStore }) => {
return (
<>
<InputEntity
label="Scene"
label={langStore.get("SCENE")}
restrictToDomain={["scene"]}
value={state.scene ?? ""}
onChange={(d) => setState({ ...state, scene: d ?? "" })}
@@ -8,11 +8,11 @@ export const ActionStopState: OptionManager<StopAction> = {
stop: "",
}),
isReady: () => true,
Component: ({ state, setState }) => {
Component: ({ state, setState, langStore }) => {
return (
<>
<InputText
label="Stop Reason"
label={langStore.get("STOP_REASON")}
value={state.stop ?? []}
onChange={(d) => setState({ ...state, stop: d })}
/>
@@ -24,7 +24,7 @@ export const ActionWaitState: OptionManager<ThisAction> = {
delay: "",
}),
isReady: () => true,
Component: ({ state, setState }) => {
Component: ({ state, setState, langStore }) => {
// state
const update = updateActionData(state, setState);
const [current, _setCurrent] = useState(getCurrentOption(state));
@@ -63,7 +63,7 @@ export const ActionWaitState: OptionManager<ThisAction> = {
<>
<InputTime
className="for"
label="for"
label={langStore.get("FOR")}
value={(state as any).delay}
onChange={(delay) => update({ delay })}
/>
@@ -87,7 +87,7 @@ export const ActionWaitState: OptionManager<ThisAction> = {
<>
<InputYaml
className="triggers"
label="Triggers"
label={langStore.get("TRIGGERS")}
value={state.wait_for_trigger ?? []}
onChange={(wait_for_trigger) => update({ wait_for_trigger })}
/>
@@ -100,7 +100,7 @@ export const ActionWaitState: OptionManager<ThisAction> = {
<div className="node-editor--action-wait">
<InputList
className="wait-type"
label="Wait Type"
label={langStore.get("WAIT_TYPE")}
prettyOptionLabels
options={["template", "trigger", "delay"]}
current={current}
@@ -110,7 +110,7 @@ export const ActionWaitState: OptionManager<ThisAction> = {
{current !== "delay" ? (
<div className="wait-options">
<InputNumber
label="Timeout"
label={langStore.get("TIMEOUT")}
value={
(state as any).timeout
? Number((state as any).timeout)
@@ -123,7 +123,7 @@ export const ActionWaitState: OptionManager<ThisAction> = {
}
/>
<InputBoolean
label="Continue on Timeout"
label={langStore.get("CONTINUTE_ON_TIMEOUT")}
value={(state as any).continue_on_timeout ?? false}
onChange={(continue_on_timeout) =>
update({ continue_on_timeout })
@@ -1,5 +1,6 @@
import { HAService } from "haService";
import { HAEntitiesState } from "haService/HAEntities";
import { LangStore } from "lang";
import { FC } from "react";
import { AutomationAction } from "types/automations/actions";
import { AutomationCondition } from "types/automations/conditions";
@@ -21,6 +22,7 @@ export type OptionManager<T> = {
setState: (s: T) => void;
ha: HAService;
createMode: boolean;
langStore: LangStore;
}>;
}
);
@@ -15,6 +15,7 @@ import { Button } from "components/Inputs/Buttons/Button";
import { useState } from "react";
import AddIcon from "@mui/icons-material/Add";
import { InputTimeEntity } from "components/Inputs/AutoComplete/InputTimeEntity";
import { useLang } from "lang";
export const TriggerTime: OptionManager<AutomationTriggerTime> = {
defaultState: () => ({
@@ -115,10 +116,11 @@ export const TriggerTimePattern: FC<{
state: AutomationTriggerTimePattern;
setState: (t: AutomationTriggerTimePattern) => void;
}> = ({ state, setState }) => {
const lang = useLang();
return (
<div className="trigger-time--pattern">
<InputText
label="Hours"
label={lang.get("TIME_UNITS_HOURS")}
value={state.hours ?? ""}
onChange={(hours) =>
setState({
@@ -128,7 +130,7 @@ export const TriggerTimePattern: FC<{
}
/>
<InputText
label="Minutes"
label={lang.get("TIME_UNITS_MINUTES")}
value={state.minutes ?? ""}
onChange={(minutes) =>
setState({
@@ -138,7 +140,7 @@ export const TriggerTimePattern: FC<{
}
/>
<InputText
label="Seconds"
label={lang.get("TIME_UNITS_SECONDS")}
value={state.seconds ?? ""}
onChange={(seconds) =>
setState({
@@ -158,6 +158,7 @@ export const useEditorNodeState = (
setState={setState}
ha={ha}
createMode={createMode}
langStore={langStore}
/>
)}
</>