提交 c4e0a8df 编写于 作者: K kohsuke

expanded the URL space so that jobs can be displayed under views. This puts...

expanded the URL space so that jobs can be displayed under views. This puts the view into the breadcrumb, allowing users to get back to the view more easily.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1687 71c3de6d-444a-0410-be80-ed276b4c234a
上级 77b52aaa
......@@ -270,4 +270,19 @@ public class Functions {
}
return false;
}
/**
* Finds the given object in the ancestor list and returns its URL.
* This is used to determine the "current" URL assigned to the given object,
* so that one can compute relative URLs from it.
*/
public static String getNearestAncestorUrl(StaplerRequest req,Object it) {
List list = req.getAncestors();
for( int i=list.size()-1; i>=0; i-- ) {
Ancestor anc = (Ancestor) list.get(i);
if(anc.getObject()==it)
return anc.getUrl();
}
return null;
}
}
......@@ -56,6 +56,10 @@ public class View extends JobCollection {
return Arrays.asList(jobs);
}
public Job getJob(String name) {
return owner.getJob(name);
}
public boolean containsJob(Job job) {
return jobNames.contains(job.getName());
}
......
......@@ -7,16 +7,17 @@
</l:header>
<l:side-panel>
<l:tasks>
<j:set var="url" value="${h.getNearestAncestorUrl(request,it)}"/>
<l:task icon="images/24x24/up.gif" href="${rootURL}/" title="Back to Dashboard" />
<l:task icon="images/24x24/search.gif" href="${rootURL}/${it.url}" title="Status" />
<l:task icon="images/24x24/notepad.gif" href="${rootURL}/${it.url}changes" title="Changes" />
<l:task icon="images/24x24/folder.gif" href="${rootURL}/${it.url}ws/" title="Workspace" />
<l:task icon="images/24x24/search.gif" href="${url}/" title="Status" />
<l:task icon="images/24x24/notepad.gif" href="${url}/changes" title="Changes" />
<l:task icon="images/24x24/folder.gif" href="${url}/ws/" title="Workspace" />
<l:isAdmin>
<j:if test="${!it.disabled}">
<l:task icon="images/24x24/clock.gif" href="${rootURL}/${it.url}build" title="Build Now" />
<l:task icon="images/24x24/clock.gif" href="${url}/build" title="Build Now" />
</j:if>
<l:task icon="images/24x24/edit-delete.gif" href="${rootURL}/${it.url}delete" title="Delete Project" />
<l:task icon="images/24x24/setting.gif" href="${rootURL}/${it.url}configure" title="Configure" />
<l:task icon="images/24x24/edit-delete.gif" href="${url}/delete" title="Delete Project" />
<l:task icon="images/24x24/setting.gif" href="${url}/configure" title="Configure" />
</l:isAdmin>
<st:include page="actions.jelly" />
</l:tasks>
......
......@@ -40,7 +40,7 @@
</p>
</j:when>
<j:otherwise>
<t:projectView jobs="${it.tiedJobs}" showViewTabs="false" />
<t:projectView jobs="${it.tiedJobs}" showViewTabs="false" jobBaseUrl="${rootURL}/" />
</j:otherwise>
</j:choose>
......
......@@ -13,7 +13,8 @@
<st:include page="noJob.jelly" />
</j:when>
<j:otherwise>
<t:projectView jobs="${it.jobs}" showViewTabs="true" />
<!-- set @jobBaseUrl="" so that links to jobs will be under this view. -->
<t:projectView jobs="${it.jobs}" showViewTabs="true" jobBaseUrl="" />
</j:otherwise>
</j:choose>
</l:main-panel>
......
<!--
<%@ attribute name="jobs" required="true" type="java.util.Collection" %>
<%@ attribute name="showViewTabs" required="true" type="java.lang.Boolean" %>
<%@ attribute name="jobBaseUrl" type="String" %>
The base URL of all job links. Normally ${rootURL}/
-->
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<t:setIconSize/>
......@@ -44,7 +47,7 @@
<img src="${rootURL}/images/${iconSize}/${job.buildStatusUrl}" />
</td>
<td>
<a href="${rootURL}/${job.url}">
<a href="${jobBaseUrl}${job.url}">
${job.name}
</a>
</td>
......@@ -52,7 +55,7 @@
<j:choose>
<j:when test="${lsBuild!=null}">
${lsBuild.timestampString}
(<a href="${rootURL}/${job.url}lastSuccessfulBuild/">#${lsBuild.number}</a>)
(<a href="${jobBaseUrl}${job.url}lastSuccessfulBuild/">#${lsBuild.number}</a>)
</j:when>
<j:otherwise>
N/A
......@@ -63,7 +66,7 @@
<j:choose>
<j:when test="${lfBuild!=null}">
${lfBuild.timestampString}
(<a href="${rootURL}/${job.url}lastFailedBuild/">#${lfBuild.number}</a>)
(<a href="${jobBaseUrl}${job.url}lastFailedBuild/">#${lfBuild.number}</a>)
</j:when>
<j:otherwise>
N/A
......@@ -89,7 +92,7 @@
<l:isAdmin>
<td>
<j:if test="${job.buildable}">
<a href="${rootURL}/${job.url}build">
<a href="${jobBaseUrl}${job.url}build">
<img src="${rootURL}/images/${subIconSize}/clock.gif" title="Schedule a build" border="0" /></a>
</j:if>
</td>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册