diff --git a/pom.xml b/pom.xml index 1d49615f..3447508a 100644 --- a/pom.xml +++ b/pom.xml @@ -88,8 +88,7 @@ io.jenkins.tools.bom - bom-2.426.x - + bom-2.452.x 3208.vb_21177d4b_cd9 import pom @@ -110,7 +109,6 @@ org.jenkins-ci.plugins bouncycastle-api - 2.30.1.78.1-248.ve27176eb_46cb_ diff --git a/src/main/resources/lib/credentials/select.jelly b/src/main/resources/lib/credentials/select.jelly index 24c76cd9..5236ea27 100644 --- a/src/main/resources/lib/credentials/select.jelly +++ b/src/main/resources/lib/credentials/select.jelly @@ -24,7 +24,7 @@ --> + xmlns:f="/lib/form" xmlns:t="/lib/hudson" xmlns:dd="/lib/layout/dropdowns"> A select control that supports the data binding and AJAX updates with support for adding credentials. Your descriptor should have the 'doFillXyzItems' method, which returns a StandardListBoxModel @@ -114,46 +114,34 @@ - -
-
-
    + - - -
  • - - - ${storeItem.displayName} - -
  • -
    - -
  • - - - ${storeItem.displayName} - -
  • -
    -
    + + +
    -
-
-
+
-
-
diff --git a/src/main/resources/lib/credentials/select/select.js b/src/main/resources/lib/credentials/select/select.js index b151e5c7..1114fb97 100644 --- a/src/main/resources/lib/credentials/select/select.js +++ b/src/main/resources/lib/credentials/select/select.js @@ -127,49 +127,14 @@ window.credentials.addSubmit = function (_) { } }; -Behaviour.specify("BUTTON.credentials-add-menu", 'credentials-select', -99, function(e) { - var btn = e; - var menu = btn.nextElementSibling; - while (menu && !menu.matches('DIV.credentials-add-menu-items')) { - menu = menu.nextElementSibling; - } - if (menu) { - var menuAlign = (btn.getAttribute("menualign") || "tl-bl"); - - var menuButton = new YAHOO.widget.Button(btn, { - type: "menu", - menu: menu, - menualignment: menuAlign.split("-"), - menuminscrollheight: 250 - }); - // copy class names - for (var i = 0; i < btn.classList.length; i++) { - menuButton._button.classList.add(btn.classList.item(i)); - } - menuButton._button.setAttribute("suffix", btn.getAttribute("suffix")); - menuButton.getMenu().clickEvent.subscribe(function (type, args, value) { - var item = args[1]; - if (item.cfg.getProperty("disabled")) { - return; - } - window.credentials.add(item.srcElement.getAttribute('data-url')); - }); - // YUI menu will not parse disabled when using DIV-LI only when using SELECT-OPTION - // but SELECT-OPTION doesn't support images, so we need to catch the rendering and roll our - // own disabled attribute support - menuButton.getMenu().beforeShowEvent.subscribe(function(type,args,value){ - var items = this.getItems(); - for (var i = 0; i < items.length; i++) { - if (items[i].srcElement.getAttribute('disabled')) { - items[i].cfg.setProperty('disabled', true); - } - } - }); - } - e=null; +Behaviour.specify("[data-type='credentials-add-store-item']", 'credentials-add-store-item', -99, function(e) { + e.addEventListener("click", function (event) { + window.credentials.add(event.target.dataset.url); + }); + e = null; }); Behaviour.specify("BUTTON.credentials-add", 'credentials-select', 0, function (e) { - makeButton(e, e.disabled ? null : window.credentials.add); + e.addEventListener("click", window.credentials.add); e = null; // avoid memory leak }); Behaviour.specify("DIV.credentials-select-control", 'credentials-select', 100, function (d) { diff --git a/src/test/java/com/cloudbees/plugins/credentials/CredentialsSelectHelperTest.java b/src/test/java/com/cloudbees/plugins/credentials/CredentialsSelectHelperTest.java index d01bd87c..5703712c 100644 --- a/src/test/java/com/cloudbees/plugins/credentials/CredentialsSelectHelperTest.java +++ b/src/test/java/com/cloudbees/plugins/credentials/CredentialsSelectHelperTest.java @@ -10,9 +10,7 @@ import org.htmlunit.html.HtmlButton; import org.htmlunit.html.HtmlForm; import org.htmlunit.html.HtmlInput; -import org.htmlunit.html.HtmlListItem; import org.htmlunit.html.HtmlPage; -import org.htmlunit.html.HtmlSpan; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; @@ -26,10 +24,15 @@ public class CredentialsSelectHelperTest { public void doAddCredentialsFromPopupWorksAsExpected() throws Exception { try (JenkinsRule.WebClient wc = j.createWebClient()) { HtmlPage htmlPage = wc.goTo("credentials-selection"); + HtmlButton addCredentialsButton = htmlPage.querySelector(".credentials-add-menu"); + // The 'click' event doesn't fire a 'mouseenter' event causing the menu not to show, so let's fire one + addCredentialsButton.fireEvent("mouseenter"); addCredentialsButton.click(); - HtmlListItem li = htmlPage.querySelector(".credentials-add-menu-items li"); - li.click(); + + HtmlButton jenkinsCredentialsOption = htmlPage.querySelector(".jenkins-dropdown__item"); + jenkinsCredentialsOption.click(); + wc.waitForBackgroundJavaScript(4000); HtmlForm form = htmlPage.querySelector("#credentials-dialog-form");