diff --git a/web/vtadmin/src/components/routes/workflows/WorkflowActions.tsx b/web/vtadmin/src/components/routes/workflows/WorkflowActions.tsx index 6f9bb1741fd..f8ac57162b4 100644 --- a/web/vtadmin/src/components/routes/workflows/WorkflowActions.tsx +++ b/web/vtadmin/src/components/routes/workflows/WorkflowActions.tsx @@ -133,26 +133,42 @@ const WorkflowActions: React.FC = ({ !(streamsByState['Copying'] && streamsByState['Copying'].length) && !(streamsByState['Stopped'] && streamsByState['Stopped'].length); + const isStopped = + !(streamsByState['Error'] && streamsByState['Error'].length) && + !(streamsByState['Copying'] && streamsByState['Copying'].length) && + !(streamsByState['Running'] && streamsByState['Running'].length); + const isSwitched = workflows && + isStopped && !!getReverseWorkflow( workflows, workflows.find((w) => w.workflow?.name === name && w.cluster?.id === clusterID) ); + const isReverseWorkflow = name.endsWith('_reverse'); + return (
- {isMoveTablesWorkflow && isSwitched && ( - setCurrentDialog('Complete MoveTables')}>Complete - )} - {isRunning && setCurrentDialog('Switch Traffic')}>Switch Traffic} - {isSwitched && setCurrentDialog('Reverse Traffic')}>Reverse Traffic} - {!isSwitched && ( - setCurrentDialog('Cancel Workflow')}>Cancel Workflow + {!isReverseWorkflow && ( + <> + {isMoveTablesWorkflow && isSwitched && ( + setCurrentDialog('Complete MoveTables')}>Complete + )} + {isRunning && ( + setCurrentDialog('Switch Traffic')}>Switch Traffic + )} + {isSwitched && ( + setCurrentDialog('Reverse Traffic')}>Reverse Traffic + )} + {!isSwitched && ( + setCurrentDialog('Cancel Workflow')}>Cancel Workflow + )} + )} - setCurrentDialog('Start Workflow')}>Start Workflow - setCurrentDialog('Stop Workflow')}>Stop Workflow + {!isRunning && setCurrentDialog('Start Workflow')}>Start Workflow} + {!isStopped && setCurrentDialog('Stop Workflow')}>Stop Workflow}