Skip to content

Commit

Permalink
update pipelinerun graph to show past pipeline structure
Browse files Browse the repository at this point in the history
  • Loading branch information
karthik committed Nov 4, 2020
1 parent a6b7e84 commit f33b7df
Show file tree
Hide file tree
Showing 17 changed files with 461 additions and 629 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,16 @@
import * as React from 'react';
import { Alert } from '@patternfly/react-core';
import { k8sGet } from '@console/internal/module/k8s';
import { PipelineModel } from '../../../models';
import PipelineVisualization from '../../pipelines/detail-page-tabs/pipeline-details/PipelineVisualization';
import { Pipeline, PipelineRun, pipelineRefExists } from '../../../utils/pipeline-augment';
import { PipelineRun, getPipelineFromPipelineRun } from '../../../utils/pipeline-augment';

type PipelineRunVisualizationProps = {
pipelineRun: PipelineRun;
};

const PipelineRunVisualization: React.FC<PipelineRunVisualizationProps> = ({ pipelineRun }) => {
const [errorMessage, setErrorMessage] = React.useState<string>(null);
const [pipeline, setPipeline] = React.useState<Pipeline>(null);

React.useEffect(() => {
if (pipelineRefExists(pipelineRun)) {
k8sGet(PipelineModel, pipelineRun.spec.pipelineRef.name, pipelineRun.metadata.namespace)
.then((res: Pipeline) => setPipeline(res))
.catch((error) =>
setErrorMessage(error?.message || 'Could not load visualization at this time.'),
);
}
}, [pipelineRun, setPipeline]);

if (errorMessage) {
return <Alert variant="danger" isInline title={errorMessage} />;
}

if (!pipeline || !pipelineRun) {
return null;
}

return <PipelineVisualization pipeline={pipeline} pipelineRun={pipelineRun} />;
};
const PipelineRunVisualization: React.FC<PipelineRunVisualizationProps> = ({ pipelineRun }) => (
<PipelineVisualization
pipeline={getPipelineFromPipelineRun(pipelineRun)}
pipelineRun={pipelineRun}
/>
);

export default PipelineRunVisualization;
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import * as React from 'react';
import { Link } from 'react-router-dom';
import { resourcePathFromModel } from '@console/internal/components/utils';
import { Pipeline, PipelineRun } from '../../../utils/pipeline-augment';
import { PipelineRun } from '../../../utils/pipeline-augment';
import { PipelineRunModel } from '../../../models';
import { PipelineTaskStatus } from './PipelineTaskStatus';
import { PipelineBars } from './PipelineBars';

export interface LinkedPipelineRunTaskStatusProps {
pipeline?: Pipeline;
pipelineRun: PipelineRun;
}

Expand All @@ -15,15 +14,10 @@ export interface LinkedPipelineRunTaskStatusProps {
* If it does not, it'll just render the pipeline status.
*/
const LinkedPipelineRunTaskStatus: React.FC<LinkedPipelineRunTaskStatusProps> = ({
pipeline,
pipelineRun,
}) => {
const pipelineStatus = (
<PipelineTaskStatus
key={pipelineRun.metadata?.name}
pipeline={pipeline}
pipelinerun={pipelineRun}
/>
<PipelineBars key={pipelineRun.metadata?.name} pipelinerun={pipelineRun} />
);

if (pipelineRun.metadata?.name && pipelineRun.metadata?.namespace) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ import {
getTaskStatus,
runStatus,
getRunStatusColor,
Pipeline,
PipelineRun,
} from '../../../utils/pipeline-augment';
import TaskStatusToolTip from './TaskStatusTooltip';

export interface PipelineBarProps {
pipelinerun: PipelineRun;
pipeline?: { data: Pipeline };
}

export const PipelineBars: React.FC<PipelineBarProps> = ({ pipelinerun, pipeline }) => {
const taskStatus = getTaskStatus(pipelinerun, pipeline?.data);
export const PipelineBars: React.FC<PipelineBarProps> = ({ pipelinerun }) => {
const taskStatus = getTaskStatus(pipelinerun);

return (
<Tooltip content={<TaskStatusToolTip taskStatus={taskStatus} />}>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum StartedByAnnotation {
}

export enum TektonResourceLabel {
pipeline = 'tekton.dev/pipeline',
pipelinerun = 'tekton.dev/pipelineRun',
taskrun = 'tekton.dev/taskRun',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ const PipelineRow: RowFunction<Pipeline> = ({ obj, index, key, style }) => {
)}
</TableData>
<TableData className={tableColumnClasses[3]}>
{obj.latestRun ? (
<LinkedPipelineRunTaskStatus pipeline={obj} pipelineRun={obj.latestRun} />
) : (
'-'
)}
{obj.latestRun ? <LinkedPipelineRunTaskStatus pipelineRun={obj.latestRun} /> : '-'}
</TableData>
<TableData className={tableColumnClasses[4]}>
<Status status={pipelineFilterReducer(obj)} />
Expand Down
Loading

0 comments on commit f33b7df

Please sign in to comment.