Skip to content

Commit

Permalink
Add group field
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Dec 11, 2024
1 parent 80f24cb commit 3d45ca7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
6 changes: 6 additions & 0 deletions core/src/main/java/hudson/model/Computer.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import hudson.node_monitors.NodeMonitor;
import hudson.remoting.Channel;
import hudson.remoting.VirtualChannel;
import hudson.search.SearchGroup;
import hudson.security.ACL;
import hudson.security.AccessControlled;
import hudson.security.Permission;
Expand Down Expand Up @@ -1109,6 +1110,11 @@ public String getSearchUrl() {
return getUrl();
}

@Override
public SearchGroup getSearchGroup() {
return SearchGroup.COMPUTER;
}

/**
* {@link RetentionStrategy} associated with this computer.
*
Expand Down
15 changes: 12 additions & 3 deletions core/src/main/java/hudson/search/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void doSuggest(StaplerRequest2 req, StaplerResponse2 rsp, @QueryParameter
r.suggestions.add(new Item(curItem.getPath(), curItem.getUrl(),
Symbol.get(new SymbolRequest.Builder().withRaw(iconName).build())));
} else {
r.suggestions.add(new Item(curItem.getPath(), curItem.getUrl(), iconName, "image"));
r.suggestions.add(new Item(curItem.getPath(), curItem.getUrl(), iconName, "image", curItem.item.getSearchGroup()));
}
}
rsp.serveExposedBean(req, r, new ExportConfig());
Expand Down Expand Up @@ -277,7 +277,9 @@ public static class Item {

private final String type;

public final String iconXml;
private final String iconXml;

private final SearchGroup group;

public Item(String name) {
this(name, null, null);
Expand All @@ -288,13 +290,15 @@ public Item(String name, String url, String iconXml) {
this.url = url;
this.iconXml = iconXml;
this.type = "symbol";
this.group = null;
}

public Item(String name, String url, String iconXml, String type) {
public Item(String name, String url, String iconXml, String type, SearchGroup group) {
this.name = name;
this.url = url;
this.iconXml = iconXml;
this.type = type;
this.group = group;
}

@Exported
Expand All @@ -311,6 +315,11 @@ public String getIconXml() {
public String getType() {
return type;
}

@Exported
public SearchGroup getGroup() {
return group;
}
}

private enum Mode {
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/hudson/search/SearchItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ default String getSearchIcon() {
return "symbol-search";
}

default SearchGroup getSearchGroup() {
return SearchGroup.OTHER;
}

/**
* Returns the {@link SearchIndex} to further search sub items inside this item.
*
Expand Down

0 comments on commit 3d45ca7

Please sign in to comment.