From c4e0a8df91944f634d19bccba0d560ee6329c5c8 Mon Sep 17 00:00:00 2001
From: kohsuke
Date: Sun, 7 Jan 2007 21:00:49 +0000
Subject: [PATCH] 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
---
core/src/main/java/hudson/Functions.java | 15 +++++++++++++++
core/src/main/java/hudson/model/View.java | 4 ++++
.../hudson/model/AbstractProject/sidepanel.jelly | 13 +++++++------
.../resources/hudson/model/Computer/index.jelly | 2 +-
.../hudson/model/JobCollection/index.jelly | 3 ++-
.../main/resources/lib/hudson/projectView.jelly | 11 +++++++----
6 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java
index a0ce3a6536..aadecaa51c 100644
--- a/core/src/main/java/hudson/Functions.java
+++ b/core/src/main/java/hudson/Functions.java
@@ -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;
+ }
}
diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java
index a2655e9000..1e72ad29a5 100644
--- a/core/src/main/java/hudson/model/View.java
+++ b/core/src/main/java/hudson/model/View.java
@@ -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());
}
diff --git a/core/src/main/resources/hudson/model/AbstractProject/sidepanel.jelly b/core/src/main/resources/hudson/model/AbstractProject/sidepanel.jelly
index 82a24c1f4e..ca8c4af009 100644
--- a/core/src/main/resources/hudson/model/AbstractProject/sidepanel.jelly
+++ b/core/src/main/resources/hudson/model/AbstractProject/sidepanel.jelly
@@ -7,16 +7,17 @@
+
-
-
-
+
+
+
-
+
-
-
+
+
diff --git a/core/src/main/resources/hudson/model/Computer/index.jelly b/core/src/main/resources/hudson/model/Computer/index.jelly
index 5f9f40c297..ced95fd418 100644
--- a/core/src/main/resources/hudson/model/Computer/index.jelly
+++ b/core/src/main/resources/hudson/model/Computer/index.jelly
@@ -40,7 +40,7 @@
-
+
diff --git a/core/src/main/resources/hudson/model/JobCollection/index.jelly b/core/src/main/resources/hudson/model/JobCollection/index.jelly
index 4a8d115523..f7b39b1233 100644
--- a/core/src/main/resources/hudson/model/JobCollection/index.jelly
+++ b/core/src/main/resources/hudson/model/JobCollection/index.jelly
@@ -13,7 +13,8 @@
-
+
+
diff --git a/core/src/main/resources/lib/hudson/projectView.jelly b/core/src/main/resources/lib/hudson/projectView.jelly
index 2ea887a56a..973eecc395 100644
--- a/core/src/main/resources/lib/hudson/projectView.jelly
+++ b/core/src/main/resources/lib/hudson/projectView.jelly
@@ -1,6 +1,9 @@
@@ -44,7 +47,7 @@
-
+
${job.name}
|
@@ -52,7 +55,7 @@
${lsBuild.timestampString}
- (#${lsBuild.number})
+ (#${lsBuild.number})
N/A
@@ -63,7 +66,7 @@
${lfBuild.timestampString}
- (#${lfBuild.number})
+ (#${lfBuild.number})
N/A
@@ -89,7 +92,7 @@
-
+
|