Skip to content

Commit 87c53b9

Browse files
stuartroweStuart Rowe
and
Stuart Rowe
authored
Refresh the Console View Step Header Cards (#347)
Co-authored-by: Stuart Rowe <[email protected]>
1 parent ef989d1 commit 87c53b9

File tree

6 files changed

+193
-104
lines changed

6 files changed

+193
-104
lines changed

src/main/frontend/pipeline-console-view/pipeline-console/main/ConsoleLogCard.tsx

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
import React from "react";
22
import { lazy, Suspense } from "react";
33
import { styled } from "@mui/material/styles";
4-
import Card from "@mui/material/Card";
5-
import CardContent from "@mui/material/CardContent";
4+
import {
5+
Button,
6+
Card,
7+
CardContent,
8+
CircularProgress,
9+
Collapse,
10+
Grid,
11+
Typography,
12+
} from "@mui/material";
613
import CardActionArea from "@mui/material/CardActions";
7-
import { CircularProgress } from "@mui/material";
8-
import Collapse from "@mui/material/Collapse";
914
import IconButton, { IconButtonProps } from "@mui/material/IconButton";
10-
import Typography from "@mui/material/Typography";
1115
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
12-
import { StepInfo, StepLogBufferInfo } from "./PipelineConsoleModel";
13-
import Grid from "@mui/material/Grid";
14-
import Button from "@mui/material/Button";
16+
import LinkIcon from "@mui/icons-material/Link";
1517
import { Tooltip } from "react-tippy";
1618

17-
import { LOG_FETCH_SIZE } from "./PipelineConsoleModel";
18-
import LinkIcon from "@mui/icons-material/Link";
19+
import {
20+
LOG_FETCH_SIZE,
21+
StepInfo,
22+
StepLogBufferInfo,
23+
} from "./PipelineConsoleModel";
1924
import ConsoleLogModal from "./ConsoleLogModal";
2025
import ResizeIcon from "./ResizeIcon";
2126

27+
import { getStepStatus } from "../../../step-status/StepStatus";
28+
2229
const ConsoleLogStream = lazy(() => import("./ConsoleLogStream"));
2330

2431
interface ExpandMoreProps extends IconButtonProps {
@@ -127,10 +134,32 @@ export class ConsoleLogCard extends React.Component<
127134
return `${(size / gib).toFixed(2)}GiB`;
128135
}
129136

137+
getStepHeaderTitle(stepTitle: string, stepId: string) {
138+
if (stepTitle) {
139+
return (
140+
<Typography
141+
className="log-card--text"
142+
component="div"
143+
key={`step-duration-text-${stepId}`}
144+
>
145+
{stepTitle}
146+
</Typography>
147+
);
148+
} else {
149+
return null;
150+
}
151+
}
152+
130153
render() {
131154
const handleOpen = () => this.setState({ open: true });
132155
const handleClose = () => this.setState({ open: false });
133156

157+
const statusIcon = getStepStatus(
158+
this.props.step.state,
159+
this.props.step.completePercent,
160+
10
161+
);
162+
134163
return (
135164
<Card
136165
className="step-detail-group"
@@ -145,6 +174,7 @@ export class ConsoleLogCard extends React.Component<
145174
}`}
146175
key={`step-action-area-${this.props.step.id}`}
147176
>
177+
{statusIcon}
148178
<Grid
149179
container
150180
wrap="nowrap"
@@ -165,22 +195,12 @@ export class ConsoleLogCard extends React.Component<
165195
key={`step-name-text-${this.props.step.id}`}
166196
sx={{ flexGrow: 3 }}
167197
>
168-
{this.props.step.name
169-
.substring(0, this.props.step.name.lastIndexOf("-"))
170-
.trimEnd()}
171-
</Typography>
172-
<Typography
173-
className="log-card--text"
174-
component="div"
175-
key={`step-duration-text-${this.props.step.id}`}
176-
>
177-
{this.props.step.name
178-
.substring(
179-
this.props.step.name.lastIndexOf("-") + 1,
180-
this.props.step.name.length
181-
)
182-
.trimStart()}
198+
{this.props.step.name}
183199
</Typography>
200+
{this.getStepHeaderTitle(
201+
this.props.step.title,
202+
this.props.step.id
203+
)}
184204
</Grid>
185205
<Grid
186206
item
@@ -202,13 +222,15 @@ export class ConsoleLogCard extends React.Component<
202222
</Typography>
203223
</Grid>
204224

205-
<Grid item xs={1} alignItems="center" sx={{ margin: "auto" }}>
225+
<Grid item xs={2} alignItems="center" sx={{ margin: "auto" }}>
206226
<Tooltip title="Open console log in full-screen mode">
207227
<IconButton
208228
aria-label={"Open console log in full-screen mode"}
209229
onClick={handleOpen}
210230
>
211-
<ResizeIcon />
231+
<div className="svg-icon--expand">
232+
<ResizeIcon />
233+
</div>
212234
</IconButton>
213235
</Tooltip>
214236
<Tooltip title="View step as plain text">
@@ -218,11 +240,11 @@ export class ConsoleLogCard extends React.Component<
218240
}
219241
aria-label="View step as plain text"
220242
>
221-
<LinkIcon />
243+
<LinkIcon className="svg-icon--expand" />
222244
</IconButton>
223245
</Tooltip>
224246
</Grid>
225-
<Grid item xs={2} alignItems="center" sx={{ margin: "auto" }}>
247+
<Grid item xs={1} alignItems="center" sx={{ margin: "auto" }}>
226248
<Tooltip title="Open console log">
227249
<ExpandMore
228250
expand={this.props.isExpanded}

src/main/frontend/pipeline-console-view/pipeline-console/main/ConsoleLogModal.tsx

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React from "react";
22
import { StepInfo, StepLogBufferInfo } from "./PipelineConsoleModel";
3+
import { getStepStatus } from "../../../step-status/StepStatus";
34
import CloseIcon from "./CloseIcon";
45

5-
import Button from "@mui/material/Button";
6-
76
export interface ConsoleLogModelProps {
87
logBuffer: StepLogBufferInfo;
98
handleMoreConsoleClick: (nodeId: string, startByte: number) => void;
@@ -13,7 +12,7 @@ export interface ConsoleLogModelProps {
1312
open: boolean;
1413
}
1514

16-
import { Box, Modal } from "@mui/material";
15+
import { Box, Modal, Stack } from "@mui/material";
1716
import Typography from "@mui/material/Typography";
1817
import ConsoleLogStream from "./ConsoleLogStream";
1918

@@ -36,6 +35,13 @@ const style = {
3635

3736
export default function ConsoleLogModal(props: ConsoleLogModelProps) {
3837
const handleClose = () => props.setClose();
38+
const statusIcon = getStepStatus(
39+
props.step.state,
40+
props.step.completePercent,
41+
10
42+
);
43+
const stepDisplayName = props.step.name;
44+
const stepTitle = props.step.title ? " - " + props.step.title : "";
3945

4046
return (
4147
<>
@@ -54,25 +60,17 @@ export default function ConsoleLogModal(props: ConsoleLogModelProps) {
5460
noWrap={true}
5561
key={`step-name-text-${props.step.id}`}
5662
>
57-
{props.step.name
58-
.substring(0, props.step.name.lastIndexOf("-"))
59-
.trimEnd()}
63+
<Stack direction="row" alignItems="center" spacing={1}>
64+
{statusIcon}
65+
<Box component="span">
66+
<Box component="span" fontWeight="bold">
67+
{stepDisplayName}
68+
</Box>
69+
{stepTitle}
70+
</Box>
71+
</Stack>
6072
</Typography>
6173
<CloseIcon onClick={handleClose} />
62-
<Typography
63-
className="log-card--text"
64-
id="modal-modal-description"
65-
sx={{ mt: 2, mb: 2 }}
66-
key={`step-duration-text-${props.step.id}`}
67-
>
68-
{props.step.name
69-
.substring(
70-
props.step.name.lastIndexOf("-") + 1,
71-
props.step.name.length
72-
)
73-
.trimStart()}
74-
</Typography>
75-
7674
<ConsoleLogStream {...props} />
7775
</Box>
7876
</Modal>

src/main/frontend/pipeline-console-view/pipeline-console/main/pipeline-console.scss

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
:root {
44
--card-background: hsl(212, 30%, 96%);
5-
--step-bg-running: var(--accent-color);
6-
--step-bg-success: var(--success-color);
7-
--step-bg-unstable: var(--warning-color);
8-
--step-bg-failure: var(--error-color);
9-
--step-bg-aborted: var(--purple);
10-
--step-bg-paused: var(--blue);
11-
--step-text-color: rgb(233, 237, 237);
5+
--step-bg-running: color-mix(in srgb, var(--accent-color) 50%, white);
6+
--step-bg-success: color-mix(in srgb, var(--success-color) 50%, white);
7+
--step-bg-unstable: color-mix(in srgb, var(--warning-color) 50%, white);
8+
--step-bg-failure: color-mix(in srgb, var(--error-color) 50%, white);
9+
--step-bg-aborted: color-mix(in srgb, var(--purple) 50%, white);
10+
--step-bg-paused: color-mix(in srgb, var(--blue) 50%, white);
11+
--step-text-color: var(--text-color);
1212
}
1313

1414
.app-page-body--one-column {
@@ -17,14 +17,25 @@
1717

1818
[data-theme="dark"] {
1919
--card-background: hsl(230deg 14% 23%);
20-
--step-text-color: hsl(230deg 14% 23%);
20+
--step-bg-running: color-mix(in srgb, var(--accent-color) 50%, black);
21+
--step-bg-success: color-mix(in srgb, var(--success-color) 50%, black);
22+
--step-bg-unstable: color-mix(in srgb, var(--warning-color) 50%, black);
23+
--step-bg-failure: color-mix(in srgb, var(--error-color) 50%, black);
24+
--step-bg-aborted: color-mix(in srgb, var(--purple) 50%, black);
25+
--step-bg-paused: color-mix(in srgb, var(--blue) 50%, black);
2126
}
2227

2328
@media (prefers-color-scheme: dark) {
2429
[data-theme="dark-system"],
2530
[data-theme="dark-system"] {
2631
--card-background: hsl(230deg 14% 23%);
27-
--step-text-color: hsl(230deg 14% 23%);
32+
//--step-text-color: hsl(230deg 14% 23%);
33+
--step-bg-running: color-mix(in srgb, var(--accent-color) 50%, black);
34+
--step-bg-success: color-mix(in srgb, var(--success-color) 50%, black);
35+
--step-bg-unstable: color-mix(in srgb, var(--warning-color) 50%, black);
36+
--step-bg-failure: color-mix(in srgb, var(--error-color) 50%, black);
37+
--step-bg-aborted: color-mix(in srgb, var(--purple) 50%, black);
38+
--step-bg-paused: color-mix(in srgb, var(--blue) 50%, black);
2839
}
2940
}
3041

@@ -222,6 +233,14 @@ g.build-status-icon__outer {
222233
color: var(--step-text-color);
223234
}
224235

236+
.svg-icon--link {
237+
color: var(--step-text-color);
238+
}
239+
240+
.svg-icon--resize {
241+
color: var(--step-text-color);
242+
}
243+
225244
.svg-icon--step-card-status {
226245
color: var(--step-text-color) !important;
227246
}

src/main/frontend/step-status/StepStatus.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ const Component: FunctionComponent<Props> = (props: Props) => {
2424
);
2525
};
2626

27-
function getStepStatus(status: Result, complete?: number, radius?: number) {
27+
export function getStepStatus(
28+
status: Result,
29+
complete?: number,
30+
radius?: number
31+
) {
2832
const icon = getGroupForResult(
2933
decodeResultValue(status),
3034
complete ?? 100,

src/main/java/io/jenkins/plugins/pipelinegraphview/utils/PipelineStepApi.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,22 @@ private List<PipelineStep> parseSteps(List<FlowNodeWrapper> stepNodes, String st
2828
if (flowNodeWrapper.getStatus().getState() != BlueRun.BlueRunState.FINISHED) {
2929
state = flowNodeWrapper.getStatus().getState().name().toLowerCase(Locale.ROOT);
3030
}
31-
String displayName = flowNodeWrapper.getDisplayName();
3231

32+
String displayName = flowNodeWrapper.getDisplayName();
33+
String title = "";
3334
if (flowNodeWrapper.getType() == FlowNodeWrapper.NodeType.UNHANDLED_EXCEPTION) {
3435
displayName = "Pipeline error";
3536
} else {
3637
String stepArguments = flowNodeWrapper.getArgumentsAsString();
3738
if (stepArguments != null && !stepArguments.isEmpty()) {
38-
displayName = stepArguments + " - " + displayName;
39+
displayName = stepArguments;
40+
title = flowNodeWrapper.getDisplayName();
3941
}
4042
// Use the step label as the displayName if set
4143
String labelDisplayName = flowNodeWrapper.getLabelDisplayName();
4244
if (labelDisplayName != null && !labelDisplayName.isEmpty()) {
4345
displayName = labelDisplayName;
46+
title = "";
4447
}
4548
}
4649
// Remove non-printable chars (e.g. ANSI color codes).
@@ -54,7 +57,7 @@ private List<PipelineStep> parseSteps(List<FlowNodeWrapper> stepNodes, String st
5457
state,
5558
50, // TODO how ???
5659
flowNodeWrapper.getType().name(),
57-
flowNodeWrapper.getDisplayName(), // TODO blue ocean uses timing information: "Passed in
60+
title, // TODO blue ocean uses timing information: "Passed in
5861
// 0s"
5962
stageId,
6063
"Queued "

0 commit comments

Comments
 (0)