Skip to content

Commit 73e91c4

Browse files
committed
feat: Add results column into pipeline table (#557)
1 parent 86cfa69 commit 73e91c4

File tree

6 files changed

+77
-20
lines changed

6 files changed

+77
-20
lines changed

src/components/InfoColumns/index.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ export const InfoColumns = ({ infoRows }: InfoColumnsProps) => {
1414
<React.Fragment key={`column::${index}`}>
1515
{!!label && !!text && (
1616
<Grid item xs={columnXs as GridSize}>
17-
<Typography fontWeight={500} fontSize={14} color="primary.dark" gutterBottom>
17+
<Typography
18+
component="div"
19+
fontWeight={500}
20+
fontSize={14}
21+
color="primary.dark"
22+
gutterBottom
23+
>
1824
{label}
1925
</Typography>
2026
<Grid container spacing={1} alignItems={'center'}>
@@ -27,7 +33,7 @@ export const InfoColumns = ({ infoRows }: InfoColumnsProps) => {
2733
)}
2834
</Grid>
2935
)}
30-
<Grid item>
36+
<Grid item flexGrow={1}>
3137
<Typography
3238
fontSize={13}
3339
color="secondary.dark"

src/k8s/groups/Tekton/PipelineRun/utils/createBuildPipelineRunInstance/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const createBuildPipelineRunInstance = ({
6262
base.metadata.labels[PIPELINE_RUN_LABEL_SELECTOR_CODEBASE_BRANCH] = codebaseBranchMetadataName;
6363
base.metadata.labels[PIPELINE_RUN_LABEL_SELECTOR_PIPELINE_TYPE] = PIPELINE_TYPES.BUILD;
6464

65-
base.spec.pipelineRef.name = codebaseBranch.spec.pipelines.build;
65+
base.spec.pipelineRef.name = codebaseBranch.spec?.pipelines?.build;
6666

6767
base.spec.workspaces = [
6868
...base.spec.workspaces,

src/pages/component-details/providers/DynamicData/provider.tsx

+17-14
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useParams } from 'react-router-dom';
44
import { CodebaseKubeObject } from '../../../../k8s/groups/EDP/Codebase';
55
import { CodebaseBranchKubeObject } from '../../../../k8s/groups/EDP/CodebaseBranch';
66
import { CODEBASE_BRANCH_LABEL_SELECTOR_CODEBASE_NAME } from '../../../../k8s/groups/EDP/CodebaseBranch/labels';
7+
import { CodebaseBranchKubeObjectInterface } from '../../../../k8s/groups/EDP/CodebaseBranch/types';
78
import { useGitServerByCodebaseQuery } from '../../../../k8s/groups/EDP/GitServer/hooks/useGitServerByCodebaseQuery';
89
import {
910
generateBuildPipelineRef,
@@ -26,16 +27,6 @@ export const DynamicDataContextProvider: React.FC = ({ children }) => {
2627
props: { codebaseGitServer: component?.spec.gitServer },
2728
});
2829

29-
const reviewPipelineRefName = generateReviewPipelineRef({
30-
gitServer: gitServerByCodebase,
31-
component: component,
32-
});
33-
34-
const buildPipelineRefName = generateBuildPipelineRef({
35-
gitServer: gitServerByCodebase,
36-
component: component,
37-
});
38-
3930
const [codebaseBranches, codebaseBranchesError] = CodebaseBranchKubeObject.useList({
4031
namespace,
4132
labelSelector: `${CODEBASE_BRANCH_LABEL_SELECTOR_CODEBASE_NAME}=${name}`,
@@ -46,6 +37,8 @@ export const DynamicDataContextProvider: React.FC = ({ children }) => {
4637
? null
4738
: codebaseBranches?.sort((a) => (isDefaultBranch(component, a) ? -1 : 1));
4839

40+
const defaultBranch: CodebaseBranchKubeObjectInterface = sortedCodebaseBranches?.[0];
41+
4942
const DataContextValue = React.useMemo(
5043
() => ({
5144
component: {
@@ -55,8 +48,18 @@ export const DynamicDataContextProvider: React.FC = ({ children }) => {
5548
},
5649
pipelines: {
5750
data: {
58-
review: reviewPipelineRefName,
59-
build: buildPipelineRefName,
51+
review:
52+
defaultBranch?.spec?.pipelines?.review ||
53+
generateReviewPipelineRef({
54+
gitServer: gitServerByCodebase,
55+
component: component,
56+
}),
57+
build:
58+
defaultBranch?.spec?.pipelines?.build ||
59+
generateBuildPipelineRef({
60+
gitServer: gitServerByCodebase,
61+
component: component,
62+
}),
6063
},
6164
error: error,
6265
isLoading: component === null,
@@ -73,15 +76,15 @@ export const DynamicDataContextProvider: React.FC = ({ children }) => {
7376
},
7477
}),
7578
[
76-
buildPipelineRefName,
7779
codebaseBranches,
7880
codebaseBranchesError,
7981
component,
82+
defaultBranch?.spec?.pipelines?.build,
83+
defaultBranch?.spec?.pipelines?.review,
8084
error,
8185
gitServerByCodebase,
8286
gitServerByCodebaseError,
8387
gitServerByCodebaseIsLoading,
84-
reviewPipelineRefName,
8588
sortedCodebaseBranches,
8689
]
8790
);

src/pages/pipeline-details/components/Overview/hooks/useInfoRows.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { InfoRow } from '../../../../../components/InfoColumns/types';
44
import { StatusIcon } from '../../../../../components/StatusIcon';
55
import { PipelineRunKubeObject } from '../../../../../k8s/groups/Tekton/PipelineRun';
66
import { humanize } from '../../../../../utils/date/humanize';
7+
import { PipelineRunResults } from '../../../../../widgets/PipelineRunResults';
78
import { useDynamicDataContext } from '../../../providers/DynamicData/hooks';
89

910
export const useInfoRows = (): InfoRow[] | null => {
@@ -111,11 +112,23 @@ export const useInfoRows = (): InfoRow[] | null => {
111112
columnXs: 12,
112113
},
113114
],
115+
[
116+
...(pipelineRun.data?.status?.results
117+
? [
118+
{
119+
label: 'Results',
120+
text: <PipelineRunResults pipelineRun={pipelineRun.data} />,
121+
columnXs: 6,
122+
},
123+
]
124+
: []),
125+
],
114126
];
115127
}, [
116128
color,
117129
icon,
118130
isRotating,
131+
pipelineRun.data,
119132
pipelineRunLabels,
120133
reason,
121134
status,

src/widgets/PipelineRunList/hooks/useColumns.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { routePipelineRunDetails } from '../../../pages/pipeline-details/route';
1515
import { useDialogContext } from '../../../providers/Dialog/hooks';
1616
import { humanize } from '../../../utils/date/humanize';
1717
import { PipelineRunGraphDialog } from '../../dialogs/PipelineRunGraph';
18+
import { PipelineRunResults } from '../../PipelineRunResults';
1819
import { Actions } from '../components/Actions';
1920
import { WidgetPermissions } from '../types';
2021

@@ -98,6 +99,12 @@ export const useColumns = ({
9899
},
99100
width: '15%',
100101
},
102+
{
103+
id: 'results',
104+
label: 'Results',
105+
render: (resource) => <PipelineRunResults pipelineRun={resource} />,
106+
width: '30%',
107+
},
101108
{
102109
id: 'pullRequestUrl',
103110
label: 'Pull Request',
@@ -117,7 +124,7 @@ export const useColumns = ({
117124
/>
118125
);
119126
},
120-
width: '10%',
127+
width: '5%',
121128
textAlign: 'center',
122129
},
123130
{
@@ -148,8 +155,9 @@ export const useColumns = ({
148155

149156
return startedAt;
150157
},
151-
width: '15%',
158+
width: '10%',
152159
},
160+
153161
{
154162
id: 'time',
155163
label: 'Time',
@@ -193,7 +201,7 @@ export const useColumns = ({
193201

194202
return activeDuration;
195203
},
196-
width: '30%',
204+
width: '10%',
197205
},
198206
{
199207
id: 'diagram',
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Table, TableBody, TableCell, TableRow } from '@mui/material';
2+
import React from 'react';
3+
4+
export const PipelineRunResults = ({ pipelineRun }) => {
5+
const results = pipelineRun?.status?.results || [];
6+
7+
if (results.length === 0) {
8+
return null;
9+
}
10+
11+
return (
12+
<Table size="small">
13+
<colgroup>
14+
<col style={{ width: '30%' }} />
15+
<col style={{ width: '70%' }} />
16+
</colgroup>
17+
<TableBody>
18+
{results.map((el) => (
19+
<TableRow>
20+
<TableCell sx={{ fontWeight: 500 }}>{el.name}</TableCell>
21+
<TableCell>{el.value}</TableCell>
22+
</TableRow>
23+
))}
24+
</TableBody>
25+
</Table>
26+
);
27+
};

0 commit comments

Comments
 (0)