import "./safe.css"; import { Component, ErrorInfo } from "react"; import { DAGAutomationFlow, DAGAutomationFlowProps } from "."; import { AutomationSequenceNode } from "types/automations"; import { AutomationCondition } from "types/automations/conditions"; import { AutomationTrigger } from 'types/automations/triggers'; import InputYaml from "components/Inputs/InputYaml"; import { Button } from "components/Inputs/Button"; type GoodState = { hasError: false; } type FailedStateData = { sequence: AutomationSequenceNode[], condition: AutomationCondition[], trigger: AutomationTrigger[], } type FailedState = { hasError: true, error: any, errorInfo?: ErrorInfo, } & FailedStateData type State = GoodState | FailedState export class SafeDAGAutomationFlow extends Component { state: State = { hasError: false } componentDidCatch(error: Error, errorInfo: ErrorInfo) { this.setState({ hasError: true, error, errorInfo, sequence: this.props.sequence, condition: this.props.condition, trigger: this.props.trigger, }) } render() { if (this.state.hasError) { const makeSet = (k: K) => (d: FailedStateData[K]) => this.setState({ ...this.state, [k]: d, }); const makeSave = (k: K) => () => { if (!this.state.hasError) { return } if (k === 'condition') { this.props.onConditionUpdate(this.state.condition) } else if (k === 'sequence') { this.props.onSequenceUpdate(this.state.sequence) } else if (k === 'trigger') { this.props.onTriggerUpdate(this.state.trigger) } } return

An Error has occured.

Failed to Open Autmation!

Something is likely not configured in your automation properly.

Error:

{String(this.state.error)}


{JSON.stringify(this.state.error, null, 4)} {this.state.errorInfo && this.state.errorInfo.componentStack.split('\n').map((s, i) => <> {s}
)}

Automation YAML

} return ; } }