Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
[FIXED JENKINS-29900] Use prefix "../../" for URLs in detail trend gr…
Browse files Browse the repository at this point in the history
…aph view.
  • Loading branch information
uhafner committed Sep 4, 2015
1 parent bfcc332 commit 77df032
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Expand Up @@ -15,7 +15,6 @@

import com.google.common.collect.Lists;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import jenkins.model.Jenkins;

import hudson.model.AbstractBuild;
Expand Down Expand Up @@ -182,7 +181,7 @@ public Object getTrendDetails() {
* @return the details
*/
public Object getTrendDetails(final StaplerRequest request, final StaplerResponse response) {
return new TrendDetails(getProject(), getTrendGraph(request, response));
return new TrendDetails(getProject(), getTrendGraph(request, response, "../../"));
}

/**
Expand All @@ -204,8 +203,13 @@ public Object getTrendGraph() {
* @return the trend graph
*/
public Graph getTrendGraph(final StaplerRequest request, final StaplerResponse response) {
return getTrendGraph(request, response, "");
}

private Graph getTrendGraph(final StaplerRequest request, final StaplerResponse response, final String urlPrefix) {
GraphConfigurationView configuration = createUserConfiguration(request);
if (configuration.hasMeaningfulGraph()) {
configuration.setUrlPrefix(urlPrefix);
return configuration.getGraphRenderer(getUrlName());
}
else {
Expand Down
Expand Up @@ -85,9 +85,7 @@ public boolean isVisible() {
* Sets the root URL to the specified value.
*
* @param rootUrl the value to set
* @deprecated as of 1.69 relative links are created
*/
@Deprecated
public void setRootUrl(final String rootUrl) {
this.rootUrl = rootUrl;
}
Expand Down
Expand Up @@ -8,7 +8,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

Expand All @@ -35,6 +35,7 @@ public abstract class GraphConfigurationView implements ModelObject {
private final BuildHistory buildHistory;
private final AbstractHealthDescriptor healthDescriptor; // NOPMD
private final GraphConfiguration configuration;
private String urlPrefix;

/**
* Creates a new instance of {@link GraphConfigurationView}.
Expand Down Expand Up @@ -349,7 +350,9 @@ public String getParameterValue() {
* @return the type
*/
public BuildResultGraph getGraphType() {
return configuration.getGraphType();
BuildResultGraph graphType = configuration.getGraphType();
graphType.setRootUrl(StringUtils.defaultString(urlPrefix));
return graphType;
}

/**
Expand Down Expand Up @@ -383,4 +386,15 @@ public String toString() {
public AbstractHealthDescriptor getHealthDescriptor() {
return healthDescriptor;
}

/**
* Sets the prefix of the URLs in the trend graph. Depending on the sub page this trend is shown a different
* prefix can be set for the relative URL.
*
* @param urlPrefix prefix, might be empty
* @since 1.73
*/
public void setUrlPrefix(final String urlPrefix) {
this.urlPrefix = urlPrefix;
}
}

0 comments on commit 77df032

Please sign in to comment.