未验证 提交 9bb02ecf 编写于 作者: T Tim Jacomb 提交者: GitHub

Merge pull request #4586 from daniel-beck/manage-context-menu-titles

Add section titles to Manage Jenkins context menu
...@@ -14,6 +14,8 @@ import org.apache.commons.jelly.JellyException; ...@@ -14,6 +14,8 @@ import org.apache.commons.jelly.JellyException;
import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.Script; import org.apache.commons.jelly.Script;
import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.XMLOutput;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;
import org.kohsuke.stapler.HttpResponse; import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.Stapler; import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerRequest;
...@@ -128,6 +130,18 @@ public interface ModelObjectWithContextMenu extends ModelObject { ...@@ -128,6 +130,18 @@ public interface ModelObjectWithContextMenu extends ModelObject {
return this; return this;
} }
/**
* Add a header row (no icon, no URL, rendered in header style).
*
* @since TODO
*/
@Restricted(DoNotUse.class) // manage.jelly only
public ContextMenu addHeader(String title) {
final MenuItem item = new MenuItem().withDisplayName(title);
item.header = true;
return add(item);
}
/** /**
* Adds a manually constructed {@link MenuItem} * Adds a manually constructed {@link MenuItem}
* *
...@@ -259,6 +273,13 @@ public interface ModelObjectWithContextMenu extends ModelObject { ...@@ -259,6 +273,13 @@ public interface ModelObjectWithContextMenu extends ModelObject {
*/ */
@Exported public boolean requiresConfirmation; @Exported public boolean requiresConfirmation;
/**
* True to display this item as a section header.
* @since TODO
*/
@Exported public boolean header;
/** /**
* If this is a submenu, definition of subitems. * If this is a submenu, definition of subitems.
*/ */
......
...@@ -49,7 +49,7 @@ THE SOFTWARE. ...@@ -49,7 +49,7 @@ THE SOFTWARE.
<j:forEach var="category" items="${it.categorizedManagementLinks.entrySet()}"> <j:forEach var="category" items="${it.categorizedManagementLinks.entrySet()}">
<section class="manage-page__category"> <section class="manage-page__category">
<h2>${category.key.label}</h2> <h2>${category.key.label}</h2>
${taskTags!=null and attrs.contextMenu!='false' ? taskTags.addHeader(category.key.label) : null}
<div class="manage-page__row"> <div class="manage-page__row">
<j:forEach var="m" items="${category.value}"> <j:forEach var="m" items="${category.value}">
<j:set var="icon" value="${m.iconClassName != null ? m.iconClassName : m.iconFileName}" /> <j:set var="icon" value="${m.iconClassName != null ? m.iconClassName : m.iconFileName}" />
......
...@@ -126,3 +126,8 @@ ...@@ -126,3 +126,8 @@
A.model-link.inside, #breadcrumbs A.inside {/* additional 'inside' class allows pre-allocation of the context menu space */ A.model-link.inside, #breadcrumbs A.inside {/* additional 'inside' class allows pre-allocation of the context menu space */
padding-right: 16px; padding-right: 16px;
} }
#breadcrumb-menu .header {
font-weight: bold;
font-size: 0.875rem;
}
...@@ -203,7 +203,11 @@ var breadcrumbs = (function() { ...@@ -203,7 +203,11 @@ var breadcrumbs = (function() {
onComplete:function (x) { onComplete:function (x) {
var a = x.responseText.evalJSON().items; var a = x.responseText.evalJSON().items;
function fillMenuItem(e) { function fillMenuItem(e) {
e.text = makeMenuHtml(e.icon, e.displayName); if (e.header) {
e.text = makeMenuHtml(e.icon, "<span class='header'>" + e.displayName + "</span>");
} else {
e.text = makeMenuHtml(e.icon, e.displayName);
}
if (e.subMenu!=null) if (e.subMenu!=null)
e.subMenu = {id:"submenu"+(iota++), itemdata:e.subMenu.items.each(fillMenuItem)}; e.subMenu = {id:"submenu"+(iota++), itemdata:e.subMenu.items.each(fillMenuItem)};
if (e.requiresConfirmation) { if (e.requiresConfirmation) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册