fixed typing for repeat
This commit is contained in:
1 parent
595aa2dfa1
commit
f392cf17fd
5 files changed
+135
-54
No files matched your search
@@ -1,37 +1,43 @@
|
||||
import InputNumber from "components/Inputs/InputNumber";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import { RepeatAction } from "types/automations/actions";
|
||||
import { OptionManager, updateActionData } from './OptionManager';
|
||||
|
||||
import { OptionManager, updateActionData } from "./OptionManager";
|
||||
|
||||
export const ActionRepeatState: OptionManager<RepeatAction> = {
|
||||
defaultState: () => ({
|
||||
alias: "Repeat",
|
||||
repeat: {
|
||||
count: 1,
|
||||
while: [],
|
||||
sequence: [],
|
||||
}
|
||||
},
|
||||
}),
|
||||
isReady: ({
|
||||
alias,
|
||||
repeat,
|
||||
}) => (
|
||||
alias !== '' &&
|
||||
repeat?.sequence.length > 0
|
||||
),
|
||||
isReady: ({ alias, repeat }) => alias !== "" && repeat?.sequence.length > 0,
|
||||
renderOptionList: (state, setState) => {
|
||||
const update = updateActionData(state, setState);
|
||||
return <>
|
||||
<InputNumber
|
||||
label="How many times?"
|
||||
value={state.repeat.count}
|
||||
onChange={(count = 1) => update({ repeat: { ...state.repeat, count } })}
|
||||
/>
|
||||
<InputYaml
|
||||
label="Sequence"
|
||||
value={state.repeat.sequence ?? []}
|
||||
onChange={sequence => update({ repeat: { ...state.repeat, sequence } })}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<InputNumber
|
||||
label="How many times?"
|
||||
value={state.repeat.count}
|
||||
onChange={(count = 1) =>
|
||||
update({ repeat: { ...state.repeat, count } })
|
||||
}
|
||||
/>
|
||||
<InputYaml
|
||||
label="Sequence"
|
||||
value={state.repeat.sequence ?? []}
|
||||
onChange={(sequence) =>
|
||||
update({ repeat: { ...state.repeat, sequence } })
|
||||
}
|
||||
/>
|
||||
<InputYaml
|
||||
label="Condition"
|
||||
value={state.repeat.while ?? []}
|
||||
onChange={(sequence) =>
|
||||
update({ repeat: { ...state.repeat, sequence } })
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user