Skip to content

Commit f3a626e

Browse files
committed
Fix race condition in pane collapse POST handling
1 parent a3fb95e commit f3a626e

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

core/src/main/resources/lib/form/link/link.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
Behaviour.specify("A.post", "link.post", 0, function (element) {
2-
const pendingHref = element.getAttribute("data-post-href");
3-
if (pendingHref) {
4-
element.setAttribute("href", pendingHref);
5-
element.removeAttribute("data-post-href");
6-
}
7-
82
element.onclick = function () {
9-
var form = document.createElement("form");
3+
const url = element.getAttribute("data-post-href") || element.getAttribute("href");
4+
if (!url) {
5+
return false;
6+
}
7+
const form = document.createElement("form");
108
form.setAttribute("method", "POST");
11-
form.setAttribute("action", element.getAttribute("href"));
9+
form.setAttribute("action", url);
1210
crumb.appendToForm(form);
1311
document.body.appendChild(form);
1412
form.submit();

core/src/main/resources/lib/hudson/executors.jelly

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
THE SOFTWARE.
2424
-->
2525
<?jelly escape-by-default='true'?>
26-
<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:local="local">
26+
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
27+
xmlns:t="/lib/hudson"
28+
xmlns:local="local">
2729
<st:documentation>
2830
Displays the status of executors.
2931
<st:attribute name="computers">
@@ -176,7 +178,7 @@ THE SOFTWARE.
176178
</j:if>
177179
<st:adjunct includes="lib.form.link.link"/>
178180
<!-- TODO improve l:link so the `a` can be changed to `l:link`. -->
179-
<a class="collapse post" data-post-href="${rootURL}/toggleCollapse?paneId=executors"
181+
<a class="collapse post" href="#" data-post-href="${rootURL}/toggleCollapse?paneId=executors"
180182
tooltip="${paneIsCollapsed ? '%Expand' : '%Collapse'}" data-tooltip-append-to-parent="true">
181183
<j:set var="svgIconId" value="${paneIsCollapsed ? 'chevron-up' : 'chevron-down'}" />
182184
<l:icon src="symbol-${svgIconId}" />

core/src/main/resources/lib/layout/pane.jelly

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ THE SOFTWARE.
6161
<j:if test="${attrs.id != null}">
6262
<st:adjunct includes="lib.form.link.link"/>
6363
<!-- TODO improve l:link so the `a` can be changed to `l:link`. -->
64-
<a class="collapse post" data-post-href="${rootURL}/toggleCollapse?paneId=${attrs.id}"
64+
<a class="collapse post" href="#" data-post-href="${rootURL}/toggleCollapse?paneId=${attrs.id}"
6565
title="${paneIsCollapsed ? '%expand' : '%collapse'}">
6666

6767
<j:set var="svgIconId" value="${paneIsCollapsed ? 'chevron-up' : 'chevron-down'}" />

0 commit comments

Comments
 (0)