mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-26 19:15:09 +00:00
Update with HeaderAction
This commit is contained in:
1 parent
79c1280d51
commit
2ea0b1f867
3 files changed
+50
-4
No files matched your search
@@ -2,6 +2,8 @@ package jenkins.views;
|
||||
|
||||
import hudson.model.Action;
|
||||
import java.util.List;
|
||||
|
||||
import hudson.model.RootAction;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
@@ -24,11 +26,13 @@ public abstract class FullHeader extends Header {
|
||||
* @return a list of {@link Action} to show in the header, defaults to {@link hudson.model.RootAction} extensions
|
||||
*/
|
||||
@Restricted(NoExternalUse.class)
|
||||
public List<Action> getActions() {
|
||||
public List<HeaderAction> getActions() {
|
||||
return Jenkins.get()
|
||||
.getActions()
|
||||
.stream()
|
||||
.filter(e -> e.getIconFileName() != null)
|
||||
.map(e -> (RootAction) e)
|
||||
.map(e -> new HeaderAction(e.getDisplayName(), e.getIconFileName(), e.getUrlName(), e.getBadge()))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package jenkins.views;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
import jenkins.management.Badge;
|
||||
import org.jenkins.ui.icon.IconSpec;
|
||||
|
||||
public class HeaderAction implements IconSpec {
|
||||
|
||||
private final @NonNull String displayName;
|
||||
|
||||
private final @NonNull String iconClassName;
|
||||
|
||||
private final String url;
|
||||
|
||||
private final Badge badge;
|
||||
|
||||
public HeaderAction(@NonNull String displayName, @NonNull String iconClassName, String url, Badge badge) {
|
||||
this.displayName = displayName;
|
||||
this.iconClassName = iconClassName;
|
||||
this.url = url;
|
||||
this.badge = badge;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public Badge getBadge() {
|
||||
return badge;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public String getIconClassName() {
|
||||
return iconClassName;
|
||||
}
|
||||
}
|
||||
@@ -32,9 +32,9 @@
|
||||
<div class="jenkins-header__actions">
|
||||
<l:overflowButton clazz="jenkins-button--tertiary jenkins-mobile-show">
|
||||
<j:forEach var="action" items="${it.actions}">
|
||||
<j:if test="${action.iconFileName != null}">
|
||||
<j:if test="${action.iconClassName != null}">
|
||||
<dd:item href="${h.getActionUrl(app.url, action)}"
|
||||
icon="${action.iconFileName}"
|
||||
icon="${action.iconClassName}"
|
||||
text="${action.displayName}" />
|
||||
</j:if>
|
||||
</j:forEach>
|
||||
@@ -73,7 +73,7 @@
|
||||
<x:attribute name="data-tippy-theme">${interactive ? 'dropdown' : 'tooltip'}</x:attribute>
|
||||
<x:attribute name="draggable">false</x:attribute>
|
||||
<x:attribute name="class">jenkins-button ${isCurrent ? '' : 'jenkins-button--tertiary'}</x:attribute>
|
||||
<l:icon src="${action.iconFileName}" />
|
||||
<l:icon src="${action.iconClassName}" />
|
||||
<span class="jenkins-visually-hidden">${action.displayName}</span>
|
||||
<j:if test="${action.badge != null}">
|
||||
<span class="jenkins-badge jenkins-!-${action.badge.severity}-color" />
|
||||
|
||||
Reference in new issue
Block a user