mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-13 12:02:20 +00:00
Overhaul search with a Command Palette (#7569)
Co-authored-by: Wadeck Follonier <Wadeck@users.noreply.github.com> Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com> Co-authored-by: Alexander Brandes <mc.cache@web.de> Co-authored-by: Tim Jacomb <timjacomb1@gmail.com>
This commit is contained in:
28 files changed
+600
-163
No files matched your search
@@ -62,6 +62,7 @@ import hudson.model.User;
|
||||
import hudson.model.View;
|
||||
import hudson.scm.SCM;
|
||||
import hudson.scm.SCMDescriptor;
|
||||
import hudson.search.SearchFactory;
|
||||
import hudson.search.SearchableModelObject;
|
||||
import hudson.security.ACL;
|
||||
import hudson.security.AccessControlled;
|
||||
@@ -2578,6 +2579,11 @@ public class Functions {
|
||||
return String.valueOf(Math.floor(Math.random() * 3000));
|
||||
}
|
||||
|
||||
@Restricted(NoExternalUse.class)
|
||||
public static ExtensionList<SearchFactory> getSearchFactories() {
|
||||
return SearchFactory.all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keyboardShortcut the shortcut to be translated
|
||||
* @return the translated shortcut, e.g. CMD+K to ⌘+K for macOS, CTRL+K for Windows
|
||||
@@ -2596,6 +2602,10 @@ public class Functions {
|
||||
|
||||
@Restricted(NoExternalUse.class)
|
||||
public static String formatMessage(String format, Object args) {
|
||||
if (format == null) {
|
||||
return args.toString();
|
||||
}
|
||||
|
||||
return MessageFormat.format(format, args);
|
||||
}
|
||||
}
|
||||
@@ -541,7 +541,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
|
||||
public void suggest(String token, List<SearchItem> result) {
|
||||
find(token, result);
|
||||
}
|
||||
}).add("configure", "config", "configure");
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -158,7 +158,7 @@ public class Search implements StaplerProxy {
|
||||
public void doSuggest(StaplerRequest2 req, StaplerResponse2 rsp, @QueryParameter String query) throws IOException, ServletException {
|
||||
Result r = new Result();
|
||||
for (SuggestedItem item : getSuggestions(req, query))
|
||||
r.suggestions.add(new Item(item.getPath()));
|
||||
r.suggestions.add(new Item(item.getPath(), item.getUrl()));
|
||||
|
||||
rsp.serveExposedBean(req, r, Flavor.JSON);
|
||||
}
|
||||
@@ -252,12 +252,25 @@ public class Search implements StaplerProxy {
|
||||
|
||||
@ExportedBean(defaultVisibility = 999)
|
||||
public static class Item {
|
||||
|
||||
@Exported
|
||||
@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "read by Stapler")
|
||||
public String name;
|
||||
|
||||
private final String url;
|
||||
|
||||
public Item(String name) {
|
||||
this(name, null);
|
||||
}
|
||||
|
||||
public Item(String name, String url) {
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Exported
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class SuggestedItem {
|
||||
buf.append(item.getSearchName());
|
||||
else {
|
||||
parent.getPath(buf);
|
||||
buf.append(' ').append(item.getSearchName());
|
||||
buf.append(" » ").append(item.getSearchName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2346,9 +2346,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
|
||||
public SearchIndexBuilder makeSearchIndex() {
|
||||
SearchIndexBuilder builder = super.makeSearchIndex();
|
||||
if (hasPermission(ADMINISTER)) {
|
||||
builder.add("configure", "config", "configure")
|
||||
.add("manage")
|
||||
.add("log");
|
||||
builder.add("manage", Messages.ManageJenkinsAction_DisplayName());
|
||||
}
|
||||
builder.add(new CollectionSearchIndex<TopLevelItem>() {
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user