Skip to content
Permalink
Browse files

Merge pull request #1306 from bkmeneguello/post-cancel-shutdown

[FIXED JENKINS-23020 JENKINS-23942] Convert the queue's cancel shutdown to POST
  • Loading branch information...
daniel-beck committed Oct 3, 2014
2 parents 2b6c00d + 597cb55 commit fda84f456f4be4f48048970a6055399f17761ab0
@@ -112,4 +112,14 @@ public boolean getRequiresConfirmation() {
public Permission getRequiredPermission() {
return null;
}

/**
* Define if the rendered link will use the default GET method or POST.
* @return true if POST must be used
* @see RequirePOST
* @since TODO
*/
public boolean getRequiresPOST() {
return false;
}
}
@@ -52,4 +52,9 @@ public String getDescription() {
public String getUrlName() {
return Jenkins.getInstance().isQuietingDown() ? "cancelQuietDown" : "quietDown";
}

@Override
public boolean getRequiresPOST() {
return true;
}
}
@@ -43,7 +43,7 @@ THE SOFTWARE.
<l:confirmationLink href="${_href}" post="true" message="${%are.you.sure(title)}">${title}</l:confirmationLink>
</j:when>
<j:otherwise>
<a href="${_href}">${title}</a>
<f:link href="${_href}" post="${post}">${title}</f:link>
</j:otherwise>
</j:choose>
</div>
@@ -86,7 +86,7 @@ THE SOFTWARE.
<l:hasPermission permission="${m.requiredPermission}">
<j:set var="icon" value="${m.iconClassName != null ? m.iconClassName : m.iconFileName}"/>
<j:if test="${icon!=null}">
<local:feature icon="${icon}" href="${m.urlName}" title="${m.displayName}" requiresConfirmation="${m.requiresConfirmation}">
<local:feature icon="${icon}" href="${m.urlName}" title="${m.displayName}" requiresConfirmation="${m.requiresConfirmation}" post="${m.requiresPOST}">
<j:out value="${m.description}"/>
<st:include it="${m}" page="info.jelly" optional="true"/>
</local:feature>
@@ -0,0 +1,49 @@
<!--
The MIT License
Copyright (c) 2004-2010, Sun Microsystems, Inc., Bruno Kühnen Meneguello
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
<st:documentation>
Generates an anchor element with the ability to send POST requests and/or
asynchronous requests. It depends the combination of post and async attributes.

@since TODO
<st:attribute name="clazz">
Additional CSS classes.
</st:attribute>
<st:attribute name="href">
Link destination URL.
</st:attribute>
<st:attribute name="post">
If this must send a POST request.
</st:attribute>
<st:attribute name="async">
If this must send an asynchronous request.
</st:attribute>
</st:documentation>

<st:adjunct includes="lib.form.link.link"/>

<a href="${attrs.href}" class="${attrs.post ? 'post' + (attrs.async ? '-async' : '') : (attrs.async ? 'async' : '')} ${attrs.clazz}"><d:invokeBody/></a>
</j:jelly>
@@ -0,0 +1,27 @@
Behaviour.specify('A.post', 'link.post', 0, function(element) {
element.onclick = function(evt) {
var form = document.createElement('form');
form.setAttribute('method', 'POST');
form.setAttribute('action', element.getAttribute('href'));
crumb.appendToForm(form);
document.body.appendChild(form);
form.submit();
return false;
}
});

Behaviour.specify('A.post-async', 'link.post-async', 0, function(element) {
element.onclick = function(evt) {
new Ajax.Request(element.getAttribute('href'));
return false;
}
});

Behaviour.specify('A.async', 'link.async', 0, function(element) {
element.onclick = function(evt) {
new Ajax.Request(element.getAttribute('href'), {
method : 'get'
});
return false;
}
});
@@ -51,7 +51,7 @@ THE SOFTWARE.
<td class="pane" colspan="2" style="white-space: normal;">
${%Jenkins is going to shut down. No further builds will be performed.}
<j:if test="${h.hasPermission(app.ADMINISTER)}">
<a href="${rootURL}/cancelQuietDown">(${%cancel})</a>
<f:link href="${rootURL}/cancelQuietDown" post="true">(${%cancel})</f:link>
</j:if>
</td>
</tr>

0 comments on commit fda84f4

Please sign in to comment.
You can’t perform that action at this time.