import { formatPayloadForCommandInput } from '../utils.js'; import type { DevHostFlowEntry, DevHostFlowRunState } from '../types.js'; import { Button } from './ui/Button.js'; type FlowListProps = { flows: DevHostFlowEntry[]; flowRuns: DevHostFlowRunState[]; hasRunningFlow: (flowName: string) => boolean; onRunFlow: (flow: DevHostFlowEntry) => void; onStopFlow: (runId: string) => void; }; const getStatusLabel = (status: DevHostFlowRunState['status']) => { if (status === 'running') { return 'Running'; } if (status === 'succeeded') { return 'Completed'; } if (status === 'failed') { return 'Failed'; } if (status === 'aborted') { return 'Stopped'; } return status; }; export const FlowList = ({ flows, flowRuns, hasRunningFlow, onRunFlow, onStopFlow }: FlowListProps) => { if (flows.length === 0) { return
No flows were configured for this plugin.
; } const hasExecutionState = flowRuns.length > 0; return (
Available flows
{flows.map((flow, index) => { const isActive = hasRunningFlow(flow.name); return ( ); })}
{hasExecutionState ? (
Flow runs
{flowRuns.map((flowRun) => { const isRunning = flowRun.status === 'running'; return (
{flowRun.flowDisplayName} {flowRun.autoRun ? Auto : null}
{isRunning ? ( ) : null}
{getStatusLabel(flowRun.status)}
{flowRun.error ? (
{flowRun.error}
) : null} {flowRun.result != null ? (
                      {formatPayloadForCommandInput(flowRun.result)}
                    
) : null}
); })}
) : null}
); };