Skip to content

Commit

Permalink
Additional checks to display workflow actions
Browse files Browse the repository at this point in the history
Signed-off-by: Noble Mittal <noblemittal@outlook.com>
  • Loading branch information
beingnoble03 committed Oct 10, 2024
1 parent ddc5e74 commit bb02cc3
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions web/vtadmin/src/components/routes/workflows/WorkflowActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,26 +133,42 @@ const WorkflowActions: React.FC<WorkflowActionsProps> = ({
!(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 (
<div className="w-min inline-block">
<Dropdown dropdownButton={Icons.info}>
{isMoveTablesWorkflow && isSwitched && (
<MenuItem onClick={() => setCurrentDialog('Complete MoveTables')}>Complete</MenuItem>
)}
{isRunning && <MenuItem onClick={() => setCurrentDialog('Switch Traffic')}>Switch Traffic</MenuItem>}
{isSwitched && <MenuItem onClick={() => setCurrentDialog('Reverse Traffic')}>Reverse Traffic</MenuItem>}
{!isSwitched && (
<MenuItem onClick={() => setCurrentDialog('Cancel Workflow')}>Cancel Workflow</MenuItem>
{!isReverseWorkflow && (
<>
{isMoveTablesWorkflow && isSwitched && (
<MenuItem onClick={() => setCurrentDialog('Complete MoveTables')}>Complete</MenuItem>
)}
{isRunning && (
<MenuItem onClick={() => setCurrentDialog('Switch Traffic')}>Switch Traffic</MenuItem>
)}
{isSwitched && (
<MenuItem onClick={() => setCurrentDialog('Reverse Traffic')}>Reverse Traffic</MenuItem>
)}
{!isSwitched && (
<MenuItem onClick={() => setCurrentDialog('Cancel Workflow')}>Cancel Workflow</MenuItem>
)}
</>
)}
<MenuItem onClick={() => setCurrentDialog('Start Workflow')}>Start Workflow</MenuItem>
<MenuItem onClick={() => setCurrentDialog('Stop Workflow')}>Stop Workflow</MenuItem>
{!isRunning && <MenuItem onClick={() => setCurrentDialog('Start Workflow')}>Start Workflow</MenuItem>}
{!isStopped && <MenuItem onClick={() => setCurrentDialog('Stop Workflow')}>Stop Workflow</MenuItem>}
</Dropdown>
<WorkflowAction
title="Start Workflow"
Expand Down

0 comments on commit bb02cc3

Please sign in to comment.