From aef3cf3acfeb5c78c7da2c999e2babc1371ef212 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 19 Apr 2012 13:48:26 +0200 Subject: [PATCH] converting publishers to a drop-down menu to save real estate --- core/src/main/java/hudson/model/Project.java | 2 +- .../main/resources/lib/form/hetero-list.jelly | 12 ++++++-- .../hudson/project/config-publishers.jelly | 13 +++++++-- .../main/webapp/scripts/hudson-behavior.js | 28 ++++++++++++++++++- 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/hudson/model/Project.java b/core/src/main/java/hudson/model/Project.java index fd228a3521..fb63c2c837 100644 --- a/core/src/main/java/hudson/model/Project.java +++ b/core/src/main/java/hudson/model/Project.java @@ -195,7 +195,7 @@ public abstract class Project

,B extends Build> buildWrappers.rebuild(req,json, BuildWrappers.getFor(this)); builders.rebuildHetero(req,json, Builder.all(), "builder"); - publishers.rebuild(req, json, BuildStepDescriptor.filter(Publisher.all(), this.getClass())); + publishers.rebuildHetero(req, json, Publisher.all(), "publisher"); } @Override diff --git a/core/src/main/resources/lib/form/hetero-list.jelly b/core/src/main/resources/lib/form/hetero-list.jelly index 3325dc18d5..05f0a7ec8b 100644 --- a/core/src/main/resources/lib/form/hetero-list.jelly +++ b/core/src/main/resources/lib/form/hetero-list.jelly @@ -52,6 +52,12 @@ THE SOFTWARE. For each item, add a caption from descriptor.getDisplayName(). This also activates drag&drop (where the header is a grip), and help text support. + + If true, only allow up to one instance per descriptor. + + + Menu alignment against the button. Defaults to tl-bl + @@ -90,12 +96,12 @@ THE SOFTWARE. -

+
-
+
@@ -121,7 +127,7 @@ THE SOFTWARE.
- +
diff --git a/core/src/main/resources/lib/hudson/project/config-publishers.jelly b/core/src/main/resources/lib/hudson/project/config-publishers.jelly index ddbf60fc64..71905f083a 100644 --- a/core/src/main/resources/lib/hudson/project/config-publishers.jelly +++ b/core/src/main/resources/lib/hudson/project/config-publishers.jelly @@ -27,7 +27,14 @@ THE SOFTWARE. --> - + + + + + \ No newline at end of file diff --git a/war/src/main/webapp/scripts/hudson-behavior.js b/war/src/main/webapp/scripts/hudson-behavior.js index 98b945a4a9..3cf67c89be 100644 --- a/war/src/main/webapp/scripts/hudson-behavior.js +++ b/war/src/main/webapp/scripts/hudson-behavior.js @@ -510,6 +510,7 @@ var jenkinsRules = { // other behavior rules change them (like YUI buttons.) "DIV.hetero-list-container" : function(e) { + e=$(e); if(isInsideRemovable(e)) return; // components for the add button @@ -537,19 +538,27 @@ var jenkinsRules = { var withDragDrop = initContainerDD(e); - var menuButton = new YAHOO.widget.Button(btn, { type: "menu", menu: menu }); + var menuAlign = (btn.getAttribute("menualign")||"tl-bl").split("-"); + + var menuButton = new YAHOO.widget.Button(btn, { type: "menu", menu: menu, menualignment: menuAlign }); menuButton.getMenu().clickEvent.subscribe(function(type,args,value) { var t = templates[parseInt(args[1].value)]; // where this args[1] comes is a real mystery var nc = document.createElement("div"); nc.className = "repeated-chunk"; nc.setAttribute("name",t.name); + nc.setAttribute("descriptorId",t.descriptorId); nc.innerHTML = t.html; + $(nc).setOpacity(0); renderOnDemand(findElementsBySelector(nc,"TR.config-page")[0],function() { insertionPoint.parentNode.insertBefore(nc, insertionPoint); if(withDragDrop) prepareDD(nc); + new YAHOO.util.ColorAnim(nc, { + opacity: { to:1 } + }, 0.2, YAHOO.util.Easing.easeIn).animate(); + Behaviour.applySubtree(nc,true); },true); }); @@ -563,6 +572,23 @@ var jenkinsRules = { applyTooltip(items[i].element,t); } }); + + if (e.hasClassName("one-each")) { + // does this container already has a ocnfigured instance of the specified descriptor ID? + function has(id) { + return Prototype.Selector.find(e.childElements(),"DIV.repeated-chunk[descriptorId=\""+id+"\"]")!=null; + } + + menuButton.getMenu().showEvent.subscribe(function() { + var items = menuButton.getMenu().getItems(); + for(i=0; i