Skip to content

Commit 862bb7f

Browse files
ivicacclaude
andcommitted
Fix PR review comments for stop job functionality
- Set endDate when cancelling task execution in StopJobTaskDispatcherPreSendProcessor for consistency with TaskCoordinator.onStopJobEvent - Add endDate assertion to test - Add query cache invalidation in WorkflowExecutionsDropdownMenu onSuccess - Derive disabled state from data prop instead of local state for synchronization - Wrap logger.debug in isDebugEnabled check for consistency Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3d565ee commit 862bb7f

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

client/src/pages/automation/workflow-executions/components/WorkflowExecutionsDropdownMenu.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@ import {DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger
33
import {useToast} from '@/hooks/use-toast';
44
import {WorkflowExecution} from '@/shared/middleware/automation/workflow/execution';
55
import {useStopJobMutation} from '@/shared/mutations/platform/jobs.mutations';
6+
import {WorkflowExecutionKeys} from '@/shared/queries/automation/workflowExecutions.queries';
7+
import {useQueryClient} from '@tanstack/react-query';
68
import {CellContext} from '@tanstack/react-table';
79
import {CircleStopIcon, EllipsisVerticalIcon, ViewIcon} from 'lucide-react';
8-
import {useState} from 'react';
910

1011
import useWorkflowExecutionSheetStore from '../stores/useWorkflowExecutionSheetStore';
1112

1213
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1314
const WorkflowExecutionsDropdownMenu = ({data}: {data: CellContext<WorkflowExecution, any>}) => {
14-
const [disabled, setDisabled] = useState(data.getValue()?.status !== 'STARTED');
1515
const {toast} = useToast();
1616

17+
const queryClient = useQueryClient();
18+
1719
const {setWorkflowExecutionId, setWorkflowExecutionSheetOpen} = useWorkflowExecutionSheetStore();
1820

1921
const stopJobMutation = useStopJobMutation({
@@ -22,13 +24,20 @@ const WorkflowExecutionsDropdownMenu = ({data}: {data: CellContext<WorkflowExecu
2224
className: 'mt-2 w-[340px] rounded-md bg-red-600 p-4 text-white',
2325
description: 'Failed to stop Workflow Execution',
2426
}),
25-
onSuccess: () =>
27+
onSuccess: () => {
2628
toast({
2729
className: 'mt-2 w-[340px] rounded-md bg-green-600 p-4 text-white',
2830
description: 'Stopping Workflow Execution',
29-
}),
31+
});
32+
33+
queryClient.invalidateQueries({
34+
queryKey: WorkflowExecutionKeys.workflowExecutions,
35+
});
36+
},
3037
});
3138

39+
const disabled = data.getValue()?.status !== 'STARTED';
40+
3241
const handleViewClick = () => {
3342
const id = data.row.original.id;
3443

@@ -40,7 +49,6 @@ const WorkflowExecutionsDropdownMenu = ({data}: {data: CellContext<WorkflowExecu
4049

4150
const handleStopWorkflowExecutionClick = (id: number) => {
4251
stopJobMutation.mutate(id);
43-
setDisabled(true);
4452
};
4553

4654
return (

server/libs/atlas/atlas-coordinator/atlas-coordinator-impl/src/main/java/com/bytechef/atlas/coordinator/task/dispatcher/DefaultTaskDispatcher.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ public void dispatch(TaskExecution taskExecution) {
6262

6363
TaskWorkerMessageRoute messageRoute = calculateQueueName(taskExecution);
6464

65-
logger.debug(
66-
"Task id={}, type='{}' sent to route='{}'", taskExecution.getId(), taskExecution.getType(), messageRoute);
65+
if (logger.isDebugEnabled()) {
66+
logger.debug(
67+
"Task id={}, type='{}' sent to route='{}'", taskExecution.getId(), taskExecution.getType(),
68+
messageRoute);
69+
}
6770

6871
eventPublisher.publishEvent(new TaskExecutionEvent(messageRoute, taskExecution));
6972
}

server/libs/atlas/atlas-coordinator/atlas-coordinator-impl/src/main/java/com/bytechef/atlas/coordinator/task/dispatcher/StopJobTaskDispatcherPreSendProcessor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.bytechef.atlas.execution.domain.TaskExecution;
2121
import com.bytechef.atlas.execution.service.JobService;
2222
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
23+
import java.time.Instant;
2324
import org.apache.commons.lang3.Validate;
2425
import org.springframework.core.Ordered;
2526
import org.springframework.core.annotation.Order;
@@ -44,6 +45,7 @@ public TaskExecution process(TaskExecution taskExecution) {
4445
Job job = jobService.getJob(Validate.notNull(taskExecution.getJobId(), "jobId"));
4546

4647
if (job.getStatus() == Job.Status.STOPPED) {
48+
taskExecution.setEndDate(Instant.now());
4749
taskExecution.setStatus(TaskExecution.Status.CANCELLED);
4850
}
4951

server/libs/atlas/atlas-coordinator/atlas-coordinator-impl/src/test/java/com/bytechef/atlas/coordinator/task/dispatcher/StopJobTaskDispatcherPreSendProcessorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public void testProcessWithStoppedJob() {
6161
taskExecution = process(Job.Status.STOPPED);
6262

6363
assertThat(taskExecution.getStatus()).isEqualTo(TaskExecution.Status.CANCELLED);
64+
assertThat(taskExecution.getEndDate()).isNotNull();
6465
}
6566

6667
private TaskExecution process(Job.Status status) {

0 commit comments

Comments
 (0)