From a7857161c7a7c4ae2639966f1792cc60eb262061 Mon Sep 17 00:00:00 2001 From: Jan Faracik <43062514+janfaracik@users.noreply.github.com> Date: Mon, 15 Jul 2024 23:03:23 +0100 Subject: [PATCH 1/5] Init --- pom.xml | 2 +- .../resources/lib/credentials/select.jelly | 68 ++++++++----------- .../lib/credentials/select/select.js | 48 ++----------- 3 files changed, 36 insertions(+), 82 deletions(-) diff --git a/pom.xml b/pom.xml index cbb2f197..fa046b7a 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ 999999-SNAPSHOT jenkinsci/${project.artifactId}-plugin - 2.426.3 + 2.452.3 diff --git a/src/main/resources/lib/credentials/select.jelly b/src/main/resources/lib/credentials/select.jelly index f0650ade..086054ac 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 @@ -112,48 +112,36 @@ checkMethod="${attrs.checkMethod}"/> - - - -
-
-
    - - - -
  • - - - ${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 ba46a696..c4d96191 100644 --- a/src/main/resources/lib/credentials/select/select.js +++ b/src/main/resources/lib/credentials/select/select.js @@ -32,6 +32,7 @@ window.credentials.init = function () { }; window.credentials.add = function (e) { window.credentials.init(); + console.log(e); fetch(e, { method: 'GET', headers: crumb.wrap({}), @@ -127,49 +128,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-test-thing']", 'credentials-test-thing', -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) { From 77a5082285398e3f4a2b14a2b13692ee6d9d90c5 Mon Sep 17 00:00:00 2001 From: Jan Faracik <43062514+janfaracik@users.noreply.github.com> Date: Mon, 15 Jul 2024 23:08:24 +0100 Subject: [PATCH 2/5] Push --- .../resources/lib/credentials/select.jelly | 50 +++++++++---------- .../lib/credentials/select/select.js | 1 - 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/main/resources/lib/credentials/select.jelly b/src/main/resources/lib/credentials/select.jelly index 086054ac..9c69b53e 100644 --- a/src/main/resources/lib/credentials/select.jelly +++ b/src/main/resources/lib/credentials/select.jelly @@ -112,36 +112,36 @@ checkMethod="${attrs.checkMethod}"/> - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + - - + +
diff --git a/src/main/resources/lib/credentials/select/select.js b/src/main/resources/lib/credentials/select/select.js index c4d96191..dc9fdff4 100644 --- a/src/main/resources/lib/credentials/select/select.js +++ b/src/main/resources/lib/credentials/select/select.js @@ -32,7 +32,6 @@ window.credentials.init = function () { }; window.credentials.add = function (e) { window.credentials.init(); - console.log(e); fetch(e, { method: 'GET', headers: crumb.wrap({}), From e393335b995c59d4e050084a0d17f147b17b4007 Mon Sep 17 00:00:00 2001 From: Jan Faracik <43062514+janfaracik@users.noreply.github.com> Date: Wed, 17 Jul 2024 09:48:34 +0100 Subject: [PATCH 3/5] Update select.jelly --- src/main/resources/lib/credentials/select.jelly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/lib/credentials/select.jelly b/src/main/resources/lib/credentials/select.jelly index 9c69b53e..0eddaf46 100644 --- a/src/main/resources/lib/credentials/select.jelly +++ b/src/main/resources/lib/credentials/select.jelly @@ -117,7 +117,7 @@ + clazz="jenkins-!-margin-top-2 credentials-add-menu">