wait template
This commit is contained in:
1 parent
240f8faef7
commit
e3a816f2c8
4 files changed
+65
-32
No files matched your search
@@ -30,6 +30,30 @@ export const ActionWaitState: OptionManager<ThisAction> = {
|
||||
const update = updateActionData(state, setState);
|
||||
const [current, _setCurrent] = useState(getCurrentOption(state));
|
||||
const setCurrent = (opt: Option) => {
|
||||
const base: any = {
|
||||
alias: state.alias,
|
||||
variables: state.variables,
|
||||
}
|
||||
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') {
|
||||
setState({
|
||||
...base,
|
||||
wait_template: (state as any).wait_template ?? "",
|
||||
})
|
||||
} else {
|
||||
setState({
|
||||
...base,
|
||||
wait_for_trigger: (state as any).wait_for_trigger ?? "",
|
||||
})
|
||||
}
|
||||
}
|
||||
_setCurrent(opt)
|
||||
}
|
||||
|
||||
@@ -72,8 +96,8 @@ export const ActionWaitState: OptionManager<ThisAction> = {
|
||||
{current !== 'delay' ? <div className="wait-options">
|
||||
<InputNumber
|
||||
label="Timeout"
|
||||
value={(state as any).timeout ? Number((state as any).timeout) : 0}
|
||||
onChange={(timeout = 0) => update({ timeout: String(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"
|
||||
|
||||
@@ -15,23 +15,32 @@ export type OptionManager<T> = {
|
||||
}>
|
||||
})
|
||||
|
||||
export const cleanUpUndefined = (data: Record<string, any>): any => {
|
||||
const clean: any = {};
|
||||
Object.keys(data).forEach(k => {
|
||||
if ((data[k] !== undefined) && (data[k] !== null)) {
|
||||
clean[k] = data[k]
|
||||
}
|
||||
})
|
||||
return clean;
|
||||
}
|
||||
|
||||
export const updateConditionData = <T extends AutomationCondition>(
|
||||
setState: (s: T) => void
|
||||
) => (
|
||||
state: T,
|
||||
data: Partial<T>,
|
||||
) => setState({
|
||||
) => setState(cleanUpUndefined({
|
||||
...state,
|
||||
...data,
|
||||
})
|
||||
}))
|
||||
|
||||
export const updateActionData = <T extends AutomationAction>(
|
||||
state: T,
|
||||
setState: (s: T) => void
|
||||
) => (
|
||||
data: Partial<T>,
|
||||
) => setState({
|
||||
) => setState(cleanUpUndefined({
|
||||
...state,
|
||||
...data,
|
||||
})
|
||||
}))
|
||||
Reference in new issue
Block a user