Skip to content

Commit f2d0df1

Browse files
vishakha1411karenbraganz
authored andcommitted
UI: Fix mapped task XCom navigation from Grid apache#64875 (apache#65192)
* UI: Fix mapped task XCom navigation from Grid * Add regression test for mapped task navigation
1 parent 1ad66a2 commit f2d0df1

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

airflow-core/src/airflow/ui/src/utils/links.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,16 @@ describe("buildTaskInstanceUrl", () => {
271271
}),
272272
).toBe("/dags/my_dag/runs/run_1/tasks/group/my_group");
273273
});
274+
275+
it("should not preserve sub-routes for mapped tasks without map index", () => {
276+
expect(
277+
buildTaskInstanceUrl({
278+
currentPathname: "/dags/old_dag/runs/old_run/tasks/old_task/mapped/2/xcom",
279+
dagId: "new_dag",
280+
isMapped: true,
281+
runId: "new_run",
282+
taskId: "new_task",
283+
}),
284+
).toBe("/dags/new_dag/runs/new_run/tasks/new_task/mapped");
285+
});
274286
});

airflow-core/src/airflow/ui/src/utils/links.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ export const buildTaskInstanceUrl = (params: {
8484
}): string => {
8585
const { currentPathname, dagId, isGroup = false, isMapped = false, mapIndex, runId, taskId } = params;
8686
const groupPath = isGroup ? "group/" : "";
87-
// Task groups only have "Task Instances" tab, so never preserve tabs for groups
88-
const additionalPath = isGroup ? "" : getTaskInstanceAdditionalPath(currentPathname);
87+
const additionalPath =
88+
isGroup || (isMapped && (mapIndex === undefined || mapIndex === "-1"))
89+
? ""
90+
: getTaskInstanceAdditionalPath(currentPathname);
8991

9092
let basePath = `/dags/${dagId}/runs/${runId}/tasks/${groupPath}${taskId}`;
9193

0 commit comments

Comments
 (0)