Skip to content

Commit

Permalink
Using class name instead of ids
Browse files Browse the repository at this point in the history
  • Loading branch information
PereBueno committed Jul 24, 2024
1 parent 9e7db13 commit fd99628
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:entry title="${%Key}" field="privateKey">
<f:secretTextarea checkMethod="post" id="sshCredentials_privateKey"/>
<f:textarea checkMethod="post" class="sshCredentials_privateKey"/>
</f:entry>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<f:hetero-radio field="privateKeySource" descriptors="${descriptor.privateKeySources}"/>
</f:entry>
<f:entry title="${%Passphrase}" field="passphrase">
<f:password id="sshCredentials_passphrase"/>
<f:password clazz="sshCredentials_passphrase"/>
</f:entry>
<st:adjunct includes="com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey.passphraseChangeEvent" />
</j:jelly>
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
//TODO: this snippet, as well as ids in passphrase and private key fields can be removed once https://issues.jenkins.io/browse/JENKINS-65616 is completed
var passphraseElement = document.getElementById('sshCredentials_passphrase');
var privateKeyElement = document.getElementById('sshCredentials_privateKey');
const passphraseElements = document.getElementsByClassName('sshCredentials_passphrase');

passphraseElement.addEventListener("change", event => {
var newEvent = new Event("change")
privateKeyElement.dispatchEvent(newEvent)
})
if (passphraseElements.length > 0) {
// Failsafe in case there's more than 1 element we'll only use the first one. Should not happen.
passphraseElements[0].addEventListener("change", event => {
var newEvent = new Event("change")
const privateKeyElements = document.getElementsByClassName('sshCredentials_privateKey');
if (passphraseElements.length > 0) {
privateKeyElements[0].dispatchEvent(newEvent)
}
})
}

0 comments on commit fd99628

Please sign in to comment.