Skip to content

Commit

Permalink
[FIXED JENKINS-23160] Newly added module locations' / additional cred…
Browse files Browse the repository at this point in the history
…entials' "Add" credential button does not work

- Also changed the width of the drop-down to be auto so that the add button is more clearly associated
- Also fixed select box alignment with add button

Note:
- Root cause was f:repeatable was neither generating a new id nor re-executing the in-line script, this fixes both in one go by using Behaviour to apply the rule thus removing the need for the id on the button
  • Loading branch information
stephenc committed Aug 6, 2014
1 parent 1d374a9 commit 7c263cb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
10 changes: 3 additions & 7 deletions src/main/resources/lib/credentials/select.jelly
Expand Up @@ -44,25 +44,21 @@
</st:documentation>
<st:adjunct includes="lib.credentials.select.select"/>
<f:prepareDatabinding/>
<f:select style="width:90%" clazz="${attrs.clazz} credentials-select" field="${attrs.field}"
default="${attrs.default}"/>
<f:select clazz="${attrs.clazz} credentials-select" field="${attrs.field}" default="${attrs.default}"/>
<!-- TODO add support for checking permissions against stores in request path -->
<j:set var="buttonId" value="${h.generateId()}"/>
<st:nbsp/>
<j:choose>
<j:when test="${h.hasPermission(app.getDescriptorByName('com.cloudbees.plugins.credentials.CredentialsSelectHelper').CREATE)}">
<button id="${buttonId}" type="button" onclick="return window.credentials.add();">
<button class="credentials-add" type="button" onclick="return window.credentials.add();">
<img src="${resURL}/plugin/credentials/images/16x16/new-credential.png" alt=""/>
${%Add}
</button>
<script>(function(){var a=function(){var b=document.getElementById('${buttonId}');if(b!=null) makeButton(b, window.credentials.add)};if(document.getElementById('${buttonId}')==null) window.setTimeout(a,10); else a();})();</script>
</j:when>
<j:otherwise>
<button id="${buttonId}" type="button" disabled="disabled">
<button class="credentials-add" type="button" disabled="disabled">
<img src="${resURL}/plugin/credentials/images/16x16/new-credential.png" alt=""/>
${%Add}
</button>
<script>(function(){var a=function(){var b=document.getElementById('${buttonId}');if(b!=null) makeButton(b)};if(document.getElementById('${buttonId}')==null) window.setTimeout(a,10); else a();})();</script>
</j:otherwise>
</j:choose>
</j:jelly>
1 change: 1 addition & 0 deletions src/main/resources/lib/credentials/select/select.css
@@ -0,0 +1 @@
select.credentials-select { width: auto; vertical-align: top; }
10 changes: 8 additions & 2 deletions src/main/resources/lib/credentials/select/select.js
Expand Up @@ -16,7 +16,8 @@ window.credentials.init = function () {
window.credentials.dialog.render();
}
};
window.credentials.add = function () {
window.credentials.add = function (e) {
console.log(e);
window.credentials.init();
new Ajax.Request(rootURL + "/descriptor/com.cloudbees.plugins.credentials.CredentialsSelectHelper/dialog", {
method: 'get',
Expand Down Expand Up @@ -146,4 +147,9 @@ window.credentials.addSubmit = function (e) {
}
window.credentials.dialog.hide();
return false;
}
}
Behaviour.specify("BUTTON.credentials-add", 'select', 0, function (e) {
makeButton(e, e.disabled ? null : window.credentials.add);
e = null; // avoid memory leak
});

0 comments on commit 7c263cb

Please sign in to comment.