Skip to content

Commit

Permalink
Cleanup + fix menu
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Jan 15, 2022
1 parent c2e47cb commit d8169ad
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
13 changes: 1 addition & 12 deletions core/src/main/java/hudson/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -2322,18 +2322,7 @@ public static String tryGetIconPath(String iconGuess, JellyContext context) {
StaplerRequest currentRequest = Stapler.getCurrentRequest();
currentRequest.getWebApp().getDispatchValidator().allowDispatch(currentRequest, Stapler.getCurrentResponse());
String rootURL = currentRequest.getContextPath();
Icon iconMetadata = IconSet.icons.getIconByClassSpec(iconGuess);

if (iconMetadata == null) {
// Icon could be provided as a simple iconFileName e.g. "settings.png"
iconMetadata = IconSet.icons.getIconByClassSpec(IconSet.toNormalizedIconNameClass(iconGuess) + " icon-md");
}

if (iconMetadata == null) {
// Icon could be provided as an absolute iconFileName e.g. "/plugin/foo/abc.png"
iconMetadata = IconSet.icons.getIconByUrl(iconGuess);
}

Icon iconMetadata = tryGetIcon(iconGuess, context);
String iconSource = null;

if (iconMetadata != null) {
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/org/jenkins/ui/icon/IconType.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

package org.jenkins.ui.icon;

import jnr.ffi.annotations.Out;

/**
* Icon type.
*
Expand Down
13 changes: 9 additions & 4 deletions core/src/main/resources/lib/layout/breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ var breadcrumbs = (function() {
var logger = function() {};
// logger = function() { console.log.apply(console,arguments) }; // uncomment this line to enable logging

function makeMenuHtml(icon,displayName) {
function makeMenuHtml(icon, iconXml, displayName) {
var displaynameSpan = '<span>' + displayName + '</span>';

if (iconXml != null) {
return iconXml + displaynameSpan;
}

if (icon === null) return "<span style='margin: 2px 4px 2px 2px;' />" + displaynameSpan;

// TODO: move this to the API response in a clean way
Expand Down Expand Up @@ -213,9 +218,9 @@ var breadcrumbs = (function() {
var a = x.responseText.evalJSON().items;
function fillMenuItem(e) {
if (e.header) {
e.text = makeMenuHtml(e.icon, "<span class='header'>" + e.displayName + "</span>");
e.text = makeMenuHtml(e.icon, e.iconXml, "<span class='header'>" + e.displayName + "</span>");
} else {
e.text = makeMenuHtml(e.icon, e.displayName);
e.text = makeMenuHtml(e.icon, e.iconXml, e.displayName);
}
if (e.subMenu!=null)
e.subMenu = {id:"submenu"+(iota++), itemdata:e.subMenu.items.each(fillMenuItem)};
Expand Down Expand Up @@ -287,7 +292,7 @@ var breadcrumbs = (function() {
* @return {breadcrumbs.MenuItem}
*/
"add" : function (url,icon,displayName) {
this.items.push({ url:url, text:makeMenuHtml(icon,displayName) });
this.items.push({ url:url, text:makeMenuHtml(icon, null, displayName) });
return this;
}
};
Expand Down
7 changes: 7 additions & 0 deletions war/src/main/less/base/yui-compatibility.less
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ div.yahooTree td {
#jenkins .yuimenuitem {
font-size: var(--font-size-xs);
padding: 3px;

svg,
img {
width: 1.2rem;
height: 1.2rem;
margin: 0.25rem 0.5rem 0.25rem 0;
}
}

#jenkins .yuimenuitem,
Expand Down

0 comments on commit d8169ad

Please sign in to comment.