|
46 | 46 | import jenkins.security.stapler.StaplerNotDispatchable;
|
47 | 47 | import jenkins.util.MemoryReductionUtil;
|
48 | 48 | import jenkins.util.SystemProperties;
|
| 49 | +import org.jenkins.ui.symbol.Symbol; |
| 50 | +import org.jenkins.ui.symbol.SymbolRequest; |
49 | 51 | import org.kohsuke.accmod.Restricted;
|
50 | 52 | import org.kohsuke.accmod.restrictions.NoExternalUse;
|
51 | 53 | import org.kohsuke.stapler.Ancestor;
|
@@ -157,9 +159,16 @@ public void doSuggestOpenSearch(StaplerRequest2 req, StaplerResponse2 rsp, @Quer
|
157 | 159 | */
|
158 | 160 | public void doSuggest(StaplerRequest2 req, StaplerResponse2 rsp, @QueryParameter String query) throws IOException, ServletException {
|
159 | 161 | Result r = new Result();
|
160 |
| - for (SuggestedItem item : getSuggestions(req, query)) |
161 |
| - r.suggestions.add(new Item(item.getPath(), item.getUrl())); |
| 162 | + for (SuggestedItem item : getSuggestions(req, query)) { |
| 163 | + String symbolName = item.item.getSearchIcon(); |
162 | 164 |
|
| 165 | + if (symbolName == null || !symbolName.startsWith("symbol-")) { |
| 166 | + symbolName = "symbol-search"; |
| 167 | + } |
| 168 | + |
| 169 | + r.suggestions.add(new Item(item.getPath(), item.getUrl(), "", |
| 170 | + Symbol.get(new SymbolRequest.Builder().withRaw(symbolName).build()))); |
| 171 | + } |
163 | 172 | rsp.serveExposedBean(req, r, Flavor.JSON);
|
164 | 173 | }
|
165 | 174 |
|
@@ -259,19 +268,35 @@ public static class Item {
|
259 | 268 |
|
260 | 269 | private final String url;
|
261 | 270 |
|
| 271 | + public final String icon; |
| 272 | + |
| 273 | + public final String iconXml; |
| 274 | + |
262 | 275 | public Item(String name) {
|
263 |
| - this(name, null); |
| 276 | + this(name, null, null, null); |
264 | 277 | }
|
265 | 278 |
|
266 |
| - public Item(String name, String url) { |
| 279 | + public Item(String name, String url, String icon, String iconXml) { |
267 | 280 | this.name = name;
|
268 | 281 | this.url = url;
|
| 282 | + this.icon = icon; |
| 283 | + this.iconXml = iconXml; |
269 | 284 | }
|
270 | 285 |
|
271 | 286 | @Exported
|
272 | 287 | public String getUrl() {
|
273 | 288 | return url;
|
274 | 289 | }
|
| 290 | + |
| 291 | + @Exported |
| 292 | + public String getIcon() { |
| 293 | + return icon; |
| 294 | + } |
| 295 | + |
| 296 | + @Exported |
| 297 | + public String getIconXml() { |
| 298 | + return iconXml; |
| 299 | + } |
275 | 300 | }
|
276 | 301 |
|
277 | 302 | private enum Mode {
|
|
0 commit comments