Class ItemListTab

java.lang.Object
jenkins.model.Tab
jenkins.model.dashboard.ItemListTab
All Implemented Interfaces:
Action, ModelObject, Badgeable
Direct Known Subclasses:
AllTab

@Restricted(org.kohsuke.accmod.restrictions.Beta.class) public abstract class ItemListTab extends Tab
A Dashboard tab that lists items, loading them a page at a time as the user scrolls, with a search box.

Subclasses only provide the items. For example, a tab listing the current user's favourite jobs:


 public class FavoritesTab extends ItemListTab {
     public FavoritesTab(Dashboard dashboard) { super(dashboard); }
     public String getDisplayName() { return "Favorites"; }
     public String getIconFileName() { return "symbol-star"; }
     public String getUrlName() { return "favorites"; }
     public Iterable<? extends Item> getItems() { return Favorites.getFavorites(User.current()); }
 }
 
and contribute it with a TransientActionFactory for Dashboard.
Since:
TODO
  • Constructor Details

    • ItemListTab

      protected ItemListTab(@NonNull Dashboard dashboard)
  • Method Details

    • getItems

      @NonNull public abstract Iterable<? extends Item> getItems()
      The items to list, in display order, already filtered to those the current user can see. Only the requested page is read from the returned Iterable, so it may be lazy.
    • search

      @NonNull public Iterable<? extends Item> search(@NonNull String query)
      The items matching a search query. By default, the items from getItems() accepted by matching(String).
      Parameters:
      query - a non-blank query
    • matching

      @NonNull protected static Predicate<Item> matching(@NonNull String query)
      Accepts items whose name or full display name contains a query, ignoring case. The full display name includes the names of the folders containing the item, so a folder's name matches everything in it.
    • getEmptyMessage

      @CheckForNull public String getEmptyMessage()
      Shown when there is nothing to list and no search is active.
    • getPage

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @NonNull public ItemListTab.Page getPage(int start, @CheckForNull String after, @CheckForNull String search)
      Reads one page of items. Items the current user cannot read are left out, whatever the subclass returns.
      Parameters:
      start - the index of the first item to return, used when after is not listed
      after - the full name of the last item already shown, or null. The page continues after it, so items removed from earlier in the list don't shift the page past items not yet shown.
      search - a query, or null to list everything
    • getPage

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @NonNull public ItemListTab.Page getPage(int start, @CheckForNull String search)
      Reads one page of items, by position only.
      See Also:
    • getEmptyStateView

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @NonNull public View getEmptyStateView()
      The page shown when there is nothing to list: the welcome page of the root of Jenkins, whichever view is the primary one.
    • doItems

      @GET @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void doItems(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter String start, @QueryParameter String after, @QueryParameter String search) throws IOException, jakarta.servlet.ServletException
      Renders one page of rows as an HTML fragment.
      Throws:
      IOException
      jakarta.servlet.ServletException