Skip to content

Commit

Permalink
[JENKINS-60866][JENKINS-71797] Remove timeline widget (#6869)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Beck <daniel-beck@users.noreply.github.com>
Co-authored-by: Basil Crow <me@basilcrow.com>
Co-authored-by: Alexander Brandes <mc.cache@web.de>
  • Loading branch information
4 people authored Nov 5, 2023
1 parent d06f360 commit dd04e33
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 227 deletions.
5 changes: 0 additions & 5 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,6 @@ THE SOFTWARE.
<artifactId>stapler-adjunct-codemirror</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-adjunct-timeline</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-groovy</artifactId>
Expand Down
12 changes: 0 additions & 12 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,6 @@ THE SOFTWARE.
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-adjunct-codemirror</artifactId>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-adjunct-timeline</artifactId>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-groovy</artifactId>
Expand Down Expand Up @@ -495,14 +491,6 @@ THE SOFTWARE.
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!-- this helps us see the source code of the control while we edit Jenkins -->
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-adjunct-timeline</artifactId>
<version>1.5</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
34 changes: 13 additions & 21 deletions core/src/main/java/hudson/model/BuildTimelineWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@

package hudson.model;

import hudson.Util;
import hudson.util.RunList;
import java.io.IOException;
import java.util.Date;
import java.util.ArrayList;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.koshuke.stapler.simile.timeline.Event;
import org.koshuke.stapler.simile.timeline.TimelineEventList;

/**
* UI widget for showing the SIMILE timeline control.
Expand All @@ -41,7 +40,9 @@
*
* @author Kohsuke Kawaguchi
* @since 1.372
* @deprecated since TODO
*/
@Deprecated
public class BuildTimelineWidget {
protected final RunList<?> builds;

Expand All @@ -59,22 +60,13 @@ public BuildTimelineWidget(RunList<?> builds) {
return builds.getLastBuild();
}

public TimelineEventList doData(StaplerRequest req, @QueryParameter long min, @QueryParameter long max) throws IOException {
TimelineEventList result = new TimelineEventList();
for (Run<?, ?> r : builds.byTimestamp(min, max)) {
Event e = new Event();
e.start = new Date(r.getStartTimeInMillis());
e.end = new Date(r.getStartTimeInMillis() + r.getDuration());
// due to SimileAjax.HTML.deEntify (in simile-ajax-bundle.js), "&lt;" are transformed back to "<", but not the "&#60";
// to protect against XSS
e.title = Util.escape(r.getFullDisplayName()).replace("&lt;", "&#60;");
e.link = req.getContextPath() + '/' + r.getUrl();
BallColor c = r.getIconColor();
e.color = String.format("#%06X", c.getBaseColor().darker().getRGB() & 0xFFFFFF);
e.classname = "event-" + c.noAnime().toString() + " " + (c.isAnimated() ? "animated" : "");
result.add(e);
}
return result;
public HttpResponse doData(StaplerRequest req, @QueryParameter long min, @QueryParameter long max) {
return (req1, rsp, node) -> {
JSONObject o = new JSONObject();
o.put("events", JSONArray.fromObject(new ArrayList<>()));
rsp.setContentType("application/javascript;charset=UTF-8");
o.write(rsp.getWriter());
};

Check warning on line 69 in core/src/main/java/hudson/model/BuildTimelineWidget.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 64-69 are not covered by tests
}

}
2 changes: 2 additions & 0 deletions core/src/main/java/hudson/model/Computer.java
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,8 @@ public LoadStatistics getLoadStatistics() {
return LabelAtom.get(nodeName != null ? nodeName : Jenkins.get().getSelfLabel().toString()).loadStatistics;
}

@Deprecated
@Restricted(DoNotUse.class)
public BuildTimelineWidget getTimeline() {
return new BuildTimelineWidget(getBuilds());
}
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/hudson/model/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
import org.jfree.ui.RectangleInsets;
import org.jvnet.localizer.Localizable;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
Expand Down Expand Up @@ -1597,6 +1598,8 @@ public ACL getACL() {
return Jenkins.get().getAuthorizationStrategy().getACL(this);
}

@Deprecated
@Restricted(DoNotUse.class)
public BuildTimelineWidget getTimeline() {
return new BuildTimelineWidget(getBuilds());
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/hudson/model/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,8 @@ public RunList getBuilds() {
return new RunList(this);
}

@Deprecated
@Restricted(DoNotUse.class)
public BuildTimelineWidget getTimeline() {
return new BuildTimelineWidget(getBuilds());
}
Expand Down

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions core/src/main/resources/hudson/model/Computer/builds.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ THE SOFTWARE.
<em>${%disclaimer}</em>
</p>

<st:include page="control.jelly" it="${it.timeline}" />

<t:buildListTable builds="${it.builds}"/>
</l:main-panel>
</l:layout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ THE SOFTWARE.
<l:breadcrumb title="${%Build Time Trend}" />
<st:adjunct includes="hudson.model.Job.buildTimeTrend_resources" />
<l:main-panel>
<h1>${%Timeline}</h1>
<st:include page="control.jelly" it="${it.timeline}" />

<h1>${%Build Time Trend}</h1>
<div align="center">
<img class="build-time-graph" src="buildTimeGraph/png" width="500" height="400" lazymap="buildTimeGraph/map" alt="[${%Build time graph}]" />
Expand All @@ -44,7 +41,7 @@ THE SOFTWARE.
<j:new var="handler" className="jenkins.widgets.BuildTimeTrend"/>
${handler.setBuilds(it.builds)}
<l:progressiveRendering handler="${handler}" callback="buildTimeTrend_displayBuilds"/>
<table class="sortable" id="trend"
<table class="sortable" id="trend"
data-is-distributed-build-enabled="${isDistributedBuildEnabled}">
<tr>
<th><st:nbsp/></th>
Expand Down
1 change: 0 additions & 1 deletion core/src/main/resources/hudson/model/User/builds.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ THE SOFTWARE.
${%title(it)}
</h1>

<!-- TODO consider adding a BuildTimelineWidget (cf. Job, View, Computer) -->
<t:buildListTable builds="${it.builds}"/>
</l:main-panel>
</l:layout>
Expand Down
4 changes: 0 additions & 4 deletions core/src/main/resources/hudson/model/View/builds.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ THE SOFTWARE.
</div>
</div>

<j:if test="${!request.getParameter('suppressTimelineControl')}"> <!-- cf. BuildListTableTest; breaks HtmlUnit -->
<st:include page="control.jelly" it="${it.timeline}"/>
</j:if>

<t:buildListTable builds="${it.builds}"/>
</l:main-panel>
</l:layout>
Expand Down
4 changes: 2 additions & 2 deletions test/src/test/java/jenkins/widgets/BuildListTableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public class BuildListTableTest {
v2.add(p);
d.addView(v2);
JenkinsRule.WebClient wc = r.createWebClient();
HtmlPage page = wc.goTo("view/v1/job/d/view/v2/builds?suppressTimelineControl=true");
HtmlPage page = wc.goTo("view/v1/job/d/view/v2/builds");
assertEquals(0, wc.waitForBackgroundJavaScript(120000));
HtmlAnchor anchor = page.getAnchorByText("d » d2 » p");
String href = anchor.getHrefAttribute();
URL target = URI.create(page.getUrl().toExternalForm()).resolve(href).toURL();
wc.getPage(target);
assertEquals(href, r.getURL() + "view/v1/job/d/view/v2/job/d2/job/p/", target.toString());
page = wc.goTo("job/d/view/All/builds?suppressTimelineControl=true");
page = wc.goTo("job/d/view/All/builds");
assertEquals(0, wc.waitForBackgroundJavaScript(120000));
anchor = page.getAnchorByText("d » d2 » p");
href = anchor.getHrefAttribute();
Expand Down

0 comments on commit dd04e33

Please sign in to comment.