提交 e2608173 编写于 作者: K kohsuke

control the presence of the abort icon based on permission.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@6579 71c3de6d-444a-0410-be80-ed276b4c234a
上级 5edc0f17
......@@ -586,11 +586,8 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
}
}
/**
* People can stop a build if they can start a build.
*/
public void checkAbortPermission() {
getParent().getACL().checkPermission(AbstractProject.BUILD);
getParent().getACL().checkPermission(AbstractProject.ABORT);
}
//
......
......@@ -937,4 +937,8 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
private static final Logger LOGGER = Logger.getLogger(AbstractProject.class.getName());
public static final Permission BUILD = new Permission(PERMISSIONS, "Build", Permission.UPDATE);
/**
* Permission to abort a build. For now, let's make it the same as {@link #BUILD}
*/
public static final Permission ABORT = BUILD;
}
......@@ -8,6 +8,7 @@ import javax.servlet.ServletException;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.acegisecurity.AccessDeniedException;
/**
......@@ -162,6 +163,18 @@ public class Executor extends Thread implements ModelObject {
rsp.forwardToPreviousPage(req);
}
/**
* Checks if the current user has a permission to stop this build.
*/
public boolean hasStopPermission() {
try {
executable.checkAbortPermission();
return true;
} catch (AccessDeniedException e) {
return false;
}
}
public Computer getOwner() {
return owner;
}
......
......@@ -58,9 +58,9 @@
<t:buildProgressBar build="${e.currentExecutable}"/>
</td>
<td class="pane" width="16" align="center" valign="middle">
<l:isAdmin>
<j:if test="${e.hasStopPermission()}">
<a href="${rootURL}/computers/${cloop.index}/executors/${eloop.index}/stop"><img src="${imagesURL}/16x16/stop.gif" alt="${%terminate this build}" /></a>
</l:isAdmin>
</j:if>
</td>
</j:otherwise>
</j:choose>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册