From a0b91768e0152aa868d3bd511066ea619c4e7aa0 Mon Sep 17 00:00:00 2001 From: Yaroslav Afenkin Date: Sat, 8 Oct 2022 16:06:34 +0300 Subject: [PATCH 1/7] Address inline js function call inside matrix.jelly --- .../resources/lib/hudson/matrix-project/matrix-resources.js | 1 + src/main/resources/lib/hudson/matrix-project/matrix.jelly | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/lib/hudson/matrix-project/matrix-resources.js diff --git a/src/main/resources/lib/hudson/matrix-project/matrix-resources.js b/src/main/resources/lib/hudson/matrix-project/matrix-resources.js new file mode 100644 index 00000000..da68bcec --- /dev/null +++ b/src/main/resources/lib/hudson/matrix-project/matrix-resources.js @@ -0,0 +1 @@ +refreshPart('matrix',"./ajaxMatrix"); diff --git a/src/main/resources/lib/hudson/matrix-project/matrix.jelly b/src/main/resources/lib/hudson/matrix-project/matrix.jelly index 5c81ab92..ed1d421e 100644 --- a/src/main/resources/lib/hudson/matrix-project/matrix.jelly +++ b/src/main/resources/lib/hudson/matrix-project/matrix.jelly @@ -99,9 +99,7 @@ THE SOFTWARE. - + From e7ee4ffe69a2ba277c664b69aa381b9419d77b83 Mon Sep 17 00:00:00 2001 From: Yaroslav Afenkin Date: Sun, 9 Oct 2022 15:19:08 +0300 Subject: [PATCH 2/7] Uninline URL building in checkUrl --- src/main/java/hudson/matrix/MatrixProject.java | 5 +++++ .../hudson/matrix/LabelAxis/label-axis-resources.js | 0 .../hudson/matrix/MatrixProject/configure-entries.jelly | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js diff --git a/src/main/java/hudson/matrix/MatrixProject.java b/src/main/java/hudson/matrix/MatrixProject.java index 7a89252f..49016e92 100644 --- a/src/main/java/hudson/matrix/MatrixProject.java +++ b/src/main/java/hudson/matrix/MatrixProject.java @@ -99,6 +99,7 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.stapler.HttpResponse; +import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; import org.kohsuke.stapler.TokenList; @@ -1083,6 +1084,10 @@ public List getAxisDescriptors() { return r; } + public FormValidation doCheckDisplayName(@QueryParameter String value, @QueryParameter String name) { + return Jenkins.get().doCheckDisplayName(value, name); + } + /** * @deprecated as of 1.456 * This was only exposed for Jelly. diff --git a/src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js b/src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js new file mode 100644 index 00000000..e69de29b diff --git a/src/main/resources/hudson/matrix/MatrixProject/configure-entries.jelly b/src/main/resources/hudson/matrix/MatrixProject/configure-entries.jelly index 39cd5c46..533b04f5 100644 --- a/src/main/resources/hudson/matrix/MatrixProject/configure-entries.jelly +++ b/src/main/resources/hudson/matrix/MatrixProject/configure-entries.jelly @@ -48,8 +48,11 @@ THE SOFTWARE. + + + - + From 90cf96fa79f9516be7925fcf814a5035c6df4f44 Mon Sep 17 00:00:00 2001 From: Yaroslav Afenkin Date: Fri, 21 Oct 2022 18:27:30 +0300 Subject: [PATCH 3/7] Uninline script in LabelAxis/config.jelly --- src/main/java/hudson/matrix/LabelAxis.java | 12 ++---- .../hudson/matrix/LabelAxis/config.jelly | 41 ++++--------------- .../matrix/LabelAxis/label-axis-resources.js | 40 ++++++++++++++++++ 3 files changed, 53 insertions(+), 40 deletions(-) diff --git a/src/main/java/hudson/matrix/LabelAxis.java b/src/main/java/hudson/matrix/LabelAxis.java index 85593d15..eae12501 100644 --- a/src/main/java/hudson/matrix/LabelAxis.java +++ b/src/main/java/hudson/matrix/LabelAxis.java @@ -24,7 +24,6 @@ package hudson.matrix; import hudson.Extension; -import hudson.Functions; import jenkins.model.Jenkins; import hudson.model.labels.LabelAtom; import org.apache.commons.lang.StringUtils; @@ -86,16 +85,13 @@ public boolean isInstantiable() { return !j.getNodes().isEmpty() || !j.clouds.isEmpty(); } - - public String buildLabelCheckBox(LabelAtom la, LabelAxis instance) { + public String buildLabelCheckBox(LabelAtom la) { final String escapedName = jsStringEscape(htmlAttributeEscape(la.getName())); final String escapedDescription = jsStringEscape(StringUtils.isEmpty(la.getDescription()) ? "" : htmlAttributeEscape(la.getDescription())); - return new StringBuilder("\"").append(jsStringEscape("\"") - .toString(); - // '${h.jsStringEscape('')}' + return ""; } } } diff --git a/src/main/resources/hudson/matrix/LabelAxis/config.jelly b/src/main/resources/hudson/matrix/LabelAxis/config.jelly index 5466e63b..01066ef2 100644 --- a/src/main/resources/hudson/matrix/LabelAxis/config.jelly +++ b/src/main/resources/hudson/matrix/LabelAxis/config.jelly @@ -28,39 +28,16 @@ THE SOFTWARE.
- +
+
diff --git a/src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js b/src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js index e69de29b..535a4e0c 100644 --- a/src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js +++ b/src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js @@ -0,0 +1,40 @@ +Behaviour.specify("DIV.labelAxis-tree", 'LabelAxis', 0, function(e) { + var tree = new YAHOO.widget.TreeView(e); + + var i18nContainer = document.querySelector(".label-axis-i18n"); + var labels = new YAHOO.widget.TextNode(i18nContainer.getAttribute("data-i18n-labels"), tree.getRoot(), false); + var machines = new YAHOO.widget.TextNode(i18nContainer.getAttribute("data-i18n-individual-nodes"), tree.getRoot(), false); + + var values = (e.getAttribute("values") || "").split("/"); + function has(v) { + return values.include(v) ? 'checked="checked" ' : ""; + } + + var labelAxisDataContainer = document.querySelector(".label-axis-data-container"); + labelAxisDataContainer.childNodes.forEach(node => { + var labelCheckbox = node.getAttribute("data-label-checkbox"); + + // inserting 'checked' attribute after ' Date: Mon, 24 Oct 2022 18:04:08 +0300 Subject: [PATCH 4/7] Address review feedback --- .../hudson/matrix/LabelAxis/label-axis-resources.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js b/src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js index 535a4e0c..4a4805e9 100644 --- a/src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js +++ b/src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js @@ -14,8 +14,9 @@ Behaviour.specify("DIV.labelAxis-tree", 'LabelAxis', 0, function(e) { labelAxisDataContainer.childNodes.forEach(node => { var labelCheckbox = node.getAttribute("data-label-checkbox"); - // inserting 'checked' attribute after ' Date: Fri, 28 Oct 2022 15:02:57 +0300 Subject: [PATCH 5/7] Remove overcomplicated `checkUrl` in MatrixProject/configure-entries.jelly --- src/main/java/hudson/matrix/MatrixProject.java | 5 +++-- .../hudson/matrix/MatrixProject/configure-entries.jelly | 5 +---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/hudson/matrix/MatrixProject.java b/src/main/java/hudson/matrix/MatrixProject.java index 49016e92..0367b93f 100644 --- a/src/main/java/hudson/matrix/MatrixProject.java +++ b/src/main/java/hudson/matrix/MatrixProject.java @@ -98,6 +98,7 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; +import org.kohsuke.stapler.AncestorInPath; import org.kohsuke.stapler.HttpResponse; import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.StaplerRequest; @@ -1084,8 +1085,8 @@ public List getAxisDescriptors() { return r; } - public FormValidation doCheckDisplayName(@QueryParameter String value, @QueryParameter String name) { - return Jenkins.get().doCheckDisplayName(value, name); + public FormValidation doCheckDisplayNameOrNull(@AncestorInPath MatrixProject job, @QueryParameter String value) { + return Jenkins.get().doCheckDisplayName(value, job.getName()); } /** diff --git a/src/main/resources/hudson/matrix/MatrixProject/configure-entries.jelly b/src/main/resources/hudson/matrix/MatrixProject/configure-entries.jelly index 533b04f5..9c6bed92 100644 --- a/src/main/resources/hudson/matrix/MatrixProject/configure-entries.jelly +++ b/src/main/resources/hudson/matrix/MatrixProject/configure-entries.jelly @@ -48,11 +48,8 @@ THE SOFTWARE. - - - - + From bd0cea24c228e4e5d300985aefcafcc3c62112ea Mon Sep 17 00:00:00 2001 From: Yaroslav Afenkin Date: Fri, 28 Oct 2022 19:23:59 +0300 Subject: [PATCH 6/7] Restrict usage of checker method --- src/main/java/hudson/matrix/MatrixProject.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/hudson/matrix/MatrixProject.java b/src/main/java/hudson/matrix/MatrixProject.java index 0367b93f..85e29cb7 100644 --- a/src/main/java/hudson/matrix/MatrixProject.java +++ b/src/main/java/hudson/matrix/MatrixProject.java @@ -1085,6 +1085,7 @@ public List getAxisDescriptors() { return r; } + @Restricted(NoExternalUse.class) public FormValidation doCheckDisplayNameOrNull(@AncestorInPath MatrixProject job, @QueryParameter String value) { return Jenkins.get().doCheckDisplayName(value, job.getName()); } From 4f1c596a210a58c1f1f9a02a89fc0f1dcd570427 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 1 Oct 2024 13:18:35 -0700 Subject: [PATCH 7/7] Fix merge --- .../resources/hudson/matrix/LabelAxis/label-axis-resources.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js b/src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js index 4a4805e9..5c4f2a55 100644 --- a/src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js +++ b/src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js @@ -7,7 +7,7 @@ Behaviour.specify("DIV.labelAxis-tree", 'LabelAxis', 0, function(e) { var values = (e.getAttribute("values") || "").split("/"); function has(v) { - return values.include(v) ? 'checked="checked" ' : ""; + return values.includes(v) ? 'checked="checked" ' : ""; } var labelAxisDataContainer = document.querySelector(".label-axis-data-container");