-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
92 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/resources/com/cloudbees/plugins/credentials/common/formBehaviour.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Behaviour.specify(".required-for-submit", 'required-for-submit', -99, function(requiredField) { | ||
const saveButton = requiredField.closest("form").querySelector('[name="Submit"]'); | ||
function updateSave() { | ||
const state = requiredField.value.length === 0; | ||
saveButton.disabled = state; | ||
} | ||
requiredField.addEventListener('input', updateSave); | ||
updateSave(saveButton); | ||
}); | ||
|
||
Behaviour.specify(".autofocus", "autofocus", 0, function(el) { | ||
el.focus(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...lugins/credentials/impl/CertificateCredentialsImpl/UploadedKeyStoreSource/configUpload.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// multiple objects named "password" in the form => | ||
// extend findNearBy to allow selecting by id | ||
if (!findNearBy.patched) { | ||
var oldNearBy = findNearBy; | ||
findNearBy = function(el, name) { | ||
return name.charAt(0) == '#' ? document.querySelector(name.split('/')[0]) : oldNearBy(el, name); | ||
} | ||
findNearBy.patched = true; | ||
} | ||
|
||
Behaviour.specify(".certificate-file-upload", 'certificate-file-upload', -99, function(uploadedCertFileInput) { | ||
// Adding a onChange method on the file input to retrieve the value of the file content in a variable | ||
var fileId = uploadedCertFileInput.id; | ||
var _onchange = uploadedCertFileInput.onchange; | ||
if (typeof _onchange === "function") { | ||
uploadedCertFileInput.onchange = function() { fileOnChange(this); _onchange.call(this); } | ||
} else { | ||
uploadedCertFileInput.onchange = fileOnChange.bind(uploadedCertFileInput); | ||
} | ||
const base64field = uploadedCertFileInput.closest('.radioBlock-container').querySelector('[name="certificateBase64"]'); | ||
function fileOnChange() { | ||
try { // inspired by https://stackoverflow.com/a/754398 | ||
var uploadedCertFileInputFile = uploadedCertFileInput.files[0]; | ||
var reader = new FileReader(); | ||
reader.onload = function (evt) { | ||
base64field.value = btoa(evt.target.result); | ||
var uploadedKeystore = document.getElementById(fileId + "-textbox"); | ||
uploadedKeystore.onchange(uploadedKeystore); | ||
} | ||
reader.onerror = function (evt) { | ||
if (window.console !== null) { | ||
console.warn("Error during loading uploadedCertFile content", evt); | ||
} | ||
uploadedCertFile[fileId] = ''; | ||
} | ||
|
||
reader.readAsBinaryString(uploadedCertFileInputFile); | ||
} | ||
catch(e){ | ||
if (window.console !== null) { | ||
console.warn("Unable to retrieve uploadedCertFile content"); | ||
} | ||
} | ||
} | ||
|
||
// workaround for JENKINS-19124 | ||
// without this script, the password changes will be not trigger the check on the uploadedKeystore | ||
var r = window.document.getElementById(fileId + "-textbox"); | ||
var p = findNextFormItem(r, 'password'); | ||
if (p) { | ||
const dependsOn = r.getAttribute('checkDependsOn'); | ||
if (!dependsOn.includes(p.id)) { | ||
r.setAttribute('checkDependsOn', dependsOn + ' #' + p.id + "/password"); | ||
} | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters