Skip to content

Commit

Permalink
[JENKINS-31831] Rendering content from PerJobAction so we get the cor…
Browse files Browse the repository at this point in the history
…rect ancestors in our path.
  • Loading branch information
jglick committed May 20, 2016
1 parent f395899 commit d08694d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 52 deletions.
26 changes: 18 additions & 8 deletions src/main/java/org/jenkinsci/plugins/workflow/cps/Snippetizer.java
Expand Up @@ -29,7 +29,7 @@
import hudson.model.Action;
import hudson.model.Descriptor;
import hudson.model.DescriptorByNameOwner;
import hudson.model.InvisibleAction;
import hudson.model.Item;
import hudson.model.Job;
import hudson.model.RootAction;
import java.io.Serializable;
Expand Down Expand Up @@ -236,16 +236,16 @@ public int compare(StepDescriptor o1, StepDescriptor o2) {
}

@Restricted(DoNotUse.class)
@Extension public static class SidepanelAdder extends TransientActionFactory<Job> {
@Extension public static class PerJobAdder extends TransientActionFactory<Job> {

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

@Override public Collection<? extends Action> createFor(Job target) {
// TODO probably want an API for FlowExecutionContainer or something
if (target.getClass().getName().equals("org.jenkinsci.plugins.workflow.job.WorkflowJob")) {
return Collections.singleton(new SidepanelAction());
if (target.getClass().getName().equals("org.jenkinsci.plugins.workflow.job.WorkflowJob") && target.hasPermission(Item.EXTENDED_READ)) {
return Collections.singleton(new PerJobAction(target));
} else {
return Collections.emptySet();
}
Expand All @@ -254,11 +254,21 @@ public int compare(StepDescriptor o1, StepDescriptor o2) {
}

@Restricted(NoExternalUse.class)
public static class SidepanelAction extends /* has a custom action.jelly anyway */ InvisibleAction {
public static class PerJobAction extends Snippetizer {

public static final String ACTION_URL = Snippetizer.ACTION_URL;

// TODO should retain the Job reference, and pass it along as context
public final Job<?,?> job;

PerJobAction(Job<?,?> job) {
this.job = job;
}

@Override public String getDisplayName() {
return "Pipeline Groovy";
}

public String getIconClassName() {
return "icon-help";
}

}

Expand Down

This file was deleted.

Expand Up @@ -24,17 +24,19 @@ THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout">
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout" xmlns:st="jelly:stapler">
<l:header/>
<l:side-panel>
<l:tasks>
<l:task href="${rootURL}/" icon="icon-up icon-md" title="${%Back to Jenkins}"/>
<l:task href="${rootURL}/${it.ACTION_URL}" icon="icon-gear2 icon-md" title="${%Snippet Generator}"/>
<l:task href=".." icon="icon-up icon-md" title="${%Back}"/>
<l:task href="." icon="icon-gear2 icon-md" title="${%Snippet Generator}"/>
<l:task href="html" icon="icon-help icon-md" title="${%Static Reference}"/>
<l:task href="gdsl" icon="icon-package icon-md" title="${%IntelliJ IDEA GDSL}"/>
<!-- TODO not yet ready:
<l:task href="dsld" icon="icon-package icon-md" title="${%Eclipse DSLD}"/>
-->
<div class="task"> <!-- TODO cannot use l:task since that does not support target -->
<a href="gdsl" class="task-icon-link" target="_blank"><l:icon class="icon-package icon-md" style="width: 24px; height: 24px; margin: 2px;"/></a>
<st:nbsp/>
<a href="gdsl" class="task-link" target="_blank">${%IntelliJ IDEA GDSL}</a>
</div>
<!-- TODO not yet ready: dsld “Eclipse DSLD” -->
</l:tasks>
</l:side-panel>
</j:jelly>

0 comments on commit d08694d

Please sign in to comment.