Skip to content

Commit addd6b9

Browse files
authored
Update TrafficLight.jsx with Jenkins links (#1064)
* Update TrafficLight.jsx feat: Add Jenkins links to Perf Pipeline build selectors Adds a "Jenkins Link" next to the "test build" and "baseline build" dropdowns on the Performance Pipeline page. This provides a direct link to the selected build's Jenkins job, improving user workflow. I hope it works * Update TrafficLight.jsx Fixed the messy indentation and broken JSX structure. The Select components with Jenkins links should now have proper formatting and should work nicely with Prettier.
1 parent 92c2289 commit addd6b9

File tree

1 file changed

+40
-34
lines changed

1 file changed

+40
-34
lines changed

test-result-summary-client/src/TrafficLight/TrafficLight.jsx

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { fetchData, getInfoFromBuildName } from '../utils/Utils';
1212
import { params } from '../utils/query';
1313
import { Button } from '../Components/Button';
1414
import _, { first, identity, uniq } from 'lodash';
15-
1615
function TrafficLight() {
1716
const [topBuild, setTopBuild] = useState();
1817
const [topBuildOptions, setTopBuildOptions] = useState([]);
@@ -21,7 +20,6 @@ function TrafficLight() {
2120
const [buildOptions, setBuildOptions] = useState([]);
2221
const [tableData, settableData] = useState([]);
2322
const [metricsProps, setMetricsProps] = useState({});
24-
2523
const iconRed = (
2624
<CloseCircleOutlined
2725
style={{ color: 'rgb(255, 85, 0)', fontSize: 23 }}
@@ -40,11 +38,9 @@ function TrafficLight() {
4038
style={{ color: 'rgb(158, 158, 158)', fontSize: 23 }}
4139
/>
4240
);
43-
4441
useEffect(() => {
4542
fetchDataAndUpdate();
4643
}, []);
47-
4844
async function fetchDataAndUpdate() {
4945
const data = await fetchData(`/api/getTopLevelBuildNames?type=Perf`);
5046
if (data) {
@@ -55,7 +51,6 @@ function TrafficLight() {
5551
);
5652
}
5753
}
58-
5954
const handleCompare = async () => {
6055
let testData = await fetchData(
6156
`/api/getTrafficLightData?parentId=${testBuild}&buildType=test`
@@ -74,19 +69,16 @@ function TrafficLight() {
7469
`/api/getTrafficLightData?parentId=${baselineBuild}&buildType=test`
7570
);
7671
}
77-
7872
testData.forEach((element) => {
7973
element.buildType = 'test';
8074
});
8175
baselineData.forEach((element) => {
8276
element.buildType = 'baseline';
8377
});
84-
8578
const metricPropsJSON = await fetchData(`/api/getBenchmarkMetricProps`);
8679
if (metricPropsJSON) {
8780
setMetricsProps(metricPropsJSON);
8881
}
89-
9082
const modifiedData = [...testData, ...baselineData]
9183
.map(
9284
({
@@ -98,7 +90,6 @@ function TrafficLight() {
9890
const { benchmarkName, benchmarkVariant, buildName } =
9991
aggregateInfo;
10092
const benchmark = benchmarkName.split('-')[0];
101-
10293
const {
10394
jdkVersion,
10495
jdkImpl,
@@ -159,7 +150,6 @@ function TrafficLight() {
159150
})
160151
);
161152
};
162-
163153
const renderCell = (title, _, obj) => {
164154
const testBuild = Object.values(obj).find(
165155
({ buildNameTitle, buildType }) =>
@@ -184,20 +174,17 @@ function TrafficLight() {
184174
2
185175
);
186176
}
187-
188177
const testCI = Number(testValues.CI * 100).toFixed(2) + '%';
189178
const baselineCI = Number(baselineValues.CI * 100).toFixed(2) + '%';
190179
const totalCI =
191180
Number((testValues.CI + baselineValues.CI) * 100).toFixed(2) +
192181
'%';
193-
194182
let icon = iconRed;
195183
if (percentage > 98) {
196184
icon = iconGreen;
197185
} else if (percentage > 90) {
198186
icon = iconYellow;
199187
}
200-
201188
return (
202189
<Tooltip
203190
title={
@@ -261,13 +248,11 @@ function TrafficLight() {
261248
);
262249
}
263250
};
264-
265251
const firstRow = first(tableData) ?? {};
266252
const groups = Object.values(firstRow) ?? [];
267253
const buildNameTitles = uniq(
268254
groups.map(({ buildNameTitle }) => buildNameTitle).filter(identity)
269255
);
270-
271256
const columns = [
272257
{
273258
title: 'Benchmark Name',
@@ -303,7 +288,6 @@ function TrafficLight() {
303288
})
304289
);
305290
};
306-
307291
return (
308292
<Space direction="vertical" size="middle" style={{ display: 'flex' }}>
309293
<Select
@@ -315,24 +299,45 @@ function TrafficLight() {
315299
options={topBuildOptions}
316300
placeholder="please select the top level performance build"
317301
/>
318-
<Select
319-
style={{
320-
width: '100%',
321-
}}
322-
defaultValue={testBuild}
323-
onChange={setTestBuild}
324-
options={buildOptions}
325-
placeholder="please select test build"
326-
/>
327-
<Select
328-
style={{
329-
width: '100%',
330-
}}
331-
defaultValue={baselineBuild}
332-
onChange={setBaselineBuild}
333-
options={buildOptions}
334-
placeholder="please select baseline build"
335-
/>
302+
303+
<div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
304+
<Select
305+
style={{ width: '100%' }}
306+
defaultValue={testBuild}
307+
onChange={setTestBuild}
308+
options={buildOptions}
309+
placeholder="please select test build"
310+
/>
311+
{testBuild && (
312+
<a
313+
href={buildOptions.find(option => option.value === testBuild)?.label}
314+
target="_blank"
315+
rel="noopener noreferrer"
316+
>
317+
Jenkins Link
318+
</a>
319+
)}
320+
</div>
321+
322+
<div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
323+
<Select
324+
style={{ width: '100%' }}
325+
defaultValue={baselineBuild}
326+
onChange={setBaselineBuild}
327+
options={buildOptions}
328+
placeholder="please select baseline build"
329+
/>
330+
{baselineBuild && (
331+
<a
332+
href={buildOptions.find(option => option.value === baselineBuild)?.label}
333+
target="_blank"
334+
rel="noopener noreferrer"
335+
>
336+
Jenkins Link
337+
</a>
338+
)}
339+
</div>
340+
336341
<Space direction="horizontal">
337342
<Button type="primary" onClick={handleCompare}>
338343
Compare
@@ -362,4 +367,5 @@ function TrafficLight() {
362367
</Space>
363368
);
364369
}
370+
365371
export default TrafficLight;

0 commit comments

Comments
 (0)