Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 3 additions & 5 deletions src/components/pipeline-topology/TaskList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import RemoveNodeDecorator from './RemoveNodeDecorator';
import { KebabOption, NewTaskNodeCallback } from './types';
import { TaskKind } from '../../types';
import { getReferenceForModel } from '../pipelines-overview/utils';
import { getResourceModelFromTaskKind } from '../utils/pipeline-augment';
import { getResourceModelFromTaskKind, getTaskName } from '../utils/pipeline-augment';
import { ResourceIcon } from '@openshift-console/dynamic-plugin-sdk';
import { truncateMiddle } from './truncate-middle';

Expand All @@ -20,10 +20,8 @@ const taskToOption = (
task: TaskKind,
callback: NewTaskNodeCallback,
): KeyedKebabOption => {
const {
kind,
metadata: { name },
} = task;
const { kind } = task;
const name = getTaskName(task)

return {
key: `${name}-${kind}`,
Expand Down
6 changes: 4 additions & 2 deletions src/components/pipelines-tasks/TasksRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
} from '@patternfly/react-core';
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
import { K8sCommonKebabMenu } from '../utils/k8s-common-kebab-menu';
import { TaskKind } from 'src/types';
import { getTaskName } from '../utils/pipeline-augment';

type TasksKebabProps = {
obj: K8sResourceCommon;
Expand Down Expand Up @@ -62,7 +64,7 @@ const TaskKebab: React.FC<TasksKebabProps> = ({ obj }) => {
);
};

const TaskRow: React.FC<RowProps<K8sResourceCommon>> = ({
const TaskRow: React.FC<RowProps<TaskKind>> = ({
activeColumnIDs,
obj,
}) => {
Expand All @@ -73,7 +75,7 @@ const TaskRow: React.FC<RowProps<K8sResourceCommon>> = ({
<TableData activeColumnIDs={activeColumnIDs} id="name">
<ResourceLink
kind={getReferenceForModel(TaskModel)}
name={obj.metadata.name}
name={getTaskName(obj)}
Comment thread
aThorp96 marked this conversation as resolved.
Outdated
namespace={obj.metadata.namespace}
/>
</TableData>
Expand Down
5 changes: 5 additions & 0 deletions src/components/utils/pipeline-augment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
PipelineKind,
PipelineRunKind,
PipelineTask,
TaskKind,
TaskRunKind,
} from '../../types';
import { getReferenceForModel } from '../pipelines-overview/utils';
Expand Down Expand Up @@ -309,6 +310,10 @@ export const getTaskStatus = (
return taskStatus;
};

export const getTaskName = (task: TaskKind): string => {
return task.spec.displayName || task.metadata?.name || 'anonymous-task';
};

export const getResourceModelFromTaskKind = (kind: string): K8sKind => {
if (kind === TaskModel.kind || kind === undefined) {
return TaskModel;
Expand Down
1 change: 1 addition & 0 deletions src/types/coreTekton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type TaskResult = {

export type TektonTaskSpec = {
metadata?: ObjectMetadata;
displayName?: string;
description?: string;
steps: TektonTaskSteps[];
params?: TektonParam[];
Expand Down