Skip to content

Commit

Permalink
Fix Pipeline Job titles are partially handled
Browse files Browse the repository at this point in the history
  • Loading branch information
uidoyen committed Jul 14, 2023
1 parent 58d77f1 commit 8c18297
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { usePipelinesAPI } from '~/concepts/pipelines/context';
import { PipelineCoreResourceKF } from '~/concepts/pipelines/kfTypes';
import { K8sAPIOptions } from '~/k8sTypes';
import useNotification from '~/utilities/useNotification';
import { getPipelineCoreResourceJobReference } from './tables/utils';

type DeletePipelineCoreResourceModalProps = {
type: 'triggered run' | 'scheduled run' | 'pipeline';
Expand Down Expand Up @@ -33,8 +34,8 @@ const DeletePipelineCoreResourceModal: React.FC<DeletePipelineCoreResourceModalP
if (state instanceof Error) {
const resource = toDeleteResources[i];
acc.push(
<p key={resource.name}>
For <b>{resource.name}</b>: {state.message}
<p key={getPipelineCoreResourceJobReference(resource)?.name}>
For <b>{getPipelineCoreResourceJobReference(resource)?.name}</b>: {state.message}
</p>,
);
}
Expand Down Expand Up @@ -120,7 +121,9 @@ const DeletePipelineCoreResourceModal: React.FC<DeletePipelineCoreResourceModalP
}}
submitButtonLabel={`Delete ${type}${resourceCount > 1 ? 's' : ''}`}
deleteName={
resourceCount === 1 ? toDeleteResources[0].name : `Delete ${resourceCount} ${type}s`
resourceCount === 1
? getPipelineCoreResourceJobReference(toDeleteResources[0])?.name
: `Delete ${resourceCount} ${type}s`
}
>
{resourceCount <= 1 ? (
Expand Down Expand Up @@ -161,7 +164,7 @@ const DeletePipelineCoreResourceModal: React.FC<DeletePipelineCoreResourceModalP

return (
<ListItem key={resource.id} icon={icon}>
{resource.name}
{getPipelineCoreResourceJobReference(resource)?.name}
</ListItem>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import DeletePipelineCoreResourceModal from '~/concepts/pipelines/content/DeletePipelineCoreResourceModal';
import { usePipelinesAPI } from '~/concepts/pipelines/context';
import PipelineRunTitle from '~/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTitle';
import { getPipelineCoreResourceJobReference } from '~/concepts/pipelines/content/tables/utils';

const getPipelineRunKind = (
pipelineRuntime?: PipelineRunResourceKF['pipeline_runtime'],
Expand Down Expand Up @@ -94,7 +95,9 @@ const PipelineRunDetails: PipelineCoreDetailsPageComponent = ({ breadcrumbPath,
<Breadcrumb>
{breadcrumbPath}
<BreadcrumbItem isActive>
{error ? 'Run details' : run?.name ?? 'Loading...'}
{error
? 'Run details'
: getPipelineCoreResourceJobReference(run)?.name ?? 'Loading...'}
</BreadcrumbItem>
</Breadcrumb>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Link } from 'react-router-dom';
import { PipelineRunKF } from '~/concepts/pipelines/kfTypes';
import {
getPipelineCoreResourcePipelineReference,
getPipelineCoreResourceJobReference,
getRunDuration,
} from '~/concepts/pipelines/content/tables/utils';
import { usePipelinesAPI } from '~/concepts/pipelines/context';
Expand Down Expand Up @@ -42,6 +43,7 @@ const PipelineRunTabDetails: React.FC<PipelineRunTabDetailsProps> = ({
}

const pipelineReference = getPipelineCoreResourcePipelineReference(pipelineRunKF);
const pipelineJobReference = getPipelineCoreResourceJobReference(pipelineRunKF);
const pipelineRef = pipelineReference
? [
{
Expand All @@ -57,7 +59,7 @@ const PipelineRunTabDetails: React.FC<PipelineRunTabDetailsProps> = ({
: [];

const details: DetailItem[] = [
{ key: 'Name', value: pipelineRunKF.name },
{ key: 'Name', value: pipelineJobReference?.name },
...pipelineRef,
{
key: 'Project',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { Label, Split, SplitItem } from '@patternfly/react-core';
import { PipelineRunKF } from '~/concepts/pipelines/kfTypes';
import { computeRunStatus } from '~/concepts/pipelines/content/utils';

import { getPipelineCoreResourceJobReference } from '~/concepts/pipelines/content/tables/utils';
type PipelineRunTitleProps = {
run?: PipelineRunKF;
};
Expand All @@ -16,7 +16,7 @@ const PipelineRunTitle: React.FC<PipelineRunTitleProps> = ({ run }) => {

return (
<Split hasGutter>
<SplitItem>{run.name}</SplitItem>
<SplitItem>{getPipelineCoreResourceJobReference(run)?.name}</SplitItem>
<SplitItem>
<Label icon={icon}>{label}</Label>
</SplitItem>
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/concepts/pipelines/content/tables/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ export const getStatusWeight = (run: PipelineRunKF): number => {
};

export const getRunResourceReference = (
resource: PipelineCoreResourceKF,
type: ResourceTypeKF,
resource?: PipelineCoreResourceKF,
type?: ResourceTypeKF,
): ResourceReferenceKF | undefined =>
resource.resource_references?.find((ref) => ref.key.type === type);
resource?.resource_references?.find((ref) => ref.key.type === type);

export const getPipelineCoreResourceJobReference = (
resource: PipelineCoreResourceKF,
resource?: PipelineCoreResourceKF,
): ResourceReferenceKF | undefined => getRunResourceReference(resource, ResourceTypeKF.JOB);

export const getPipelineCoreResourcePipelineReference = (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/projects/components/DeleteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type DeleteModalProps = {
onClose: () => void;
deleting: boolean;
onDelete: () => void;
deleteName: string;
deleteName?: string;
submitButtonLabel?: string;
error?: Error;
children: React.ReactNode;
Expand Down

0 comments on commit 8c18297

Please sign in to comment.