Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cant select tasks #331

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading