Skip to content

Commit

Permalink
More
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Mar 1, 2024
1 parent 0191e64 commit 7fe28ad
Show file tree
Hide file tree
Showing 14 changed files with 214 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package jenkins.model.menu.event;

public final class DoNothingAction implements Action {}
16 changes: 16 additions & 0 deletions core/src/main/java/jenkins/model/view/AtomFeedMenuItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import jenkins.model.TransientActionFactory;
import jenkins.model.menu.Group;
import jenkins.model.menu.event.DropdownAction;
import jenkins.model.menu.event.LinkAction;

public class AtomFeedMenuItem implements Action {

Expand Down Expand Up @@ -39,6 +40,11 @@ public String getIconFileName() {
public String getDisplayName() {
return "All";
}

@Override
public jenkins.model.menu.event.Action getAction() {
return LinkAction.of("rssAll");
}
},
new Action() {
@Override
Expand All @@ -50,6 +56,11 @@ public String getIconFileName() {
public String getDisplayName() {
return "Failures";
}

@Override
public jenkins.model.menu.event.Action getAction() {
return LinkAction.of("rssFailed");
}
},
new Action() {
@Override
Expand All @@ -61,6 +72,11 @@ public String getIconFileName() {
public String getDisplayName() {
return "Latest builds";
}

@Override
public jenkins.model.menu.event.Action getAction() {
return LinkAction.of("latestBuilds");
}
}
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package jenkins.model.view;

import hudson.Extension;
import hudson.model.Action;
import hudson.model.ListView;
import java.util.Collection;
import java.util.Set;
import jenkins.model.TransientActionFactory;
import jenkins.model.menu.Group;
import jenkins.model.menu.event.LinkAction;

public class CheckFingerprintMenuItem implements Action {

@Override
public String getDisplayName() {
return "Check File Fingerprint";
}

@Override
public String getIconFileName() {
return "symbol-fingerprint";
}

@Override
public Group getGroup() {
return Group.FIRST_IN_MENU;
}

@Override
public jenkins.model.menu.event.Action getAction() {
return LinkAction.of("fingerprint");
}

@Extension
public static class TransientActionFactoryImpl extends TransientActionFactory<ListView> {

@Override
public Class<ListView> type() {
return ListView.class;
}

@Override
public Collection<? extends Action> createFor(ListView target) {
return Set.of(new CheckFingerprintMenuItem());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import hudson.Extension;
import hudson.model.Action;
import hudson.model.View;
import hudson.model.ListView;
import java.util.Collection;
import java.util.Set;
import jenkins.model.TransientActionFactory;
import jenkins.model.menu.Group;
import jenkins.model.menu.event.LinkAction;

public class ConfigureMenuItem implements Action {
public class ConfigureViewMenuItem implements Action {

@Override
public String getDisplayName() {
Expand All @@ -32,16 +32,20 @@ public jenkins.model.menu.event.Action getAction() {
}

@Extension
public static class TransientActionFactoryImpl extends TransientActionFactory<View> {
public static class TransientActionFactoryImpl extends TransientActionFactory<ListView> {

@Override
public Class<View> type() {
return View.class;
public Class<ListView> type() {
return ListView.class;
}

@Override
public Collection<? extends Action> createFor(View target) {
return Set.of(new ConfigureMenuItem());
public Collection<? extends Action> createFor(ListView target) {
if (!target.hasPermission(ListView.CONFIGURE) || !target.isEditable()) {
return Set.of();
}

return Set.of(new ConfigureViewMenuItem());
}
}
}
14 changes: 9 additions & 5 deletions core/src/main/java/jenkins/model/view/DeleteViewMenuItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import hudson.Extension;
import hudson.model.Action;
import hudson.model.View;
import hudson.model.ListView;
import java.util.Collection;
import java.util.Set;
import jenkins.model.TransientActionFactory;
Expand Down Expand Up @@ -38,15 +38,19 @@ public Semantic getSemantic() {
}

@Extension
public static class TransientActionFactoryImpl extends TransientActionFactory<View> {
public static class TransientActionFactoryImpl extends TransientActionFactory<ListView> {

@Override
public Class<View> type() {
return View.class;
public Class<ListView> type() {
return ListView.class;
}

@Override
public Collection<? extends Action> createFor(View target) {
public Collection<? extends Action> createFor(ListView target) {
if (!target.hasPermission(ListView.DELETE) || !target.getOwner().canDelete(target)) {
return Set.of();
}

return Set.of(new DeleteViewMenuItem());
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/jenkins/model/view/IconLegendMenuItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.Set;
import jenkins.model.TransientActionFactory;
import jenkins.model.menu.Group;
import jenkins.model.menu.event.JavascriptAction;
import jenkins.model.menu.event.DoNothingAction;

public class IconLegendMenuItem implements Action {

Expand All @@ -33,7 +33,7 @@ public Group getGroup() {

@Override
public jenkins.model.menu.event.Action getAction() {
return JavascriptAction.of("TODO");
return new DoNothingAction();
}

@Extension
Expand Down
33 changes: 28 additions & 5 deletions core/src/main/java/jenkins/model/view/NewProjectMenuItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import hudson.Extension;
import hudson.model.Action;
import hudson.model.View;
import hudson.model.AllView;
import hudson.model.ListView;
import java.util.Collection;
import java.util.Set;
import jenkins.model.TransientActionFactory;
Expand Down Expand Up @@ -32,15 +33,37 @@ public jenkins.model.menu.event.Action getAction() {
}

@Extension
public static class TransientActionFactoryImpl extends TransientActionFactory<View> {
public static class TransientActionFactoryListViewImpl extends TransientActionFactory<ListView> {

@Override
public Class<View> type() {
return View.class;
public Class<ListView> type() {
return ListView.class;
}

@Override
public Collection<? extends Action> createFor(View target) {
public Collection<? extends Action> createFor(ListView target) {
if (!target.hasPermission(ListView.CREATE)) {
return Set.of();
}

return Set.of(new NewProjectMenuItem());
}
}

@Extension
public static class TransientActionFactoryViewImpl extends TransientActionFactory<AllView> {

@Override
public Class<AllView> type() {
return AllView.class;
}

@Override
public Collection<? extends Action> createFor(AllView target) {
if (!target.hasPermission(AllView.CREATE)) {
return Set.of();
}

return Set.of(new NewProjectMenuItem());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package jenkins.model.view;

import hudson.Extension;
import hudson.model.Action;
import hudson.model.ListView;
import java.util.Collection;
import java.util.Set;
import jenkins.model.TransientActionFactory;
import jenkins.model.menu.Group;
import jenkins.model.menu.event.LinkAction;

public class ProjectRelationshipMenuItem implements Action {

@Override
public String getDisplayName() {
return "Project relationship";
}

@Override
public String getIconFileName() {
return "symbol-project-relationship";
}

@Override
public Group getGroup() {
return Group.FIRST_IN_MENU;
}

@Override
public jenkins.model.menu.event.Action getAction() {
return LinkAction.of("projectRelationship");
}

@Extension
public static class TransientActionFactoryImpl extends TransientActionFactory<ListView> {

@Override
public Class<ListView> type() {
return ListView.class;
}

@Override
public Collection<? extends Action> createFor(ListView target) {
return Set.of(new ProjectRelationshipMenuItem());
}
}
}
33 changes: 29 additions & 4 deletions core/src/main/resources/hudson/model/View/index.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ THE SOFTWARE.
<j:if test="${action.group.order lt 3}">
<j:choose>
<j:when test="${action.action.url != null}">
<a href="${action.action.url}"
<a href="${action.action.url}" draggable="false" role="button"
class="jenkins-button ${action.semantic != null ? 'jenkins-!-' + action.semantic.name().toLowerCase() + '-color' : ''}">
<j:if test="${action.group.order == 0}">
<l:icon src="${action.iconFileName}" />
</j:if>
${action.displayName}
<j:if test="${action.badge != null}">
<l:badge badge="${action.badge}" />
</j:if>
</a>
</j:when>
<j:otherwise>
Expand All @@ -49,6 +52,9 @@ THE SOFTWARE.
<l:icon src="${action.iconFileName}" />
</j:if>
${action.displayName}
<j:if test="${action.badge != null}">
<l:badge badge="${action.badge}" />
</j:if>
</button>
</j:otherwise>
</j:choose>
Expand All @@ -65,9 +71,28 @@ THE SOFTWARE.
<dd:separator />
</j:if>
<j:set var="currentGroup" value="${action.group.order}" />
<dd:item icon="${action.iconFileName}"
text="${action.displayName}"
clazz="${action.semantic != null ? 'jenkins-!-' + action.semantic.name().toLowerCase() + '-color' : ''}" />
<j:choose>
<j:when test="${action.action.actions != null}">
<dd:submenu icon="${action.iconFileName}"
text="${action.displayName}"
>
<j:forEach var="action" items="${action.action.actions}">
<dd:item icon="${action.iconFileName}"
text="${action.displayName}"
href="${action.action.url}"
clazz="${action.semantic != null ? 'jenkins-!-' + action.semantic.name().toLowerCase() + '-color' : ''}"
badge="${action.badge}" />
</j:forEach>
</dd:submenu>
</j:when>
<j:otherwise>
<dd:item icon="${action.iconFileName}"
text="${action.displayName}"
href="${action.action.url}"
clazz="${action.semantic != null ? 'jenkins-!-' + action.semantic.name().toLowerCase() + '-color' : ''}"
badge="${action.badge}" />
</j:otherwise>
</j:choose>
</j:if>
</j:if>
</j:forEach>
Expand Down
17 changes: 0 additions & 17 deletions core/src/main/resources/hudson/model/View/sidepanel.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ THE SOFTWARE.
<l:tasks>
<st:include page="tasks-top.jelly" it="${it.owner}" optional="true" />

<st:include page="tasks-new.jelly" it="${it.owner}" optional="true">
<!-- made overridable for ViewGroup that doesn't allow modifications -->
<l:task href="${rootURL}/${it.viewUrl}newJob" icon="symbol-add" it="${app}" permission="${it.itemCreatePermission}" title="${%NewJob(it.newPronoun)}"/>
</st:include>

<j:choose>
<j:when test="${it.class.name=='hudson.model.AllView'}">
<l:task href="${rootURL}/asynchPeople/" icon="icon-user icon-md" title="${%People}"/>
Expand All @@ -52,23 +47,11 @@ THE SOFTWARE.
</j:otherwise>
</j:choose>
<l:task href="${rootURL}/${it.viewUrl}builds" icon="symbol-build-history" 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="symbol-settings" permission="${it.CONFIGURE}" title="${%Edit View}"/>
</j:if>
<j:if test="${it.owner.canDelete(it)}">
<l:delete permission="${it.DELETE}" title="${%Delete View}" message="${%delete.view(it.displayName)}"/>
</j:if>
<j:if test="${app.fingerprintMap.ready}">
<l:task href="${rootURL}/projectRelationship" icon="symbol-project-relationship" title="${%Project Relationship}"/>
<l:task href="${rootURL}/fingerprintCheck" icon="icon-fingerprint icon-md" title="${%Check File Fingerprint}"/>
</j:if>

<!-- subtypes can put more stuff here -->
<st:include page="sidepanel2.jelly" optional="true"/>

<st:include page="tasks-bottom.jelly" it="${it.owner}" optional="true" />
<t:actions />
</l:tasks>
<j:forEach var="w" items="${it.widgets}">
<j:set var="view" value="${it}" /><!-- expose the view that's rendering this sidepanel to the widget -->
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/lib/hudson/projectView.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ THE SOFTWARE.
<t:projectViewRow jobBaseUrl="${relativeLinkToJob.substring(0, relativeLinkToJob.length() - job.shortUrl.length())}"/>
</j:forEach>
</table>
<t:iconSize><t:rssBar/></t:iconSize>
<t:iconSize></t:iconSize>
</div>

<div class="jenkins-jobs-list jenkins-mobile-show">
Expand Down
Loading

0 comments on commit 7fe28ad

Please sign in to comment.