From 159563719f9e0e3ca15ad2248cb8ccbb2016c8d8 Mon Sep 17 00:00:00 2001 From: Markus Winter Date: Sun, 14 Jul 2024 15:43:35 +0200 Subject: [PATCH] modernize build time trend page - use jenkins-table - add time since column - make the link to the console an explicit icon (like for the agent history) - hide the agent column for pipeline jobs --- .../java/jenkins/widgets/BuildTimeTrend.java | 11 ++-- .../hudson/model/Job/buildTimeTrend.jelly | 47 +++++++++------- .../model/Job/buildTimeTrend_resources.css | 5 +- .../model/Job/buildTimeTrend_resources.js | 53 +++++++++++++------ .../resources/lib/hudson/buildListTable.jelly | 4 +- 5 files changed, 75 insertions(+), 45 deletions(-) diff --git a/core/src/main/java/jenkins/widgets/BuildTimeTrend.java b/core/src/main/java/jenkins/widgets/BuildTimeTrend.java index 59ab879f05daf..d3210893229d9 100644 --- a/core/src/main/java/jenkins/widgets/BuildTimeTrend.java +++ b/core/src/main/java/jenkins/widgets/BuildTimeTrend.java @@ -24,10 +24,7 @@ package jenkins.widgets; -import hudson.model.AbstractBuild; -import hudson.model.BallColor; -import hudson.model.Node; -import hudson.model.Run; +import hudson.model.*; import jenkins.console.ConsoleUrlProvider; import jenkins.model.Jenkins; import net.sf.json.JSONObject; @@ -37,6 +34,10 @@ @Restricted(DoNotUse.class) // only for buildTimeTrend.jelly public class BuildTimeTrend extends RunListProgressiveRendering { + public boolean isAbstractProject(Job job) { + return job instanceof AbstractProject; + } + @Override protected void calculate(Run build, JSONObject element) { BallColor iconColor = build.getIconColor(); element.put("iconName", iconColor.getIconName()); @@ -46,6 +47,8 @@ public class BuildTimeTrend extends RunListProgressiveRendering { element.put("displayName", build.getDisplayName()); element.put("duration", build.getDuration()); element.put("durationString", build.getDurationString()); + element.put("timestampString", build.getTimestampString()); + element.put("timestampString2", build.getTimestampString2()); element.put("consoleUrl", ConsoleUrlProvider.getRedirectUrl(build)); if (build instanceof AbstractBuild) { AbstractBuild b = (AbstractBuild) build; diff --git a/core/src/main/resources/hudson/model/Job/buildTimeTrend.jelly b/core/src/main/resources/hudson/model/Job/buildTimeTrend.jelly index 18f874a6751fd..3fbd69e74aa91 100644 --- a/core/src/main/resources/hudson/model/Job/buildTimeTrend.jelly +++ b/core/src/main/resources/hudson/model/Job/buildTimeTrend.jelly @@ -25,7 +25,7 @@ THE SOFTWARE. - + @@ -45,29 +45,36 @@ THE SOFTWARE. +

${%Build Time Trend}

-
+
+
+ + ${handler.setBuilds(it.builds)} + + + + + + + + + + + + + + + + + +
${%S}${%Build}${%Time Since}${%Duration}${%Agent}
+ +
[${%Build time graph}]
- - -
- - ${handler.setBuilds(it.builds)} - - - - - - - - - - -
${%Build}${%Duration}${%Agent}
-
diff --git a/core/src/main/resources/hudson/model/Job/buildTimeTrend_resources.css b/core/src/main/resources/hudson/model/Job/buildTimeTrend_resources.css index 13efe1c1e375e..09619fd860bb4 100644 --- a/core/src/main/resources/hudson/model/Job/buildTimeTrend_resources.css +++ b/core/src/main/resources/hudson/model/Job/buildTimeTrend_resources.css @@ -1,3 +1,4 @@ -img.build-time-graph { - float: right; +#buildTimeTrend { + display: flex; + column-gap: 5px; } diff --git a/core/src/main/resources/hudson/model/Job/buildTimeTrend_resources.js b/core/src/main/resources/hudson/model/Job/buildTimeTrend_resources.js index 8a6cbfd49253b..03cfda21cf758 100644 --- a/core/src/main/resources/hudson/model/Job/buildTimeTrend_resources.js +++ b/core/src/main/resources/hudson/model/Job/buildTimeTrend_resources.js @@ -2,24 +2,25 @@ * Public method to be called by progressiveRendering's callback */ window.buildTimeTrend_displayBuilds = function (data) { - var p = document.getElementById("trend"); - var isDistributedBuildsEnabled = - "true" === p.getAttribute("data-is-distributed-build-enabled"); - var rootURL = document.head.getAttribute("data-rooturl"); + const p = document.getElementById("trend"); + p.classList.remove("jenkins-hidden"); - for (var x = 0; data.length > x; x++) { - var e = data[x]; - var tr = document.createElement("tr"); + const showAgent = "true" === p.dataset.showAgent; + const rootURL = document.head.getAttribute("data-rooturl"); + + for (let x = 0; data.length > x; x++) { + const e = data[x]; + let tr = document.createElement("tr"); let td = document.createElement("td"); td.setAttribute("data", e.iconColorOrdinal); - - let link = document.createElement("a"); - link.classList.add("build-status-link"); - link.href = e.consoleUrl; - td.appendChild(link); + td.classList.add("jenkins-table__cell--tight", "jenkins-table__icon"); + let div = document.createElement("div"); + div.classList.add("jenkins-table__cell__button-wrapper"); let svg = generateSVGIcon(e.iconName); - link.appendChild(svg); + svg.setAttribute("tooltip", e.iconColorDescription); + div.appendChild(svg); + td.appendChild(div); tr.appendChild(td); td = document.createElement("td"); @@ -33,15 +34,20 @@ window.buildTimeTrend_displayBuilds = function (data) { td.appendChild(link); tr.appendChild(td); + td = document.createElement("td"); + td.setAttribute("data", e.timestampString2); + td.textContent = e.timestampString; + tr.appendChild(td); + td = document.createElement("td"); td.setAttribute("data", e.duration); td.innerText = escapeHTML(e.durationString); tr.appendChild(td); - if (isDistributedBuildsEnabled) { - var buildInfo = null; - var buildInfoStr = escapeHTML(e.builtOnStr || ""); + if (showAgent) { + let buildInfo = null; + let buildInfoStr = escapeHTML(e.builtOnStr || ""); if (e.builtOn) { buildInfo = document.createElement("a"); buildInfo.href = rootURL + "/computer/" + e.builtOn; @@ -58,6 +64,19 @@ window.buildTimeTrend_displayBuilds = function (data) { } tr.appendChild(td); } + + let tdConsole = document.createElement("td"); + tdConsole.classList.add("jenkins-table__cell--tight"); + let div2 = document.createElement("div"); + div2.classList.add("jenkins-table__cell__button-wrapper"); + link = document.createElement("a"); + link.classList.add("jenkins-button", "jenkins-button--tertiary"); + link.href = e.consoleUrl; + link.appendChild(generateSVGIcon("console")); + div2.appendChild(link); + tdConsole.appendChild(div2); + tr.appendChild(tdConsole) + p.appendChild(tr); Behaviour.applySubtree(tr); } @@ -132,7 +151,7 @@ window.displayBuilds = function (data) { var div2 = document.createElement("div"); div2.classList.add("jenkins-table__cell__button-wrapper"); var a3 = document.createElement("a"); - a3.classList.add("jenkins-button"); + a3.classList.add("jenkins-button", "jenkins-button--tertiary"); a3.href = e.consoleUrl; a3.innerHTML = p.dataset.consoleOutputIcon; div2.appendChild(a3); diff --git a/core/src/main/resources/lib/hudson/buildListTable.jelly b/core/src/main/resources/lib/hudson/buildListTable.jelly index c819964050cd6..a74202d4ab3d6 100644 --- a/core/src/main/resources/lib/hudson/buildListTable.jelly +++ b/core/src/main/resources/lib/hudson/buildListTable.jelly @@ -54,7 +54,7 @@ THE SOFTWARE. - + @@ -66,5 +66,5 @@ THE SOFTWARE. - +