forked from jenkinsci/pipeline-graph-view-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSingleRun.tsx
More file actions
83 lines (71 loc) · 2.12 KB
/
SingleRun.tsx
File metadata and controls
83 lines (71 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import "./single-run.scss";
import { useContext } from "react";
import StatusIcon from "../../../common/components/status-icon.tsx";
import {
I18NContext,
LocalizedMessageKey,
} from "../../../common/i18n/index.ts";
import useRunPoller from "../../../common/tree-api.ts";
import { useUserPreferences } from "../../../common/user/user-preferences-provider.tsx";
import { time, Total } from "../../../common/utils/timings.tsx";
import { PipelineGraph } from "../../../pipeline-graph-view/pipeline-graph/main/PipelineGraph.tsx";
import {
defaultLayout,
LayoutInfo,
} from "../../../pipeline-graph-view/pipeline-graph/main/PipelineGraphModel.tsx";
import { RunInfo } from "./MultiPipelineGraphModel.ts";
export default function SingleRun({ run, currentJobPath }: SingleRunProps) {
const { run: runInfo } = useRunPoller({
currentRunPath: currentJobPath + run.id + "/",
});
function Changes() {
const messages = useContext(I18NContext);
if (run.changesCount === 0) {
return;
}
return (
<>
{" - "}
{messages.format(LocalizedMessageKey.changesSummary, {
0: run.changesCount,
})}
</>
);
}
const { showNames, showDurations } = useUserPreferences();
function getLayout() {
const layout: LayoutInfo = { ...defaultLayout };
if (!showNames && !showDurations) {
layout.nodeSpacingH = 45;
} else {
layout.nodeSpacingH = 90;
}
return layout;
}
function getCompactLayout() {
return !showNames && !showDurations ? "pgv-single-run--compact" : "";
}
return (
<div className={`pgv-single-run ${getCompactLayout()}`}>
<div>
<a href={currentJobPath + run.id} className="pgv-user-specified-text">
<StatusIcon status={run.result} />
{run.displayName}
<span>
{time(run.timestamp)} - <Total ms={run.duration} />
<Changes />
</span>
</a>
</div>
<PipelineGraph
stages={runInfo?.stages || []}
layout={getLayout()}
collapsed
/>
</div>
);
}
interface SingleRunProps {
run: RunInfo;
currentJobPath: string;
}