Skip to content

Commit

Permalink
Updated plugin manager
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Jan 14, 2022
1 parent 6994e51 commit ec2fb5b
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 65 deletions.
13 changes: 12 additions & 1 deletion core/src/main/java/hudson/model/Action.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import edu.umd.cs.findbugs.annotations.CheckForNull;
import hudson.Functions;
import org.jenkins.ui.icon.Icon;
import org.jenkins.ui.icon.IconSet;

/**
* Object that contributes additional information, behaviors, and UIs to {@link ModelObject}
Expand Down Expand Up @@ -97,7 +99,16 @@ public interface Action extends ModelObject {
* @see Functions#isAnonymous()
* @see Functions#getIconFilePath(Action)
*/
@CheckForNull String getIconFileName();
@Deprecated
default String getIconFileName() {
return null;
}

@CheckForNull
default Icon getIcon() {
return IconSet.icons.getIconByClassSpec(
IconSet.toNormalizedIconNameClass(getIconFileName()) + " icon-xlg");
}

/**
* Gets the string to be displayed.
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/java/hudson/model/ManageJenkinsAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import hudson.Extension;
import jenkins.model.Jenkins;
import org.jenkins.ui.icon.Icon;
import org.jenkins.ui.icon.IconSet;
import org.jenkinsci.Symbol;

/**
Expand All @@ -36,9 +38,9 @@
@Extension(ordinal = 100) @Symbol("manageJenkins")
public class ManageJenkinsAction implements RootAction {
@Override
public String getIconFileName() {
public Icon getIcon() {
if (Jenkins.get().hasAnyPermission(Jenkins.MANAGE, Jenkins.SYSTEM_READ))
return "gear.png";
return Icon.fromSvg(IconSet.getScalableIcon("settings-outline", null));
else
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@ public void writeWholeLogTo(@NonNull OutputStream out) throws IOException, Inter
.add("console")
.add("changes");
for (Action a : getAllActions()) {
if (a.getIconFileName() != null)
if (a.getIcon() != null)
builder.add(a.getUrlName());
}
return builder;
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/jenkins/model/Jenkins.java
Original file line number Diff line number Diff line change
Expand Up @@ -4938,7 +4938,7 @@ public List<ManagementLink> getManagementLinks() {
public Map<ManagementLink.Category, List<ManagementLink>> getCategorizedManagementLinks() {
Map<ManagementLink.Category, List<ManagementLink>> byCategory = new TreeMap<>();
for (ManagementLink link : ManagementLink.all()) {
if (link.getIconFileName() == null) {
if (link.getIcon() == null) {
continue;
}
if (!Jenkins.get().hasPermission(link.getRequiredPermission())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ THE SOFTWARE.
<l:task href=".." icon="icon-up icon-md" title="${%Back to Loggers}"/>
<l:task href="." icon="icon-notepad icon-md" title="${%Log records}"/>
<l:isAdmin>
<l:task href="configure" icon="icon-gear icon-md" title="${%Configure}"/>
<l:task href="configure" scalableIcon="settings-outline" title="${%Configure}"/>
<l:task href="delete" icon="icon-edit-delete icon-md" title="${%Delete}"/>
</l:isAdmin>
</l:tasks>
</l:side-panel>
</j:jelly>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ THE SOFTWARE.
<l:side-panel>
<l:tasks>
<l:task href="${rootURL}/" icon="icon-up icon-md" title="${%Back to Dashboard}"/>
<l:task href="${rootURL}/manage" icon="icon-gear icon-md" title="${%Manage Jenkins}"/>
<l:task href="${rootURL}/manage" scalableIcon="settings-outline" title="${%Manage Jenkins}"/>
<l:task href="." icon="icon-clipboard icon-md" title="${%Log Recorders}">
<l:isAdmin>
<l:task href="new" icon="icon-new-package icon-md" title="${%New Log Recorder}"/>
</l:isAdmin>
</l:task>
<l:task href="all" icon="icon-notepad icon-md" title="${%All Log Messages}"/>
<l:task href="levels" icon="icon-gear icon-md" title="${%Log Levels}"/>
<l:task href="levels" scalableIcon="settings-outline" title="${%Log Levels}"/>
</l:tasks>
</l:side-panel>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ THE SOFTWARE.
<table style="margin-top: 1em; margin-left:1em;">

<j:forEach var="act" items="${it.prominentActions}">
<j:set var="icon" value="${act.iconClassName != null ? act.iconClassName : act.iconFileName}"/>
<j:set var="icon" value="${act.iconClassName != null ? act.iconClassName : act.icon}"/>
<t:summary icon="${icon}" href="${act.urlName}">
${act.displayName}
</t:summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ THE SOFTWARE.
<j:getStatic var="createPermission" className="hudson.model.Computer" field="CREATE"/>
<l:tasks>
<l:task href="${rootURL}/" icon="icon-up icon-md" title="${%Back to Dashboard}"/>
<l:task href="${rootURL}/manage" icon="icon-gear icon-md" permissions="${app.MANAGE_AND_SYSTEM_READ}" title="${%Manage Jenkins}"/>
<l:task href="${rootURL}/manage" scalableIcon="settings-outline" permissions="${app.MANAGE_AND_SYSTEM_READ}" title="${%Manage Jenkins}"/>
<l:task href="new" icon="icon-new-computer icon-md" permission="${createPermission}" title="${%New Node}"/>
<l:task href="${rootURL}/configureClouds" icon="icon-health-40to59 icon-md" permission="${app.SYSTEM_READ}"
title="${app.hasPermission(app.ADMINISTER) ? '%Configure Clouds' : '%View Clouds'}"/>
<l:task href="configure" icon="icon-gear icon-md" permissions="${app.MANAGE_AND_SYSTEM_READ}" title="${%Node Monitoring}"/>
<l:task href="configure" scalableIcon="settings-outline" permissions="${app.MANAGE_AND_SYSTEM_READ}" title="${%Node Monitoring}"/>
</l:tasks>
<t:queue items="${app.queue.items}" />
<t:executors />
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Label/sidepanel.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ THE SOFTWARE.
<l:task contextMenu="false" href="${rootURL}/" icon="icon-up icon-md" title="${%Back to Dashboard}"/>
<l:task contextMenu="false" href="${url}" icon="icon-attribute icon-md" title="${%Overview}"/>
<j:if test="${it.atom}">
<l:task href="${url}/configure" icon="icon-gear icon-md" title="${%Configure}" permission="${app.ADMINISTER}" />
<l:task href="${url}/configure" scalableIcon="settings-outline" title="${%Configure}" permission="${app.ADMINISTER}" />
</j:if>
<l:task href="${url}/load-statistics" icon="icon-monitor icon-md" title="${%Load Statistics}"/>
<st:include page="actions.jelly" />
</l:tasks>
</l:side-panel>
</j:jelly>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ THE SOFTWARE.
<l:side-panel>
<l:tasks>
<l:task href="${rootURL}/" icon="icon-up icon-md" title="${%Back to Dashboard}"/>
<l:task href="${rootURL}/manage" icon="icon-gear icon-md" title="${%Manage Jenkins}"/>
<l:task href="${rootURL}/manage" scalableIcon="settings-outline" title="${%Manage Jenkins}"/>
<l:task href="${rootURL}/pluginManager/" icon="icon-plugin icon-lg" title="${%Manage Plugins}"/>
</l:tasks>
</l:side-panel>
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/hudson/model/User/sidepanel.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ THE SOFTWARE.
<l:task contextMenu="false" href="${rootURL}/asynchPeople/" icon="icon-up icon-md" title="${%People}"/>
<l:task contextMenu="false" href="${rootURL}/${it.url}/" icon="icon-search icon-md" title="${%Status}"/>
<l:task href="${rootURL}/${it.url}/builds" icon="icon-notepad icon-md" title="${%Builds}"/>
<l:task href="${rootURL}/${it.url}/configure" icon="icon-gear icon-md" permission="${app.ADMINISTER}" title="${%Configure}"/>
<l:task href="${rootURL}/${it.url}/configure" scalableIcon="settings-outline" permission="${app.ADMINISTER}" title="${%Configure}"/>
<t:actions actions="${it.propertyActions}"/>
<t:actions actions="${it.transientActions}"/>
<j:if test="${it.canDelete()}">
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/hudson/model/View/sidepanel.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ THE SOFTWARE.
<l:task href="${rootURL}/${it.viewUrl}builds" icon="icon-notepad icon-md" title="${%Build History}"/>
<j:if test="${it.isEditable()}">
<!-- /configure URL on Jenkins object is overloaded with Jenkins's system config, so always use the explicit name. -->
<l:task href="${rootURL}/${it.viewUrl}configure" icon="icon-gear icon-md" permission="${it.CONFIGURE}" title="${%Edit View}"/>
<l:task href="${rootURL}/${it.viewUrl}configure" scalableIcon="settings-outline" permission="${it.CONFIGURE}" title="${%Edit View}"/>
</j:if>
<j:if test="${it.owner.canDelete(it)}">
<l:task href="delete" icon="icon-edit-delete icon-md" permission="${it.DELETE}" title="${%Delete View}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ THE SOFTWARE.
<l:side-panel>
<l:tasks>
<l:task href="${rootURL}/" icon="icon-up icon-md" title="${%Back to Dashboard}" />
<l:task href="${rootURL}/manage" icon="icon-gear icon-md" permission="${app.MANAGE}" title="${%Manage Jenkins}" />
<l:task href="${rootURL}/manage" scalableIcon="settings-outline" permission="${app.MANAGE}" title="${%Manage Jenkins}" />
<l:task href="." icon="icon-new-user icon-md" permission="${app.ADMINISTER}" title="${%Users}" />
<l:task href="addUser" icon="icon-new-user icon-md" permission="${app.ADMINISTER}" title="${%Create User}" />
</l:tasks>
Expand Down
53 changes: 12 additions & 41 deletions core/src/main/resources/jenkins/model/Jenkins/manage.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ THE SOFTWARE.
${taskTags!=null and attrs.contextMenu!='false' ? taskTags.addHeader(category.key.label) : null}
<div class="jenkins-section__items">
<j:forEach var="m" items="${category.value}">
<j:set var="icon" value="${m.iconClassName != null ? m.iconClassName : m.iconFileName}" />
<j:set var="iconMetadata" value="${icons.getIconByClassSpec(icon + ' icon-xlg')}"/>
<j:if test="${iconMetadata == null}">
<!-- Icon could be provided as a simple iconFileName e.g. "settings.png" -->
<j:set var="iconMetadata" value="${icons.getIconByClassSpec(icons.toNormalizedIconNameClass(icon) + ' icon-xlg')}"/>
</j:if>
<j:if test="${iconMetadata == null}">
<j:set var="iconMetadata" value="${icons.getIconByUrl(icon)}"/>
</j:if>
<j:set var="icon" value="${m.iconClassName != null ? m.iconClassName : m.icon}" />
<!-- <j:set var="iconMetadata" value="${icons.getIconByClassSpec(icon + ' icon-xlg')}"/>-->
<!-- <j:if test="${iconMetadata == null}">-->
<!-- &lt;!&ndash; Icon could be provided as a simple iconFileName e.g. "settings.png" &ndash;&gt;-->
<!-- <j:set var="iconMetadata" value="${icons.getIconByClassSpec(icons.toNormalizedIconNameClass(icon) + ' icon-xlg')}"/>-->
<!-- </j:if>-->
<!-- <j:if test="${iconMetadata == null}">-->
<!-- <j:set var="iconMetadata" value="${icons.getIconByUrl(icon)}"/>-->
<!-- </j:if>-->

<j:if test="${icon!=null}">
<div class="jenkins-section__item">
Expand All @@ -72,16 +72,7 @@ THE SOFTWARE.
<j:choose>
<j:when test="${m.requiresConfirmation}">
<l:confirmationLink href="${m.urlName}" post="${m.requiresPOST}" message="${%are.you.sure(m.displayName)}">
<j:choose>
<j:when test="${iconMetadata != null}">
<l:icon class="${iconMetadata.classSpec}"/>
</j:when>
<j:otherwise>
<l:icon src="${iconUrl}"
class="icon"
alt="[${%alt}]" />
</j:otherwise>
</j:choose>
<l:icon src="${rootURL + '/images/' + icon.url}" svg="${icon.svg}" class="icon" />
<dl>
<dt>${m.displayName}</dt>
<dd><j:out value="${m.description}"/></dd>
Expand All @@ -91,17 +82,7 @@ THE SOFTWARE.
</j:when>
<j:when test="${m.requiresPOST}">
<f:link href="${m.urlName}" post="${m.requiresPOST}">
<j:choose>
<j:when test="${iconMetadata != null}">
<l:icon class="${iconMetadata.classSpec}"
alt="[${%alt}]"/>
</j:when>
<j:otherwise>
<l:icon src="${iconUrl}"
class="icon"
alt="[${%alt}]" />
</j:otherwise>
</j:choose>
<l:icon src="${rootURL + '/images/' + icon.url}" svg="${icon.svg}" class="icon" />
<dl>
<dt>${m.displayName}</dt>
<dd><j:out value="${m.description}"/></dd>
Expand All @@ -111,17 +92,7 @@ THE SOFTWARE.
</j:when>
<j:otherwise>
<a href="${m.urlName}">
<j:choose>
<j:when test="${iconMetadata != null}">
<l:icon class="${iconMetadata.classSpec}"
alt="[${%alt}]"/>
</j:when>
<j:otherwise>
<l:icon src="${iconUrl}"
class="icon"
alt="[${%alt}]" />
</j:otherwise>
</j:choose>
<l:icon src="${rootURL + '/images/' + icon.url}" svg="${icon.svg}" class="icon" />
<dl>
<dt>${m.displayName}</dt>
<dd><j:out value="${m.description}"/></dd>
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/resources/lib/hudson/actions.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ THE SOFTWARE.
the action object itself is available in the 'action' variable
-->
<st:include page="action.jelly" from="${action}" optional="true">
<j:set var="icon" value="${action.iconClassName != null ? action.iconClassName + ' icon-md' : action.iconFileName}"/>
<j:set var="icon" value="${action.iconClassName != null ? action.iconClassName + ' icon-md' : action.icon}"/>

${icon}
${action.icon}

<j:if test="${icon!=null}">
<l:task icon="${icon}" title="${action.displayName}"
href="${h.getActionUrl(it.url,action)}" contextMenu="${h.isContextMenuVisible(action)}"/>
</j:if>
</st:include>
</j:forEach>
</j:jelly>
</j:jelly>
4 changes: 2 additions & 2 deletions core/src/main/resources/lib/hudson/project/configurable.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ THE SOFTWARE.
</j:if>
<j:choose>
<j:when test="${h.hasPermission(it,it.CONFIGURE)}">
<l:task href="${url}/configure" icon="icon-gear icon-md" title="${%Configure}"/>
<l:task href="${url}/configure" scalableIcon="settings-outline" title="${%Configure}"/>
</j:when>
<j:when test="${h.hasPermission(it,it.EXTENDED_READ)}">
<l:task href="${url}/configure" icon="icon-gear icon-md" title="${%View Configuration}"/>
<l:task href="${url}/configure" scalableIcon="settings-outline" title="${%View Configuration}"/>
</j:when>
</j:choose>
<l:task confirmationMessage="${%delete.confirm(it.pronoun, it.displayName)}" href="${url}/doDelete" icon="icon-edit-delete icon-md" permission="${it.DELETE}" post="true" requiresConfirmation="true" title="${%delete(it.pronoun)}"/>
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/lib/layout/task.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ THE SOFTWARE.
<st:attribute name="href" use="required">
Link target. Relative to the current page.
</st:attribute>
<st:attribute name="icon" use="required">
<st:attribute name="icon">
URL to an icon image, or the icon class specification. If using an image URL,
the image should be 24x24 in size and relative to the context path of Hudson.

Expand Down
12 changes: 11 additions & 1 deletion war/src/main/less/modules/side-panel-tasks.less
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,19 @@

// Target only icons withink task link in order to keep backwards compatibility
.task .task-icon-link {
display: inline-block;
display: inline-flex;
align-items: center;
justify-content: center;
margin: 0;
margin-right: 0.5rem;
width: 1.5rem;
height: 1.5rem;

svg {
width: 1.5rem;
height: 1.5rem;
color: var(--primary);
}
}
// Reset the margin for the icon links
.task .task-icon-link img,
Expand Down

0 comments on commit ec2fb5b

Please sign in to comment.