From 6be5828a1ad79aeacbc71ecc6e8eea3010c72bee Mon Sep 17 00:00:00 2001 From: Lokananda Prabhu Date: Tue, 1 Apr 2025 16:12:12 +0530 Subject: [PATCH] Fetching taskRuns in PLR details page using PLR UID also --- src/components/hooks/useTaskRuns.ts | 11 ++++++++++- src/components/pipelines-tasks/TaskRunsList.tsx | 4 ++++ src/consts.ts | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/hooks/useTaskRuns.ts b/src/components/hooks/useTaskRuns.ts index 6f9fe269..3dcc714f 100644 --- a/src/components/hooks/useTaskRuns.ts +++ b/src/components/hooks/useTaskRuns.ts @@ -44,8 +44,17 @@ export const useTaskRuns = ( pipelineRunName?: string, taskName?: string, cacheKey?: string, + pipelineRunUid?: string, ): [TaskRunKind[], boolean, unknown, GetNextPage] => { const selector: Selector = React.useMemo(() => { + if (pipelineRunName && pipelineRunUid) { + return { + matchLabels: { + [TektonResourceLabel.pipelinerun]: pipelineRunName, + [TektonResourceLabel.pipelineRunUid]: pipelineRunUid, + }, + }; + } if (pipelineRunName) { return { matchLabels: { [TektonResourceLabel.pipelinerun]: pipelineRunName }, @@ -55,7 +64,7 @@ export const useTaskRuns = ( return { matchLabels: { [TektonResourceLabel.pipelineTask]: taskName } }; } return undefined; - }, [taskName, pipelineRunName]); + }, [taskName, pipelineRunName, pipelineRunUid]); const [taskRuns, loaded, error, getNextPage] = useTaskRuns2( namespace, selector && { diff --git a/src/components/pipelines-tasks/TaskRunsList.tsx b/src/components/pipelines-tasks/TaskRunsList.tsx index 29435a44..48cc3a8f 100644 --- a/src/components/pipelines-tasks/TaskRunsList.tsx +++ b/src/components/pipelines-tasks/TaskRunsList.tsx @@ -115,9 +115,13 @@ const TaskRunsList: React.FC = ({ const ns = namespace === ALL_NAMESPACES_KEY ? '-' : namespace; const sortColumnIndex = !namespace ? 6 : 5; const parentName = props?.obj?.metadata?.name; + const parentUid = props?.obj?.metadata?.uid; const [taskRuns, loaded, loadError, nextPageToken] = useTaskRuns( ns, parentName, + undefined, + undefined, + parentUid, ); const [staticData, filteredData, onFilterChange] = useListPageFilter( taskRuns, diff --git a/src/consts.ts b/src/consts.ts index 3588ca73..4e2bd791 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -83,6 +83,7 @@ export enum StartedByAnnotation { export enum TektonResourceLabel { pipeline = 'tekton.dev/pipeline', pipelinerun = 'tekton.dev/pipelineRun', + pipelineRunUid = 'tekton.dev/pipelineRunUID', taskrun = 'tekton.dev/taskRun', pipelineTask = 'tekton.dev/pipelineTask', }