Skip to content

Commit

Permalink
[JENKINS-60866] Advanced button, build health, confirmation link, URI…
Browse files Browse the repository at this point in the history
… encoding monitor (#5515)

Co-authored-by: Daniel Beck <daniel-beck@users.noreply.github.com>
  • Loading branch information
daniel-beck and daniel-beck committed Nov 4, 2021
1 parent c9926fe commit 791447a
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Behaviour.specify('#URICheckEncodingMonitor-message', 'URICheckEncodingMonitor', 0, function(element) {
var url = element.getAttribute('data-url');
var params = {value : '\u57f7\u4e8b'};
var checkAjax = new Ajax.Updater(
'URICheckEncodingMonitor-message', url,
{
method: 'get', parameters: params
}
);
});
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
<?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">
<j:if test="${it.checkEnabled}">
<script>
var url="${rootURL}/${it.url}/checkURIEncoding";
var params = {value : '\u57f7\u4e8b'};
var checkAjax = new Ajax.Updater(
'message', url,
{
method: 'get', parameters: params
}
);
</script>
<span id="message"></span>
<div id="URICheckEncodingMonitor-message" data-url="${rootURL}/${it.url}/checkURIEncoding"/>
<st:adjunct includes="jenkins.diagnostics.URICheckEncodingMonitor.adjunct"/>
</j:if>
</j:jelly>
11 changes: 1 addition & 10 deletions core/src/main/resources/lib/form/advanced.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,7 @@ THE SOFTWARE.
<d:invokeBody/>
</div></div>
<j:if test="${!customizedFields.isEmpty()}">
<script>
{
var span = $$('${id}');
if (span != null) {
span.style.display = '';
} else if (console &amp;&amp; console.log) {
console.log('no element ${id} for ${customizedFields}');
}
}
</script>
<div class="advanced-customized-fields-info" data-id="${id}" data-customized-fields="${customizedFields}"/>
</j:if>
</div>
</j:jelly>
11 changes: 11 additions & 0 deletions core/src/main/resources/lib/form/advanced/advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,14 @@ Behaviour.specify("INPUT.advanced-button", 'advanced', 0, function(e) {
});
e = null; // avoid memory leak
});

Behaviour.specify('.advanced-customized-fields-info', 'advanced', 0, function(element) {
var id = element.getAttribute('data-id');
var span = $(id)
if (span != null) {
span.style.display = '';
} else if (console && console.log) {
var customizedFields = element.getAttribute('data-customized-fields');
console.log('no element ' + id + ' for ' + customizedFields);
}
});
6 changes: 3 additions & 3 deletions core/src/main/resources/lib/form/validateButton.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ THE SOFTWARE.
</st:documentation>
<f:entry>
<div style="float:right">
<input type="button" value="${title}" class="yui-button validate-button ${attrs.clazz}"
<input type="button" value="${title}" class="yui-button validate-button ${attrs.clazz} Behaviour-validateButton"
data-validate-button-descriptor-url="${descriptor.descriptorFullUrl}"
data-validate-button-method="${method}"
data-validate-button-with="${with}"
onclick="safeValidateButton(this)" />
data-validate-button-with="${with}" />
</div>
<div style="display:none;">
<img src="${imagesURL}/spinner.gif" /> ${attrs.progress}
</div>
<div><!-- this is where the error message goes --></div>
<st:adjunct includes="lib.form.validateButton.adjunct"/>
</f:entry>
</j:jelly>
3 changes: 3 additions & 0 deletions core/src/main/resources/lib/form/validateButton/adjunct.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Behaviour.specify('.Behaviour-validateButton', 'Behaviour-validateButton', 0, function(element) {
element.onclick = function() { safeValidateButton(this); };
});
3 changes: 0 additions & 3 deletions core/src/main/resources/lib/hudson/buildHealth.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ THE SOFTWARE.
<x:element name="${useTdElement!=null?'td':'div'}">
<x:attribute name="data">${buildHealth.score}</x:attribute>
<x:attribute name="class">healthReport</x:attribute>
<x:attribute name="onmouseover">this.className='healthReport hover';return true;
</x:attribute>
<x:attribute name="onmouseout">this.className='healthReport';return true;</x:attribute>
<j:if test="${buildHealth!=null}">
<j:if test="${iconSizeClass == null}">
<j:choose>
Expand Down
19 changes: 2 additions & 17 deletions core/src/main/resources/lib/layout/confirmationLink.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,6 @@ THE SOFTWARE.
A CSS class to use to style the link.
</st:attribute>
</st:documentation>
<j:set var="id" value="${h.generateId()}"/>
<a href="#" class="${class}" onclick="confirmPOST_${id}(${post ? 'true' : 'false'}, '${h.jsStringEscape(attrs.href)}', '${h.jsStringEscape(message)}')"><d:invokeBody/></a>
<script>
function confirmPOST_${id}(post, href, message) {
if (confirm(message)) {
var form = document.createElement('form');
form.setAttribute('method', post ? 'POST' : 'GET');
form.setAttribute('action', href);
if (post) {
crumb.appendToForm(form);
}
document.body.appendChild(form);
form.submit();
}
return false;
}
</script>
<a href="#" class="${class} confirmation-link" data-post="${post}" data-url="${attrs.href}" data-message="${message}"><d:invokeBody/></a>
<st:adjunct includes="lib.layout.confirmationLink.adjunct "/>
</j:jelly>
18 changes: 18 additions & 0 deletions core/src/main/resources/lib/layout/confirmationLink/adjunct.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Behaviour.specify("A.confirmation-link", 'confirmation-link', 0, function (element) {
element.onclick = function(event) {
var post = element.getAttribute('data-post');
var href = element.getAttribute('data-url');
var message = element.getAttribute('data-message');
if (confirm(message)) {
var form = document.createElement('form');
form.setAttribute('method', (post === "true") ? 'POST' : 'GET');
form.setAttribute('action', href);
if (post) {
crumb.appendToForm(form);
}
document.body.appendChild(form);
form.submit();
}
return false;
};
});
2 changes: 1 addition & 1 deletion test/src/test/java/hudson/model/ManagementLinkTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void links() throws Exception {

for (int i=0; ; i++) {
HtmlPage page = wc.goTo("manage");
List<?> anchors = DomNodeUtil.selectNodes(page, "//div[contains(@class,'jenkins-section__item')]/a[not(@onclick)]");
List<?> anchors = DomNodeUtil.selectNodes(page, "//div[contains(@class,'jenkins-section__item')]/a[not(contains(@class,'confirmation-link'))]");
assertTrue(anchors.size()>=8);
if (i==anchors.size()) return; // done

Expand Down
3 changes: 0 additions & 3 deletions test/src/test/java/lib/layout/ConfirmationLinkTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ private void checkRegularCasePost(TestRootAction testParams) throws Exception {
testParams.paramPost = "true";
assertMethodPostAfterClick();

testParams.paramPost = "TruE";
assertMethodPostAfterClick();

testParams.paramPost = false;
assertMethodGetAfterClick();

Expand Down

0 comments on commit 791447a

Please sign in to comment.