From 74b0b0d3db86649c9ce8b792c67f775584c1284b Mon Sep 17 00:00:00 2001 From: Alan Greene Date: Fri, 7 Jul 2023 13:10:18 +0100 Subject: [PATCH] Add support for TEP-0047 'displayName' When viewing a Pipeline or Task details page, include the 'displayName' alongside the 'description' if provided. On the PipelineRun details page, show the 'displayName' in the TaskTree instead of the pipelineTaskName. This also accounts for retries where the 'displayName' is used as the base instead. The details to the right still show the full TaskRun name as before. A future change may include display of the pipelineTask description so this is wired up but its display is omitted for now. --- .../src/components/PipelineRun/PipelineRun.js | 12 ++++++- .../ResourceDetails/ResourceDetails.js | 33 ++++++++++++------- .../TaskRunDetails/TaskRunDetails.js | 3 +- .../TaskRunDetails/TaskRunDetails.stories.js | 8 ++--- .../src/components/TaskTree/TaskTree.js | 4 ++- packages/utils/src/utils/constants.js | 2 ++ packages/utils/src/utils/index.js | 22 +++++++++++-- src/nls/messages_de.json | 2 ++ src/nls/messages_en.json | 2 ++ src/nls/messages_es.json | 2 ++ src/nls/messages_fr.json | 2 ++ src/nls/messages_it.json | 2 ++ src/nls/messages_ja.json | 2 ++ src/nls/messages_ko.json | 2 ++ src/nls/messages_pt.json | 2 ++ src/nls/messages_zh-Hans.json | 2 ++ src/nls/messages_zh-Hant.json | 2 ++ 17 files changed, 83 insertions(+), 21 deletions(-) diff --git a/packages/components/src/components/PipelineRun/PipelineRun.js b/packages/components/src/components/PipelineRun/PipelineRun.js index 1880a45b9..842785d71 100644 --- a/packages/components/src/components/PipelineRun/PipelineRun.js +++ b/packages/components/src/components/PipelineRun/PipelineRun.js @@ -169,6 +169,8 @@ export /* istanbul ignore next */ class PipelineRunContainer extends Component { }); const { podName } = taskRun.status || {}; + let displayName = + taskRun.metadata.labels?.[labelConstants.DASHBOARD_DISPLAY_NAME]; if (retryPodIndex[podName] || taskRun.status?.retriesStatus) { const retryNumber = @@ -178,8 +180,11 @@ export /* istanbul ignore next */ class PipelineRunContainer extends Component { id: 'dashboard.pipelineRun.pipelineTaskName.retry', defaultMessage: '{pipelineTaskName} (retry {retryNumber, number})' }, - { pipelineTaskName, retryNumber } + { pipelineTaskName: displayName || pipelineTaskName, retryNumber } ); + if (displayName) { + displayName = pipelineTaskName; + } } return { @@ -188,6 +193,11 @@ export /* istanbul ignore next */ class PipelineRunContainer extends Component { ...taskRun.metadata, labels: { ...taskRun.metadata.labels, + ...(displayName + ? { + [labelConstants.DASHBOARD_DISPLAY_NAME]: displayName + } + : null), [labelConstants.DASHBOARD_RETRY_NAME]: pipelineTaskName }, uid: `${uid}${podName}` diff --git a/packages/components/src/components/ResourceDetails/ResourceDetails.js b/packages/components/src/components/ResourceDetails/ResourceDetails.js index 3ee97396c..aa3f14e35 100644 --- a/packages/components/src/components/ResourceDetails/ResourceDetails.js +++ b/packages/components/src/components/ResourceDetails/ResourceDetails.js @@ -84,6 +84,28 @@ const ResourceDetails = ({ >
{children} diff --git a/packages/components/src/components/TaskRunDetails/TaskRunDetails.js b/packages/components/src/components/TaskRunDetails/TaskRunDetails.js index a7969f4ef..c5698d26e 100644 --- a/packages/components/src/components/TaskRunDetails/TaskRunDetails.js +++ b/packages/components/src/components/TaskRunDetails/TaskRunDetails.js @@ -122,7 +122,8 @@ const TaskRunDetails = ({ onViewChange, pod, task, taskRun, view }) => { /> ) : null; - const results = taskRun.status?.taskResults; + // taskResults renamed to results in v1 + const results = taskRun.status?.taskResults || taskRun.status?.results; const resultsTable = results?.length ? ( { } const { uid, labels, name } = taskRun.metadata; const { + [labelConstants.DASHBOARD_DISPLAY_NAME]: displayName, [labelConstants.PIPELINE_TASK]: pipelineTaskName, [labelConstants.DASHBOARD_RETRY_NAME]: retryName } = labels; + const { reason, status } = getStatus(taskRun); const { steps } = taskRun.status || {}; const expanded = @@ -44,7 +46,7 @@ const TaskTree = ({ onSelect, selectedStepId, selectedTaskId, taskRuns }) => { const selectDefaultStep = !selectedTaskId; return (