Squashed commit of the following:

commit 847981ebcb
Merge: 0ea6dcff0e 23f2b9ef59
Author: Kris Stern <krisstern@outlook.com>
Date:   Wed Feb 26 09:16:52 2025 +0800

    Merge branch 'master' into add-groups-to-command-palette

commit 0ea6dcff0e
Merge: c0777dbe79 68425e2cd4
Author: Kris Stern <krisstern@outlook.com>
Date:   Wed Feb 26 01:06:33 2025 +0800

    Merge branch 'master' into add-groups-to-command-palette

commit c0777dbe79
Merge: 1638afe17e c37293c52d
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Mon Feb 24 13:40:35 2025 +0000

    Merge branch 'master' into add-groups-to-command-palette

commit 1638afe17e
Merge: c987a9e536 b97764d3fd
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Fri Feb 21 11:49:03 2025 +0000

    Merge branch 'master' into add-groups-to-command-palette

commit c987a9e536
Merge: f909eec0d4 16748f4413
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Thu Feb 20 08:17:19 2025 +0000

    Merge branch 'master' into add-groups-to-command-palette

commit f909eec0d4
Merge: 85eedb7e88 217b0f5742
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Wed Feb 19 16:12:45 2025 +0000

    Merge branch 'master' into add-groups-to-command-palette

commit 85eedb7e88
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Wed Feb 19 16:11:24 2025 +0000

    Move to Item

commit 8f4f117bac
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Wed Feb 19 15:43:50 2025 +0000

    Tighten up animations + improve contrast

commit d7b7d6388d
Merge: 8750f7cb92 4fa61274f9
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Wed Feb 19 08:50:45 2025 +0000

    Merge branch 'master' into add-groups-to-command-palette

commit 8750f7cb92
Merge: 7b527340a2 a05c33f797
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Tue Feb 18 21:42:31 2025 +0000

    Merge branch 'master' into add-groups-to-command-palette

commit 7b527340a2
Merge: e2c133d128 3505fb3540
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Mon Feb 17 20:59:02 2025 +0000

    Merge branch 'master' into add-groups-to-command-palette

commit e2c133d128
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Sun Feb 16 18:23:14 2025 +0000

    Update require-changelog-label.yml

commit d32a61c1ea
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Sun Feb 16 17:11:18 2025 +0000

    Update _theme.scss

commit 42ecfcac5c
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Sun Feb 16 17:10:48 2025 +0000

    Rename to Items

commit cc3779171a
Merge: 0f1cb2187c 2b9d4d62a6
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Sun Feb 16 17:10:25 2025 +0000

    Merge branch 'master' into add-groups-to-command-palette

commit 0f1cb2187c
Merge: 04dc6cd222 9474c89bf1
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Wed Feb 12 20:42:01 2025 +0000

    Merge branch 'master' into add-groups-to-command-palette

commit 04dc6cd222
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Tue Feb 11 17:06:31 2025 +0000

    Reduce spacing a touch, fix icon spacing

commit 0ab3665587
Merge: 7c9e172b2f 848ac9b66a
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Tue Feb 11 14:44:03 2025 +0000

    Merge branch 'master' into add-groups-to-command-palette

commit 7c9e172b2f
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Tue Feb 11 11:23:27 2025 +0000

    Update Messages.properties

commit ec6a5e5ee0
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Tue Feb 11 08:51:16 2025 +0000

    Fix test

commit 14a64885a2
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Mon Feb 10 16:44:39 2025 +0000

    Tidy up

commit 46a9e5681a
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Mon Feb 10 16:28:15 2025 +0000

    Tidy

commit d7270b1fa4
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Mon Feb 10 16:06:04 2025 +0000

    Tidy

commit b2da3f8d39
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Mon Feb 10 16:03:37 2025 +0000

    Tidy up

commit b746fba008
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Mon Feb 10 15:53:53 2025 +0000

    Move to extensionpoint

commit 7827304ae1
Merge: cac127d119 d03a2e11c9
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Mon Feb 10 15:45:28 2025 +0000

    Merge branch 'master' into add-groups-to-command-palette

commit cac127d119
Merge: add75bf6a9 e3e3c45270
Author: Tim Jacomb <21194782+timja@users.noreply.github.com>
Date:   Mon Jan 13 11:03:10 2025 +0000

    Merge branch 'jenkinsci:master' into add-groups-to-command-palette

commit add75bf6a9
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Sat Jan 11 19:02:52 2025 +0000

    Update _command-palette.scss

commit eb4073f4fb
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Sat Jan 11 18:59:37 2025 +0000

    Tidy up

commit 323e48fddf
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Sat Jan 11 18:47:34 2025 +0000

    Update Job.java

commit 3cbdfbc4b5
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Sat Jan 11 18:47:13 2025 +0000

    Update _command-palette.scss

commit 8fecf0d880
Merge: 428e826fcd 331c7685ca
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Sat Jan 11 18:45:30 2025 +0000

    Merge branch 'master' into add-groups-to-command-palette

commit 428e826fcd
Merge: 5657369d95 f1b6d31272
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Mon Dec 16 20:53:15 2024 +0000

    Merge branch 'master' into add-groups-to-command-palette

commit 5657369d95
Merge: 26f17a277f 674d5085c3
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Fri Dec 13 09:46:35 2024 +0000

    Merge branch 'add-icons-to-command-palette' into add-groups-to-command-palette

commit 674d5085c3
Merge: 809d2e6120 7020e80af8
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Fri Dec 13 09:42:59 2024 +0000

    Merge branch 'master' into add-icons-to-command-palette

commit 26f17a277f
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Wed Dec 11 22:10:56 2024 +0000

    Update _command-palette.scss

commit 2b6ffc85f3
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Wed Dec 11 22:09:09 2024 +0000

    Init

commit 809d2e6120
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Wed Dec 11 21:37:47 2024 +0000

    Make iconXml private, rename to icon

commit 3d45ca7c39
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Wed Dec 11 21:29:27 2024 +0000

    Add group field

commit 80f24cbfdc
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Wed Dec 11 21:25:23 2024 +0000

    Init

commit 1b9faa8fb0
Merge: d6868c970a 26738449cd
Author: Tim Jacomb <timjacomb1@gmail.com>
Date:   Wed Dec 11 21:11:56 2024 +0000

    Merge branch 'add-icons-to-command-palette' of github.com:janfaracik/jenkins into add-icons-to-command-palette

commit d6868c970a
Author: Tim Jacomb <timjacomb1@gmail.com>
Date:   Wed Dec 11 21:11:41 2024 +0000

    Reword javadoc

commit 26738449cd
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Wed Dec 11 21:03:29 2024 +0000

    Implement IconSpec in IComputer

commit 57910109f3
Merge: 661f994783 05ed7560fd
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Wed Dec 11 20:23:58 2024 +0000

    Merge branch 'master' into add-icons-to-command-palette

commit 661f994783
Merge: 23570203ea dad5ef3266
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Wed Dec 11 20:15:22 2024 +0000

    Merge branch 'refine-command-palette' into add-icons-to-command-palette

commit 23570203ea
Merge: 436a02b9d3 788ae63c50
Author: Tim Jacomb <timjacomb1@gmail.com>
Date:   Wed Dec 11 16:35:43 2024 +0000

    Merge branch 'add-icons-to-command-palette' of github.com:janfaracik/jenkins into add-icons-to-command-palette

commit 436a02b9d3
Author: Tim Jacomb <timjacomb1@gmail.com>
Date:   Wed Dec 11 16:35:24 2024 +0000

    Add support for images

commit a3fdb3e0c7
Merge: ea67d6a554 d22cc2fa3c
Author: Tim Jacomb <timjacomb1@gmail.com>
Date:   Wed Dec 11 15:27:12 2024 +0000

    Merge branch 'master' into add-icons-to-command-palette

commit 788ae63c50
Merge: ea67d6a554 d22cc2fa3c
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Wed Dec 11 10:00:04 2024 +0000

    Merge branch 'jenkinsci:master' into add-icons-to-command-palette

commit dad5ef3266
Merge: cc63c9c8e5 d22cc2fa3c
Author: Tim Jacomb <21194782+timja@users.noreply.github.com>
Date:   Wed Dec 11 09:07:05 2024 +0000

    Merge branch 'master' into refine-command-palette

commit ea67d6a554
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Tue Dec 10 22:26:16 2024 +0000

    Update Search.java

commit a9aadbab30
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Tue Dec 10 22:25:40 2024 +0000

    Revert "Update Search.java"

    This reverts commit 24837ea667.

commit 24837ea667
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Tue Dec 10 21:59:03 2024 +0000

    Update Search.java

commit d43a8d3b2f
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Tue Dec 10 21:54:23 2024 +0000

    Init

commit cc63c9c8e5
Author: Jan Faracik <43062514+janfaracik@users.noreply.github.com>
Date:   Tue Dec 10 21:37:09 2024 +0000

    Refine command palette
This commit is contained in:
Jan Faracik 2025-02-28 18:00:14 +00:00
parent 7ca2e8f63b
commit ca0176a53e
15 changed files with 225 additions and 38 deletions

View File

@ -110,6 +110,7 @@ import jenkins.model.DisplayExecutor;
import jenkins.model.IComputer; import jenkins.model.IComputer;
import jenkins.model.IDisplayExecutor; import jenkins.model.IDisplayExecutor;
import jenkins.model.Jenkins; import jenkins.model.Jenkins;
import jenkins.search.SearchGroup;
import jenkins.security.ImpersonatingExecutorService; import jenkins.security.ImpersonatingExecutorService;
import jenkins.security.MasterToSlaveCallable; import jenkins.security.MasterToSlaveCallable;
import jenkins.security.stapler.StaplerDispatchable; import jenkins.security.stapler.StaplerDispatchable;
@ -1109,6 +1110,11 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
return getUrl(); return getUrl();
} }
@Override
public SearchGroup getSearchGroup() {
return SearchGroup.get(SearchGroup.ComputerSearchGroup.class);
}
/** /**
* {@link RetentionStrategy} associated with this computer. * {@link RetentionStrategy} associated with this computer.
* *

View File

@ -39,6 +39,7 @@ import hudson.util.Secret;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import jenkins.model.Jenkins; import jenkins.model.Jenkins;
import jenkins.search.SearchGroup;
import jenkins.util.SystemProperties; import jenkins.util.SystemProperties;
import jenkins.util.io.OnMaster; import jenkins.util.io.OnMaster;
import org.kohsuke.stapler.StaplerRequest2; import org.kohsuke.stapler.StaplerRequest2;
@ -249,6 +250,11 @@ public interface Item extends PersistenceRoot, SearchableModelObject, AccessCont
*/ */
void delete() throws IOException, InterruptedException; void delete() throws IOException, InterruptedException;
@Override
default SearchGroup getSearchGroup() {
return SearchGroup.get(SearchGroup.ItemSearchGroup.class);
}
PermissionGroup PERMISSIONS = new PermissionGroup(Item.class, Messages._Item_Permissions_Title()); PermissionGroup PERMISSIONS = new PermissionGroup(Item.class, Messages._Item_Permissions_Title());
Permission CREATE = Permission CREATE =
new Permission( new Permission(

View File

@ -72,6 +72,7 @@ import jenkins.model.Jenkins;
import jenkins.model.Loadable; import jenkins.model.Loadable;
import jenkins.model.ModelObjectWithContextMenu; import jenkins.model.ModelObjectWithContextMenu;
import jenkins.scm.RunWithSCM; import jenkins.scm.RunWithSCM;
import jenkins.search.SearchGroup;
import jenkins.security.ImpersonatingUserDetailsService2; import jenkins.security.ImpersonatingUserDetailsService2;
import jenkins.security.LastGrantedAuthoritiesProperty; import jenkins.security.LastGrantedAuthoritiesProperty;
import jenkins.security.UserDetailsCache; import jenkins.security.UserDetailsCache;
@ -284,6 +285,11 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
return UserAvatarResolver.resolve(this, "48x48"); return UserAvatarResolver.resolve(this, "48x48");
} }
@Override
public SearchGroup getSearchGroup() {
return SearchGroup.get(SearchGroup.UserSearchGroup.class);
}
/** /**
* The URL of the user page. * The URL of the user page.
*/ */

View File

@ -94,6 +94,7 @@ import jenkins.model.ModelObjectWithContextMenu;
import jenkins.model.item_category.Categories; import jenkins.model.item_category.Categories;
import jenkins.model.item_category.Category; import jenkins.model.item_category.Category;
import jenkins.model.item_category.ItemCategory; import jenkins.model.item_category.ItemCategory;
import jenkins.search.SearchGroup;
import jenkins.security.stapler.StaplerNotDispatchable; import jenkins.security.stapler.StaplerNotDispatchable;
import jenkins.util.xml.XMLUtils; import jenkins.util.xml.XMLUtils;
import jenkins.widgets.HasWidgets; import jenkins.widgets.HasWidgets;
@ -565,6 +566,11 @@ public abstract class View extends AbstractModelObject implements AccessControll
return "symbol-jobs"; return "symbol-jobs";
} }
@Override
public SearchGroup getSearchGroup() {
return SearchGroup.get(SearchGroup.ViewSearchGroup.class);
}
/** /**
* Returns the transient {@link Action}s associated with the top page. * Returns the transient {@link Action}s associated with the top page.
* *

View File

@ -29,6 +29,8 @@ import static jakarta.servlet.http.HttpServletResponse.SC_NOT_FOUND;
import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.ExtensionComponent;
import hudson.ExtensionList;
import hudson.Util; import hudson.Util;
import hudson.util.EditDistance; import hudson.util.EditDistance;
import io.jenkins.servlet.ServletExceptionWrapper; import io.jenkins.servlet.ServletExceptionWrapper;
@ -37,12 +39,16 @@ import java.io.IOException;
import java.util.AbstractList; import java.util.AbstractList;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors;
import jenkins.model.Jenkins; import jenkins.model.Jenkins;
import jenkins.search.SearchGroup;
import jenkins.security.stapler.StaplerNotDispatchable; import jenkins.security.stapler.StaplerNotDispatchable;
import jenkins.util.MemoryReductionUtil; import jenkins.util.MemoryReductionUtil;
import jenkins.util.SystemProperties; import jenkins.util.SystemProperties;
@ -171,11 +177,26 @@ public class Search implements StaplerProxy {
if (iconName.startsWith("symbol")) { if (iconName.startsWith("symbol")) {
r.suggestions.add(new Item(curItem.getPath(), curItem.getUrl(), r.suggestions.add(new Item(curItem.getPath(), curItem.getUrl(),
Symbol.get(new SymbolRequest.Builder().withRaw(iconName).build()))); Symbol.get(new SymbolRequest.Builder().withRaw(iconName).build()), "symbol", curItem.item.getSearchGroup().getDisplayName()));
} else { } 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().getDisplayName()));
} }
} }
// Sort results by group
ExtensionList<SearchGroup> groupsExtensionList = ExtensionList.lookup(SearchGroup.class);
List<ExtensionComponent<SearchGroup>> components = groupsExtensionList.getComponents();
Map<String, Double> searchGroupOrdinal = components.stream()
.collect(Collectors.toMap(
(k) -> k.getInstance().getDisplayName(),
ExtensionComponent::ordinal
));
r.suggestions.sort(
Comparator.comparingDouble((Item item) -> searchGroupOrdinal.getOrDefault(item.getGroup(), Double.MAX_VALUE))
.reversed()
.thenComparing(item -> item.name)
);
rsp.serveExposedBean(req, r, new ExportConfig()); rsp.serveExposedBean(req, r, new ExportConfig());
} }
@ -279,22 +300,19 @@ public class Search implements StaplerProxy {
private final String icon; private final String icon;
private final String group;
public Item(String name) { public Item(String name) {
this(name, null, null); this(name, null, null, "symbol", null);
} }
public Item(String name, String url, String icon) { public Item(String name, String url, String icon, String type, String group) {
this.name = name; this.name = name;
this.url = url; this.url = url;
this.icon = icon; this.icon = icon;
this.type = "symbol";
}
public Item(String name, String url, String icon, String type) {
this.name = name; this.name = name;
this.url = url;
this.icon = icon;
this.type = type; this.type = type;
this.group = group;
} }
@Exported @Exported
@ -311,6 +329,11 @@ public class Search implements StaplerProxy {
public String getType() { public String getType() {
return type; return type;
} }
@Exported
public String getGroup() {
return group;
}
} }
private enum Mode { private enum Mode {

View File

@ -25,6 +25,7 @@
package hudson.search; package hudson.search;
import hudson.model.Build; import hudson.model.Build;
import jenkins.search.SearchGroup;
import org.jenkins.ui.icon.IconSpec; import org.jenkins.ui.icon.IconSpec;
/** /**
@ -63,6 +64,10 @@ public interface SearchItem {
return "symbol-search"; return "symbol-search";
} }
default SearchGroup getSearchGroup() {
return SearchGroup.get(SearchGroup.UnclassifiedSearchGroup.class);
}
/** /**
* Returns the {@link SearchIndex} to further search sub items inside this item. * Returns the {@link SearchIndex} to further search sub items inside this item.
* *

View File

@ -0,0 +1,73 @@
package jenkins.search;
import static jenkins.search.Messages.SearchGroup_ComputerSearchGroup_DisplayName;
import static jenkins.search.Messages.SearchGroup_ItemSearchGroup_DisplayName;
import static jenkins.search.Messages.SearchGroup_UnclassifiedSearchGroup_DisplayName;
import static jenkins.search.Messages.SearchGroup_UserSearchGroup_DisplayName;
import static jenkins.search.Messages.SearchGroup_ViewSearchGroup_DisplayName;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.model.ModelObject;
public interface SearchGroup extends ExtensionPoint, ModelObject {
static ExtensionList<SearchGroup> all() {
return ExtensionList.lookup(SearchGroup.class);
}
static @NonNull <T extends SearchGroup> T get(Class<T> type) {
T category = all().get(type);
if (category == null) {
throw new AssertionError("Group not found. It seems the " + type + " is not annotated with @Extension and so not registered");
}
return category;
}
@Extension(ordinal = -1)
class UnclassifiedSearchGroup implements SearchGroup {
@Override
public String getDisplayName() {
return SearchGroup_UnclassifiedSearchGroup_DisplayName();
}
}
@Extension(ordinal = 999)
class ItemSearchGroup implements SearchGroup {
@Override
public String getDisplayName() {
return SearchGroup_ItemSearchGroup_DisplayName();
}
}
@Extension
class ComputerSearchGroup implements SearchGroup {
@Override
public String getDisplayName() {
return SearchGroup_ComputerSearchGroup_DisplayName();
}
}
@Extension
class ViewSearchGroup implements SearchGroup {
@Override
public String getDisplayName() {
return SearchGroup_ViewSearchGroup_DisplayName();
}
}
@Extension
class UserSearchGroup implements SearchGroup {
@Override
public String getDisplayName() {
return SearchGroup_UserSearchGroup_DisplayName();
}
}
}

View File

@ -0,0 +1,27 @@
# The MIT License
#
# Copyright (c) 2025 Jan Faracik
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
SearchGroup.UnclassifiedSearchGroup.DisplayName=Other
SearchGroup.ItemSearchGroup.DisplayName=Items
SearchGroup.ComputerSearchGroup.DisplayName=Nodes
SearchGroup.ViewSearchGroup.DisplayName=Views
SearchGroup.UserSearchGroup.DisplayName=Users

View File

@ -21,6 +21,7 @@ export const JenkinsSearchSource = {
type: e.type, type: e.type,
label: e.name, label: e.name,
url: correctAddress(e.url), url: correctAddress(e.url),
group: e.group,
}), }),
); );
}), }),

View File

@ -5,6 +5,7 @@ import * as Symbols from "./symbols";
import makeKeyboardNavigable from "@/util/keyboard"; import makeKeyboardNavigable from "@/util/keyboard";
import { xmlEscape } from "@/util/security"; import { xmlEscape } from "@/util/security";
import { createElementFromHtml } from "@/util/dom"; import { createElementFromHtml } from "@/util/dom";
import { groupResultsByCategory } from "@/components/command-palette/utils";
const datasources = [JenkinsSearchSource]; const datasources = [JenkinsSearchSource];
@ -68,6 +69,7 @@ function init() {
label: i18n.dataset.getHelp, label: i18n.dataset.getHelp,
url: document.querySelector("body").dataset.searchHelpUrl, url: document.querySelector("body").dataset.searchHelpUrl,
isExternal: true, isExternal: true,
group: null,
}), }),
]); ]);
} else { } else {
@ -77,15 +79,26 @@ function init() {
} }
results.then((results) => { results.then((results) => {
results = groupResultsByCategory(results);
// Clear current search results // Clear current search results
searchResults.innerHTML = ""; searchResults.innerHTML = "";
if (query.length === 0 || Object.keys(results).length > 0) { if (query.length === 0 || Object.keys(results).length > 0) {
results.forEach(function (obj) { for (const [group, items] of Object.entries(results)) {
if (group !== "null") {
const heading = document.createElement("p");
heading.className = "jenkins-command-palette__results__heading";
heading.innerText = group;
searchResults.append(heading);
}
items.forEach(function (obj) {
const link = createElementFromHtml(obj.render()); const link = createElementFromHtml(obj.render());
link.addEventListener("mouseenter", (e) => itemMouseEnter(e)); link.addEventListener("mouseenter", (e) => itemMouseEnter(e));
searchResults.append(link); searchResults.append(link);
}); });
}
updateSelectedItem(0); updateSelectedItem(0);
} else { } else {

View File

@ -7,12 +7,14 @@ import { xmlEscape } from "@/util/security";
* @param {string} params.label * @param {string} params.label
* @param {'symbol' | 'image'} params.type * @param {'symbol' | 'image'} params.type
* @param {string} params.url * @param {string} params.url
* @param {string | null} params.group
* @param {boolean | undefined} params.isExternal * @param {boolean | undefined} params.isExternal
*/ */
export function LinkResult(params) { export function LinkResult(params) {
return { return {
label: params.label, label: params.label,
url: params.url, url: params.url,
group: params.group,
render: () => { render: () => {
return `<a class="jenkins-command-palette__results__item" href="${xmlEscape( return `<a class="jenkins-command-palette__results__item" href="${xmlEscape(
params.url, params.url,

View File

@ -0,0 +1,13 @@
/**
* Group results by 'group' field into a map
*/
export function groupResultsByCategory(array) {
return array.reduce((hash, obj) => {
if (obj.group === undefined) {
return hash;
}
return Object.assign(hash, {
[obj.group]: (hash[obj.group] || []).concat(obj),
});
}, {});
}

View File

@ -192,17 +192,17 @@ $semantics: (
--link-font-weight: var(--font-bold-weight); --link-font-weight: var(--font-bold-weight);
// Command Palette // Command Palette
--command-palette-results-backdrop-filter: contrast(0.7) brightness(1.5) --command-palette-results-backdrop-filter: saturate(1.5) blur(5px);
saturate(1.4) blur(20px);
--command-palette-inset-shadow: --command-palette-inset-shadow:
inset 0 0 2px 2px rgb(255 255 255 / 0.1), inset 0 0 2px 2px rgb(255 255 255 / 0.1),
var(--jenkins-border--subtle-shadow); var(--jenkins-border--subtle-shadow),
0 5px 10px var(--jenkins-border-color--subtle);
::backdrop { ::backdrop {
--command-palette-backdrop-background: radial-gradient( --command-palette-backdrop-background: color-mix(
farthest-corner at 50% 30vh, in sRGB,
rgb(0 0 0 / 0.3), var(--black) 17.5%,
rgb(0 0 0 / 0.1) transparent
); );
} }

View File

@ -1,6 +1,12 @@
@use "../abstracts/mixins"; @use "../abstracts/mixins";
@use "../base/breakpoints"; @use "../base/breakpoints";
$command-palette-background: color-mix(
in sRGB,
var(--card-background) 92.5%,
transparent
);
.jenkins-command-palette__dialog { .jenkins-command-palette__dialog {
background: none; background: none;
border: none; border: none;
@ -14,19 +20,19 @@
&::backdrop { &::backdrop {
background: var(--command-palette-backdrop-background); background: var(--command-palette-backdrop-background);
backdrop-filter: contrast(0.7) brightness(0.9) saturate(1.25) blur(3px); backdrop-filter: blur(1px);
animation: jenkins-dialog-backdrop-animate-in 0.1s linear; animation: jenkins-dialog-backdrop-animate-in 0.075s linear;
} }
&[open] { &[open] {
animation: command-palette-animate-in 0.1s cubic-bezier(0, 0.68, 0.5, 1.5); animation: command-palette-animate-in 0.075s cubic-bezier(0, 0.68, 0.5, 1.5);
} }
&[closing] { &[closing] {
animation: command-palette-animate-out 0.1s linear; animation: command-palette-animate-out 0.05s linear;
&::backdrop { &::backdrop {
animation: jenkins-dialog-backdrop-animate-out 0.1s linear; animation: jenkins-dialog-backdrop-animate-out 0.05s linear;
} }
} }
} }
@ -48,7 +54,7 @@
} }
.jenkins-command-palette__wrapper { .jenkins-command-palette__wrapper {
--inset: 15vh; --inset: 10vh;
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -76,7 +82,7 @@
&__search { &__search {
--search-bar-height: 3rem !important; --search-bar-height: 3rem !important;
background: transparent; background: $command-palette-background;
box-shadow: var(--command-palette-inset-shadow); box-shadow: var(--command-palette-inset-shadow);
margin-bottom: var(--section-padding); margin-bottom: var(--section-padding);
border-radius: 1rem; border-radius: 1rem;
@ -109,12 +115,13 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
border-radius: 1rem; border-radius: 1rem;
background: $command-palette-background;
backdrop-filter: var(--command-palette-results-backdrop-filter); backdrop-filter: var(--command-palette-results-backdrop-filter);
box-shadow: var(--command-palette-inset-shadow); box-shadow: var(--command-palette-inset-shadow);
// If set to 0, Safari won't always show the backdrop-filter // If set to 0, Safari won't always show the backdrop-filter
height: 1px; height: 1px;
transition: height var(--standard-transition); transition: height 0.15s ease;
overflow: hidden; overflow: hidden;
will-change: height; will-change: height;
} }
@ -125,14 +132,13 @@
padding: 0.5rem; padding: 0.5rem;
&__heading { &__heading {
font-weight: var(--font-bold-weight);
font-size: var(--font-size-sm); font-size: var(--font-size-sm);
margin: 0; margin: 0;
padding: 0.75rem 0.75rem 0.625rem; padding: 0.375rem 0.625rem;
color: var(--text-color-secondary); color: var(--text-color-secondary);
&:not(:first-of-type) { &:not(:first-of-type) {
padding-top: 2rem; padding-top: 1.375rem;
} }
} }
@ -153,10 +159,9 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: flex-start; justify-content: flex-start;
padding: 0.75rem; padding: 0.625rem;
border-radius: 0.5rem; border-radius: 0.5rem;
color: var(--text-color) !important; color: var(--text-color) !important;
transition: var(--standard-transition);
&--hover { &--hover {
&::before { &::before {
@ -171,7 +176,7 @@
justify-content: center; justify-content: center;
width: 1.375rem; width: 1.375rem;
height: 1.375rem; height: 1.375rem;
margin-right: 0.75rem; margin-right: 0.625rem;
overflow: hidden; overflow: hidden;
pointer-events: none; pointer-events: none;
color: var(--text-color); color: var(--text-color);
@ -210,8 +215,8 @@
&__info { &__info {
font-size: var(--font-size-sm); font-size: var(--font-size-sm);
margin: 0; margin: 0;
padding: 0 14px; padding: 0 0.625rem;
line-height: 46px; line-height: 42px;
color: var(--text-color); color: var(--text-color);
span { span {

View File

@ -666,6 +666,7 @@ public class AbstractProjectTest {
o.put("url", JSONObject.fromObject(null)); o.put("url", JSONObject.fromObject(null));
o.put("icon", JSONObject.fromObject(null)); o.put("icon", JSONObject.fromObject(null));
o.put("type", "symbol"); o.put("type", "symbol");
o.put("group", JSONObject.fromObject(null));
expected.add(o); expected.add(o);
} }
assertThat(suggestions.containsAll(expected), is(true)); assertThat(suggestions.containsAll(expected), is(true));