提交 34269466 编写于 作者: J Jesse Glick

Run.canToggleLogKeep.

上级 0b52029e
......@@ -1926,6 +1926,23 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
getLogText().doProgressText(req,rsp);
}
/**
* Checks whether keep status can be toggled.
* Normally it can, but if there is a complex reason (from subclasses) why this build must be kept, the toggle is meaningless.
* @return true if {@link #doToggleLogKeep} and {@link #keepLog(boolean)} and {@link #keepLog()} are options
* @since 1.510
*/
public boolean canToggleLogKeep() {
if (!keepLog && isKeepLog()) {
// Definitely prevented.
return false;
}
// XXX may be that keepLog is on (perhaps toggler earlier) yet isKeepLog() would be true anyway.
// In such a case this will incorrectly return true and logKeep.jelly will allow the toggle.
// However at least then (after redirecting to the same page) the toggle button will correctly disappear.
return true;
}
public void doToggleLogKeep( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
keepLog(!keepLog);
rsp.forwardToPreviousPage(req);
......
......@@ -27,7 +27,7 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<j:if test="${it.parent.logRotator!=null}">
<j:if test="${it.parent.logRotator!=null and it.canToggleLogKeep()}">
<form method="get" action="toggleLogKeep" style="margin-top:1em">
<j:if test="${it.keepLog}">
<f:submit value="${%Don't keep this build forever}" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册