diff --git a/pom.xml b/pom.xml index 05e2fdb4f..f2ba01b4d 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ 999999-SNAPSHOT jenkinsci/${project.artifactId}-plugin - 2.387.3 + 2.426.3 @@ -87,8 +87,8 @@ io.jenkins.tools.bom - bom-2.387.x - 2483.v3b_22f030990a_ + bom-2.426.x + 2839.v003b_4d9d24fd import pom diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsSelectHelper/WrappedCredentialsStore/dialog.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsSelectHelper/WrappedCredentialsStore/dialog.jelly index 3a1a60c97..d23ecaea6 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsSelectHelper/WrappedCredentialsStore/dialog.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsSelectHelper/WrappedCredentialsStore/dialog.jelly @@ -25,29 +25,20 @@ - - ${it.description}: ${it.displayName} - - - ${%Add Credentials} - - - - - - ${domain.value.displayName} - - - - - - - - - - - - + + + ${%Add Credentials} + + + + ${domain.value.displayName} + + + + + + + diff --git a/src/main/resources/lib/credentials/dialog.js b/src/main/resources/lib/credentials/dialog.js deleted file mode 100644 index 56a18a39f..000000000 --- a/src/main/resources/lib/credentials/dialog.js +++ /dev/null @@ -1,7 +0,0 @@ -Behaviour.specify("#credentials-add-submit", 'credentials-dialog-add', 0, function (e) { - e.onclick = (_) => window.credentials.addSubmit(e); -}); - -Behaviour.specify("#credentials-add-abort", 'credentials-dialog-abort', 0, function (e) { - e.onclick = (_) => window.credentials.dialog.hide(); -}); \ No newline at end of file diff --git a/src/main/resources/lib/credentials/select.jelly b/src/main/resources/lib/credentials/select.jelly index 1bc67267c..f0650adef 100644 --- a/src/main/resources/lib/credentials/select.jelly +++ b/src/main/resources/lib/credentials/select.jelly @@ -65,7 +65,6 @@ - diff --git a/src/main/resources/lib/credentials/select/select.css b/src/main/resources/lib/credentials/select/select.css index 543d5f4ad..776d18587 100644 --- a/src/main/resources/lib/credentials/select/select.css +++ b/src/main/resources/lib/credentials/select/select.css @@ -1,6 +1,5 @@ select.credentials-select { width:auto; vertical-align: top; } div.credentials-select-content-inactive { display:none; } -div#credentialsDialog {overflow-y: scroll;} body.masked {overflow-y: hidden;} div.include-user-credentials { padding: 0.2em; } /* adapted from Jenkins' style.css */ diff --git a/src/main/resources/lib/credentials/select/select.js b/src/main/resources/lib/credentials/select/select.js index a5f44aa2a..ba46a696e 100644 --- a/src/main/resources/lib/credentials/select/select.js +++ b/src/main/resources/lib/credentials/select/select.js @@ -28,22 +28,6 @@ window.credentials.init = function () { document.body.appendChild(div); div.innerHTML = ""; window.credentials.body = document.getElementById('credentialsDialog'); - window.credentials.dialog = new YAHOO.widget.Panel(window.credentials.body, { - fixedcenter: true, - close: true, - draggable: true, - zindex: 1000, - modal: true, - visible: false, - keylisteners: [ - new YAHOO.util.KeyListener(document, {keys:27}, { - fn:(function() {window.credentials.dialog.hide();}), - scope:document, - correctScope:false - }) - ] - }); - window.credentials.dialog.render(); } }; window.credentials.add = function (e) { @@ -54,15 +38,15 @@ window.credentials.add = function (e) { }).then(rsp => { if (rsp.ok) { rsp.text().then((responseText) => { + // do not apply behaviour on parsed HTML, dialog.form does that later + // otherwise we have crumb and json fields twice window.credentials.body.innerHTML = responseText; - Behaviour.applySubtree(window.credentials.body, false); window.credentials.form = document.getElementById('credentials-dialog-form'); - // window.credentials.form.action = e; - var r = YAHOO.util.Dom.getClientRegion(); - window.credentials.dialog.cfg.setProperty("width", r.width * 3 / 4 + "px"); - window.credentials.dialog.cfg.setProperty("height", r.height * 3 / 4 + "px"); - window.credentials.dialog.center(); - window.credentials.dialog.show(); + const data = window.credentials.form.dataset; + const options = {'title': data['title'], 'okText': data['add'], 'submitButton':false, 'minWidth': '75vw'}; + dialog.form(window.credentials.form, options) + .then(window.credentials.addSubmit); + window.credentials.form.querySelector('select').focus(); }); } }); @@ -109,9 +93,6 @@ window.credentials.refreshAll = function () { if (window.console != null) { console.warn("Unable to find nearby " + name); } - if (window.YUI != null) { - YUI.log("Unable to find a nearby control of the name " + name, "warn") - } return; } deps.push({name: Path.tail(name), control: c}); @@ -121,9 +102,12 @@ window.credentials.refreshAll = function () { }); }; window.credentials.addSubmit = function (_) { - const form = document.getElementById('credentials-dialog-form'); + const form = window.credentials.form; + // temporarily attach to DOM (avoid https://github.com/HtmlUnit/htmlunit/issues/740) + document.body.appendChild(form); buildFormTree(form); ajaxFormSubmit(form); + form.remove(); function ajaxFormSubmit(form) { fetch(form.action, { @@ -140,9 +124,6 @@ window.credentials.addSubmit = function (_) { // notificationBar.show(...) with logging ID could be handy here? console.error("Could not add credentials:", e); }) - .finally(() => { - window.credentials.dialog.hide(); - }); } }; diff --git a/src/test/java/com/cloudbees/plugins/credentials/CredentialsSelectHelperTest.java b/src/test/java/com/cloudbees/plugins/credentials/CredentialsSelectHelperTest.java index b2e5515dd..d01bd87cb 100644 --- a/src/test/java/com/cloudbees/plugins/credentials/CredentialsSelectHelperTest.java +++ b/src/test/java/com/cloudbees/plugins/credentials/CredentialsSelectHelperTest.java @@ -31,7 +31,7 @@ public void doAddCredentialsFromPopupWorksAsExpected() throws Exception { HtmlListItem li = htmlPage.querySelector(".credentials-add-menu-items li"); li.click(); wc.waitForBackgroundJavaScript(4000); - HtmlForm form = htmlPage.querySelector("#credentialsDialog form"); + HtmlForm form = htmlPage.querySelector("#credentials-dialog-form"); HtmlInput username = form.querySelector("input[name='_.username']"); username.setValue("bob"); @@ -40,7 +40,7 @@ public void doAddCredentialsFromPopupWorksAsExpected() throws Exception { HtmlInput id = form.querySelector("input[name='_.id']"); id.setValue("test"); - HtmlSpan formSubmitButton = form.querySelector("#credentials-add-submit"); + HtmlButton formSubmitButton = htmlPage.querySelector(".jenkins-button[data-id='ok']"); formSubmitButton.fireEvent("click"); wc.waitForBackgroundJavaScript(5000);