From 839d823773dbf4fab99c27d58f94ec7bbb898570 Mon Sep 17 00:00:00 2001
From: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date: Mon, 17 Jan 2022 23:50:07 +0000
Subject: [PATCH 1/7] Add suggestions by @timja
---
core/src/main/java/hudson/Functions.java | 7 +++++--
core/src/main/java/org/jenkins/ui/icon/IconSet.java | 1 +
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java
index 356ad918212f..822d79ab72b2 100644
--- a/core/src/main/java/hudson/Functions.java
+++ b/core/src/main/java/hudson/Functions.java
@@ -2291,6 +2291,7 @@ public static boolean isContextMenuVisible(Action a) {
}
}
+ @Restricted(NoExternalUse.class)
public static Icon tryGetIcon(String iconGuess) {
// Jenkins Symbols don't have metadata so return null
if (iconGuess == null || iconGuess.startsWith("symbol-")) {
@@ -2314,6 +2315,7 @@ public static Icon tryGetIcon(String iconGuess) {
return iconMetadata;
}
+ @Restricted(NoExternalUse.class)
public static String tryGetIconPath(String iconGuess, JellyContext context) {
if (iconGuess == null) {
return null;
@@ -2338,8 +2340,9 @@ public static String tryGetIconPath(String iconGuess, JellyContext context) {
}
if (iconMetadata != null && iconMetadata.getClassSpec() != null) {
- if (IconSet.tryTranslateTangoIconToSymbol(iconMetadata.getClassSpec()) != null) {
- return IconSet.tryTranslateTangoIconToSymbol(iconMetadata.getClassSpec());
+ String translatedIcon = IconSet.tryTranslateTangoIconToSymbol(iconMetadata.getClassSpec());
+ if (translatedIcon != null) {
+ return translatedIcon;
}
}
diff --git a/core/src/main/java/org/jenkins/ui/icon/IconSet.java b/core/src/main/java/org/jenkins/ui/icon/IconSet.java
index 9b30599563aa..21ae91c641cd 100644
--- a/core/src/main/java/org/jenkins/ui/icon/IconSet.java
+++ b/core/src/main/java/org/jenkins/ui/icon/IconSet.java
@@ -540,6 +540,7 @@ private static void initializeSVGs() {
* @param tangoIcon A tango icon in the format 'icon-* size-*', e.g. 'icon-gear icon-lg'
* @return a Jenkins Symbol (if one exists) otherwise null
*/
+ @Restricted(NoExternalUse.class)
public static String tryTranslateTangoIconToSymbol(String tangoIcon) {
if (tangoIcon != null) {
tangoIcon = tangoIcon.split(" ")[0];
From f476b728eed09e14d2189197c956033b5fe09a1e Mon Sep 17 00:00:00 2001
From: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date: Tue, 18 Jan 2022 00:05:16 +0000
Subject: [PATCH 2/7] Fix breadcrumbs icon missing/incorrect size
---
.../main/java/jenkins/model/ModelObjectWithContextMenu.java | 2 +-
war/src/main/less/base/yui-compatibility.less | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/core/src/main/java/jenkins/model/ModelObjectWithContextMenu.java b/core/src/main/java/jenkins/model/ModelObjectWithContextMenu.java
index b9c02b0cdb9a..6d066007e38b 100644
--- a/core/src/main/java/jenkins/model/ModelObjectWithContextMenu.java
+++ b/core/src/main/java/jenkins/model/ModelObjectWithContextMenu.java
@@ -283,7 +283,6 @@ class MenuItem {
/**
* Optional icon XML, if set it's used instead of @icon for the menu item
*/
- @Exported
private String iconXml;
/**
@@ -318,6 +317,7 @@ class MenuItem {
@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "read by Stapler")
public ContextMenu subMenu;
+ @Exported
public String getIconXml() {
return iconXml;
}
diff --git a/war/src/main/less/base/yui-compatibility.less b/war/src/main/less/base/yui-compatibility.less
index 7f8e97a1a5ff..7113297bf732 100644
--- a/war/src/main/less/base/yui-compatibility.less
+++ b/war/src/main/less/base/yui-compatibility.less
@@ -164,8 +164,8 @@ div.yahooTree td {
svg,
img {
- width: 1.2rem;
- height: 1.2rem;
+ width: 1.2rem !important;
+ height: 1.2rem !important;
margin: 0.25rem 0.5rem 0.25rem 0;
}
}
From f8a0ecef2bad1386378276a4b73b06fc0e1fbc84 Mon Sep 17 00:00:00 2001
From: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date: Tue, 18 Jan 2022 00:12:51 +0000
Subject: [PATCH 3/7] Potentially fix test
---
.../resources/hudson/model/View/AsynchPeople/index.jelly | 2 +-
.../hudson/model/View/AsynchPeople/people-resources.js | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/core/src/main/resources/hudson/model/View/AsynchPeople/index.jelly b/core/src/main/resources/hudson/model/View/AsynchPeople/index.jelly
index 9f531c9b5a1e..ef6d4bc68850 100644
--- a/core/src/main/resources/hudson/model/View/AsynchPeople/index.jelly
+++ b/core/src/main/resources/hudson/model/View/AsynchPeople/index.jelly
@@ -47,7 +47,7 @@ THE SOFTWARE.
-
+
|
diff --git a/core/src/main/resources/hudson/model/View/AsynchPeople/people-resources.js b/core/src/main/resources/hudson/model/View/AsynchPeople/people-resources.js
index 3a90ccf9d7eb..4c96eba51a04 100644
--- a/core/src/main/resources/hudson/model/View/AsynchPeople/people-resources.js
+++ b/core/src/main/resources/hudson/model/View/AsynchPeople/people-resources.js
@@ -1,5 +1,6 @@
function display(data) {
var p = document.getElementById('people');
+ p.show();
var rootURL = document.head.getAttribute('data-rooturl');
for (var x = 0; data.length > x; x++) {
var e = data[x];
@@ -19,7 +20,7 @@ function display(data) {
var wrapper = document.createElement('div');
wrapper.className = 'jenkins-table__cell__button-wrapper';
d.className = 'jenkins-table__cell--tight jenkins-table__icon';
- var icon = document.getElementById('person-circle-outline')
+ var icon = document.getElementById('person-circle')
wrapper.innerHTML = icon.children[0].outerHTML;
d.appendChild(wrapper);
r.appendChild(d);
@@ -55,4 +56,4 @@ function display(data) {
ts_refresh(p);
}
-}
\ No newline at end of file
+}
From 26ebfad4e7c90ce813434b3fa11ad1dc336ffbbf Mon Sep 17 00:00:00 2001
From: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date: Tue, 18 Jan 2022 00:21:26 +0000
Subject: [PATCH 4/7] Update Functions.java
---
core/src/main/java/hudson/Functions.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java
index 822d79ab72b2..c12fb3b8f017 100644
--- a/core/src/main/java/hudson/Functions.java
+++ b/core/src/main/java/hudson/Functions.java
@@ -2315,7 +2315,7 @@ public static Icon tryGetIcon(String iconGuess) {
return iconMetadata;
}
- @Restricted(NoExternalUse.class)
+ @Restricted(NoExternalUse.class)
public static String tryGetIconPath(String iconGuess, JellyContext context) {
if (iconGuess == null) {
return null;
From cc2a014204138453cdf4d65a9afc7da0c65f029d Mon Sep 17 00:00:00 2001
From: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date: Tue, 18 Jan 2022 00:39:26 +0000
Subject: [PATCH 5/7] Potential fix for plugins icons not showing
---
core/src/main/java/hudson/Functions.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java
index c12fb3b8f017..887587462ded 100644
--- a/core/src/main/java/hudson/Functions.java
+++ b/core/src/main/java/hudson/Functions.java
@@ -2336,7 +2336,7 @@ public static String tryGetIconPath(String iconGuess, JellyContext context) {
}
if (iconMetadata == null) {
- iconSource = rootURL + (iconGuess.startsWith("/images/") || iconGuess.startsWith("/plugin/") ? getResourcePath() : "") + getResourcePath() + iconGuess;
+ iconSource = rootURL + (iconGuess.startsWith("/images/") || iconGuess.startsWith("/plugin/") ? getResourcePath() : "") + iconGuess;
}
if (iconMetadata != null && iconMetadata.getClassSpec() != null) {
From f6de53916f5690e29f897bf62427b0cea4145225 Mon Sep 17 00:00:00 2001
From: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date: Tue, 18 Jan 2022 01:13:29 +0000
Subject: [PATCH 6/7] Fix missing slash in tests
---
core/src/main/java/hudson/Functions.java | 4 ++++
test/src/test/java/lib/layout/IconTest.java | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java
index 887587462ded..eb6075a10c9b 100644
--- a/core/src/main/java/hudson/Functions.java
+++ b/core/src/main/java/hudson/Functions.java
@@ -2336,6 +2336,10 @@ public static String tryGetIconPath(String iconGuess, JellyContext context) {
}
if (iconMetadata == null) {
+ if (!iconGuess.startsWith("/")) {
+ iconGuess = "/" + iconGuess;
+ }
+
iconSource = rootURL + (iconGuess.startsWith("/images/") || iconGuess.startsWith("/plugin/") ? getResourcePath() : "") + iconGuess;
}
diff --git a/test/src/test/java/lib/layout/IconTest.java b/test/src/test/java/lib/layout/IconTest.java
index 10b5cae4bb76..b39480fad29a 100644
--- a/test/src/test/java/lib/layout/IconTest.java
+++ b/test/src/test/java/lib/layout/IconTest.java
@@ -150,8 +150,8 @@ public void testTasks() throws Exception {
assertIconToImageOkay(taskDivs.get(4).getElementsByTagName("img").get(0), "/images/svgs/package.svg");
assertIconToSymbolOkay(taskDivs.get(5).getElementsByTagName("svg").get(0));
- assertIconToImageOkay(taskDivs.get(6).getElementsByTagName("img").get(0), "plugin/xxx/icon.png");
- assertIconToImageOkay(taskDivs.get(7).getElementsByTagName("img").get(0), "plugin/xxx/icon.png");
+ assertIconToImageOkay(taskDivs.get(6).getElementsByTagName("img").get(0), "/plugin/xxx/icon.png");
+ assertIconToImageOkay(taskDivs.get(7).getElementsByTagName("img").get(0), "/plugin/xxx/icon.png");
}
@TestExtension("testTasks")
From 0987321b93445148aa3ab68b604feab6be732bf3 Mon Sep 17 00:00:00 2001
From: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date: Tue, 18 Jan 2022 10:14:05 +0000
Subject: [PATCH 7/7] Restore icon requirement for tasks
---
core/src/main/resources/lib/layout/task.jelly | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/core/src/main/resources/lib/layout/task.jelly b/core/src/main/resources/lib/layout/task.jelly
index af4ad6a92e28..bba181408104 100644
--- a/core/src/main/resources/lib/layout/task.jelly
+++ b/core/src/main/resources/lib/layout/task.jelly
@@ -31,13 +31,13 @@ THE SOFTWARE.
Link target. Relative to the current page.
-
+
URL to an icon image, or the icon class specification. If using an image URL,
the image should be 24x24 in size and relative to the context path of Hudson.
Common values include:
- # "symbol-search" "symbol-terminal" "symbol-settings" - use a Jenkins Symbol as the icon for your task
+ # "symbol-search" / "symbol-terminal" / "symbol-settings" - use a Jenkins Symbol as the icon for your task
# "icon-folder icon-md" is an example of using a class spec for a medium folder icon
# "images/24x24/..." then points to the stock icon resources
# "plugin/foobar/abc/def.png" that points to "src/main/webapp/abc/def.png" in your plugin resources