提交 73f3ae70 编写于 作者: K kohsuke

fixed "up" link


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@7482 71c3de6d-444a-0410-be80-ed276b4c234a
上级 9ea0c1b7
...@@ -274,7 +274,7 @@ ...@@ -274,7 +274,7 @@
<dependency> <dependency>
<groupId>org.kohsuke.stapler</groupId> <groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler</artifactId> <artifactId>stapler</artifactId>
<version>1.62</version> <version>1.63</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.kohsuke</groupId> <groupId>org.kohsuke</groupId>
......
...@@ -31,6 +31,20 @@ public class MatrixRun extends Build<MatrixConfiguration,MatrixRun> { ...@@ -31,6 +31,20 @@ public class MatrixRun extends Build<MatrixConfiguration,MatrixRun> {
super(project, buildDir); super(project, buildDir);
} }
public String getUpUrl() {
StaplerRequest req = Stapler.getCurrentRequest();
if(req!=null) {
List<Ancestor> ancs = req.getAncestors();
for( int i=1; i<ancs.size(); i++) {
if(ancs.get(i).getObject()==this) {
if(ancs.get(i-1).getObject() instanceof MatrixBuild) {
return ancs.get(i-1).getUrl()+'/';
}
}
}
}
return super.getDisplayName();
}
public String getDisplayName() { public String getDisplayName() {
StaplerRequest req = Stapler.getCurrentRequest(); StaplerRequest req = Stapler.getCurrentRequest();
......
...@@ -71,6 +71,23 @@ public class MavenBuild extends AbstractBuild<MavenModule,MavenBuild> { ...@@ -71,6 +71,23 @@ public class MavenBuild extends AbstractBuild<MavenModule,MavenBuild> {
super(project, buildDir); super(project, buildDir);
} }
@Override
public String getUpUrl() {
StaplerRequest req = Stapler.getCurrentRequest();
if(req!=null) {
List<Ancestor> ancs = req.getAncestors();
for( int i=1; i<ancs.size(); i++) {
if(ancs.get(i).getObject()==this) {
if(ancs.get(i-1).getObject() instanceof MavenModuleSetBuild) {
// if under MavenModuleSetBuild, "up" means MMSB
return ancs.get(i-1).getUrl()+'/';
}
}
}
}
return super.getUpUrl();
}
@Override @Override
public String getDisplayName() { public String getDisplayName() {
StaplerRequest req = Stapler.getCurrentRequest(); StaplerRequest req = Stapler.getCurrentRequest();
......
...@@ -3,7 +3,9 @@ package hudson.model; ...@@ -3,7 +3,9 @@ package hudson.model;
import hudson.Launcher; import hudson.Launcher;
import hudson.Proc.LocalProc; import hudson.Proc.LocalProc;
import hudson.Util; import hudson.Util;
import hudson.Functions;
import hudson.matrix.MatrixConfiguration; import hudson.matrix.MatrixConfiguration;
import hudson.matrix.MatrixRun;
import hudson.maven.MavenBuild; import hudson.maven.MavenBuild;
import hudson.model.Fingerprint.BuildPtr; import hudson.model.Fingerprint.BuildPtr;
import hudson.model.Fingerprint.RangeSet; import hudson.model.Fingerprint.RangeSet;
...@@ -23,6 +25,7 @@ import hudson.util.AdaptedIterator; ...@@ -23,6 +25,7 @@ import hudson.util.AdaptedIterator;
import hudson.util.Iterators; import hudson.util.Iterators;
import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse; import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.export.Exported;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
...@@ -42,6 +45,8 @@ import java.util.List; ...@@ -42,6 +45,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import sun.misc.Request;
/** /**
* Base implementation of {@link Run}s that build software. * Base implementation of {@link Run}s that build software.
* *
...@@ -123,6 +128,22 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs ...@@ -123,6 +128,22 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
return builtOn; return builtOn;
} }
/**
* Used to render the side panel "Back to project" link.
*
* <p>
* In a rare situation where a build can be reached from multiple paths,
* returning different URLs from this method based on situations might
* be desirable.
*
* <p>
* If you override this method, you'll most likely also want to override
* {@link #getDisplayName()}.
*/
public String getUpUrl() {
return Functions.getNearestAncestorUrl(Stapler.getCurrentRequest(),getParent())+'/';
}
/** /**
* List of users who committed a change since the last non-broken build till now. * List of users who committed a change since the last non-broken build till now.
* *
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<l:side-panel> <l:side-panel>
<l:tasks> <l:tasks>
<j:set var="buildUrl" value="${h.decompose(request)}" /> <j:set var="buildUrl" value="${h.decompose(request)}" />
<l:task icon="images/24x24/up.gif" href="${h.getNearestAncestorUrl(request,it.parent)}/" title="${%Back to Project}" /> <l:task icon="images/24x24/up.gif" href="${it.upUrl}" title="${%Back to Project}" />
<l:task icon="images/24x24/search.gif" href="${buildUrl.baseUrl}/" title="${%Status}" /> <l:task icon="images/24x24/search.gif" href="${buildUrl.baseUrl}/" title="${%Status}" />
<l:task icon="images/24x24/notepad.gif" href="${buildUrl.baseUrl}/changes" title="${%Changes}" /> <l:task icon="images/24x24/notepad.gif" href="${buildUrl.baseUrl}/changes" title="${%Changes}" />
<j:choose> <j:choose>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册