Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add icons for search #452

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
import jenkins.model.ProjectNamingStrategy;
import jenkins.model.TransientActionFactory;
import net.sf.json.JSONObject;
import org.jenkins.ui.icon.IconSpec;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.Beta;
import org.kohsuke.accmod.restrictions.NoExternalUse;
Expand Down Expand Up @@ -134,7 +135,7 @@
*/
@SuppressWarnings({"unchecked", "rawtypes"}) // mistakes in various places
@SuppressFBWarnings("DMI_RANDOM_USED_ONLY_ONCE") // https://github.com/spotbugs/spotbugs/issues/1539
public abstract class AbstractFolder<I extends TopLevelItem> extends AbstractItem implements TopLevelItem, ItemGroup<I>, ModifiableViewGroup, StaplerFallback, ModelObjectWithChildren, StaplerOverridable {
public abstract class AbstractFolder<I extends TopLevelItem> extends AbstractItem implements TopLevelItem, ItemGroup<I>, ModifiableViewGroup, StaplerFallback, ModelObjectWithChildren, StaplerOverridable, IconSpec {

/**
* Our logger.
Expand Down Expand Up @@ -305,6 +306,15 @@
return new DefaultFolderViewHolder(views, null, newDefaultViewsTabBar());
}

@Override
public String getIconClassName() {
// avoid https://issues.jenkins.io/browse/JENKINS-74990
if (icon.getClass().getName().equals("jenkins.branch.MetadataActionFolderIcon")) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not ideal but I couldn't see a cleaner solution.

This if block means that the MetadataActionFolderIcon falls back into the code it previously did before Folder had an IconSpec.

in command palette it works fine because e.g. OrganizationFolder overrides getIconClassName so it gets the right icon, in the example I tried (GitHub organisation) it didn't load the icon in command palette but that's because it was using the IconSet API and not symbols which isn't supported by command palette right now (cc @janfaracik )

return getDescriptor().getIconClassName();
}
return icon.getIconClassName();

Check warning on line 315 in src/main/java/com/cloudbees/hudson/plugins/folder/AbstractFolder.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 312-315 are not covered by tests
}

protected FolderIcon newDefaultFolderIcon() {
return new StockFolderIcon();
}
Expand Down
Loading