import React from "react"; import { observer } from "mobx-react"; import classNames from "classnames"; import { ITreeNode, Tree } from "eez-studio-ui/tree"; import { action, computed, makeObservable } from "mobx"; import { FlowState, RuntimeBase } from "project-editor/flow/runtime/runtime"; import { getFlowStateLabel } from "project-editor/flow/debugger/logs"; import { Panel } from "project-editor/ui-components/Panel"; import { ProjectContext } from "project-editor/project/context"; //////////////////////////////////////////////////////////////////////////////// export const ActiveFlowsPanel = observer( class ActiveFlowsPanel extends React.Component<{ runtime: RuntimeBase; }> { static contextType = ProjectContext; declare context: React.ContextType; render() { return (
) => { this.context.uiStateStore.showFinishedFlowsInDebugger = event.target.checked; } )} />
]} body={} > ); } } ); const FlowsTree = observer( class FlowsTree extends React.Component<{ runtime: RuntimeBase }> { static contextType = ProjectContext; declare context: React.ContextType; constructor(props: { runtime: RuntimeBase }) { super(props); makeObservable(this, { rootNode: computed, selectNode: action.bound }); } get rootNode(): ITreeNode { const selectedFlowState = this.props.runtime.selectedFlowState; const showFinishedFlowsInDebugger = this.context.uiStateStore.showFinishedFlowsInDebugger; function getChildren( flowStates: FlowState[] ): ITreeNode[] { return flowStates .filter( flowState => !flowState.isFinished || showFinishedFlowsInDebugger ) .map(flowState => ({ id: flowState.id, label: (
{getFlowStateLabel(flowState)}
), children: getChildren(flowState.flowStates), selected: flowState === selectedFlowState, expanded: true, data: flowState })); } return { id: "all", label: "All", children: getChildren(this.props.runtime.flowStates), selected: false, expanded: true }; } selectNode(node?: ITreeNode) { this.props.runtime.logs.selectedLogItem = undefined; const flowState = node?.data; this.props.runtime.selectedFlowState = flowState; this.props.runtime.showSelectedFlowState(); } render() { return ( ); } } );