Skip to content

Commit b0bb280

Browse files
committed
excessive tooltip in queued builds
1 parent f067d46 commit b0bb280

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

core/src/main/java/hudson/model/Cause.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
import java.util.ArrayList;
3838
import java.util.Arrays;
3939
import java.util.HashSet;
40+
import java.util.LinkedHashMap;
4041
import java.util.List;
42+
import java.util.Map;
4143
import java.util.Objects;
4244
import java.util.Set;
4345
import jenkins.model.Jenkins;
@@ -166,7 +168,8 @@ public static class UpstreamCause extends Cause {
166168
*/
167169
@Deprecated
168170
private transient Cause upstreamCause;
169-
private @NonNull List<Cause> upstreamCauses;
171+
private transient @NonNull List<Cause> upstreamCauses;
172+
private @NonNull Map<Cause, Integer> causeBag = new LinkedHashMap<>();
170173

171174
/**
172175
* @deprecated since 2009-02-28
@@ -181,7 +184,6 @@ public UpstreamCause(Run<?, ?> up) {
181184
upstreamBuild = up.getNumber();
182185
upstreamProject = up.getParent().getFullName();
183186
upstreamUrl = up.getParent().getUrl();
184-
upstreamCauses = new ArrayList<>();
185187
Set<String> traversed = new HashSet<>();
186188
for (Cause c : up.getCauses()) {
187189
if (traversed.size() >= MAX_LEAF) {
@@ -192,11 +194,11 @@ public UpstreamCause(Run<?, ?> up) {
192194
}
193195
}
194196

195-
private UpstreamCause(String upstreamProject, int upstreamBuild, String upstreamUrl, @NonNull List<Cause> upstreamCauses) {
197+
private UpstreamCause(String upstreamProject, int upstreamBuild, String upstreamUrl, @NonNull Map<Cause, Integer> causeBag) {
196198
this.upstreamProject = upstreamProject;
197199
this.upstreamBuild = upstreamBuild;
198200
this.upstreamUrl = upstreamUrl;
199-
this.upstreamCauses = upstreamCauses;
201+
this.causeBag = causeBag;
200202
}
201203

202204
@Override
@@ -342,7 +344,10 @@ public static class ConverterImpl extends XStream2.PassthruConverter<UpstreamCau
342344

343345
@Override protected void callback(UpstreamCause uc, UnmarshallingContext context) {
344346
if (uc.upstreamCause != null) {
345-
uc.upstreamCauses.add(uc.upstreamCause);
347+
if (uc.causeBag == null) {
348+
uc.causeBag = new LinkedHashMap<>();
349+
}
350+
uc.causeBag.put(uc.upstreamCause, uc.causeBag.size());
346351
uc.upstreamCause = null;
347352
OldDataMonitor.report(context, "1.288");
348353
}

core/src/main/java/hudson/model/Queue.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2399,6 +2399,14 @@ public final List<Cause> getCauses() {
23992399
return Collections.emptyList();
24002400
}
24012401

2402+
@Restricted(DoNotUse.class) // used from Jelly
2403+
public final Map<Cause, Integer> getCauseCounts() {
2404+
CauseAction ca = getAction(CauseAction.class);
2405+
if (ca != null)
2406+
return ca.getCauseCounts();
2407+
return Collections.emptyMap();
2408+
}
2409+
24022410
@Restricted(DoNotUse.class) // used from Jelly
24032411
@Override
24042412
public String getCausesDescription() {

core/src/main/resources/lib/hudson/queue.jelly

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,13 @@ THE SOFTWARE.
7474
<j:set var="stuck" value="${item.isStuck()}"/>
7575
<j:choose>
7676
<j:when test="${h.hasPermission(item.task,item.task.READ)}">
77+
<j:set var="causeDescription">
78+
<j:forEach var="entry" items="${item.causeCounts.entrySet()}">${entry.key.shortDescription}<j:if test="${entry.value > 1}"><st:nbsp/>${%Ntimes(entry.value)}</j:if><br/>
79+
</j:forEach>${item.why} ${item.params}
80+
${%WaitingFor(item.inQueueForString)}
81+
</j:set>
7782
<a href="${rootURL}/${item.task.url}" class="model-link inside tl-tr"
78-
tooltip="${item.causesDescription} ${item.why} ${item.params} \n ${%WaitingFor(item.inQueueForString)}"
83+
data-html-tooltip="${causeDescription}"
7984
data-tooltip-append-to-parent="true">
8085
<l:breakable value="${item.displayName}"/>
8186
</a>

core/src/main/resources/lib/hudson/queue.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ Build\ Queue=Build Queue{0,choice,0#|0< ({0,number})}
22
Filtered\ Build\ Queue=Filtered Build Queue{0,choice,0#|0< ({0,number})}
33
WaitingFor=Waiting for {0}
44
confirm=Are you sure you want to cancel the queued run of {0}?
5+
Ntimes=({0} times)

0 commit comments

Comments
 (0)