Skip to content

Commit

Permalink
Merge pull request #331 from Sudakatux/fix-cant-select-tasks
Browse files Browse the repository at this point in the history
Fix cant select tasks
  • Loading branch information
v1r3n authored Dec 16, 2024
2 parents b91a074 + 6696162 commit 590aab3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ui/src/pages/execution/RightPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function RightPanel({
const taskResult =
selectedNode?.data?.task?.executionData?.status === "PENDING"
? pendingTaskSelection(selectedNode?.data?.task)
: taskWithLatestIteration(execution?.tasks, selectedTask?.ref);
: taskWithLatestIteration(execution?.tasks, selectedTask);

const dfOptions = useMemo(
() => dag && dag.getSiblings(selectedTask),
Expand Down
6 changes: 3 additions & 3 deletions ui/src/pages/execution/TaskDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export default function TaskDetails({
const selectedTaskRefName =
data?.data?.task?.executionData?.status === "PENDING"
? pendingTaskSelection(data?.data?.task)?.workflowTask
?.taskReferenceName
: taskWithLatestIteration(execution?.tasks, data?.id)
?.referenceTaskName;
?.taskReferenceName
: taskWithLatestIteration(execution?.tasks, { ref: data.id })
?.referenceTaskName;
setSelectedNode(data);
setSelectedTask({ ref: selectedTaskRefName });
}}
Expand Down
28 changes: 19 additions & 9 deletions ui/src/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function astToQuery(node) {

return `${wrapper ? "(" : ""}${clauses.join(` ${combinator} `)}${
wrapper ? ")" : ""
}`;
}`;
} else {
return "";
}
Expand Down Expand Up @@ -99,16 +99,24 @@ export function getBasename() {
return _.isEmpty(basename) ? "/" : basename;
}

export const taskWithLatestIteration = (tasksList, taskReferenceName) => {
const filteredTasks = tasksList?.filter(
(task) =>
task?.workflowTask?.taskReferenceName === taskReferenceName ||
task?.referenceTaskName === taskReferenceName
);
export const taskWithLatestIteration = (tasksList = [], selectedTask) => {
const taskReferenceName = selectedTask?.ref;

const findTaskByReferenceName = (task) =>
task?.workflowTask?.taskReferenceName === taskReferenceName ||
task?.referenceTaskName === taskReferenceName;

const findTaskById = (task) => task?.taskId === selectedTask?.id;

// If reference name is not provided, use taskId to find the task
const findTask = selectedTask?.ref == null ? findTaskById : findTaskByReferenceName;

const filteredTasks = tasksList?.filter(findTask);

if (filteredTasks && filteredTasks.length === 1) {
// task without any retry/iteration
return _nth(filteredTasks, 0);
const targetTask = _nth(filteredTasks, 0);
return targetTask;
} else if (filteredTasks && filteredTasks.length > 1) {
const result = filteredTasks.reduce(
(acc, task, idx) => {
Expand All @@ -121,9 +129,11 @@ export const taskWithLatestIteration = (tasksList, taskReferenceName) => {
);

if (result?.idx > -1) {
return _nth(filteredTasks, result.idx);
const targetTask = _nth(filteredTasks, result.idx);
return targetTask;
}
}

return undefined;
};

Expand Down

0 comments on commit 590aab3

Please sign in to comment.