From d9ed87e4cbd72b4d0872bdc96887fa0f5a1f94c5 Mon Sep 17 00:00:00 2001 From: Dmitry_Platonov Date: Thu, 30 May 2024 09:33:52 +0300 Subject: [PATCH 1/7] [JENKINS-72854] UX improvement: make pod templates readonly from UI for NonConfigurableKubernetesCloud --- .../NonConfigurableKubernetesCloud.java | 10 ++ .../plugins/kubernetes/PodTemplate.java | 10 ++ .../kubernetes/PodTemplate/config.jelly | 169 +++++++++--------- .../kubernetes/PodTemplate/index.jelly | 8 +- .../kubernetes/PodTemplate/sidepanel.jelly | 4 +- src/main/webapp/css/custom-style.css | 3 + 6 files changed, 119 insertions(+), 85 deletions(-) create mode 100644 src/main/webapp/css/custom-style.css diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/NonConfigurableKubernetesCloud.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/NonConfigurableKubernetesCloud.java index c84c11ad6f..4e9dc06149 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/NonConfigurableKubernetesCloud.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/NonConfigurableKubernetesCloud.java @@ -5,6 +5,8 @@ import hudson.model.Descriptor; import hudson.model.DescriptorVisibilityFilter; import hudson.slaves.Cloud; +import java.util.List; +import java.util.stream.Collectors; import jenkins.model.Jenkins; import net.sf.json.JSONObject; import org.kohsuke.stapler.StaplerRequest; @@ -28,6 +30,14 @@ public Cloud reconfigure(@NonNull StaplerRequest req, JSONObject form) throws De return DescriptorImpl.class.cast(getDescriptor()).newInstance(req, form); } + @NonNull + @Override + public List getTemplates() { + return super.getTemplates().stream() + .peek(podTemplate -> podTemplate.setReadonlyFromUi(true)) + .collect(Collectors.toList()); + } + @Extension public static class FilterImpl extends DescriptorVisibilityFilter { @Override diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java index 99dc267ec1..9281221d27 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java @@ -190,6 +190,8 @@ protected static MessageDigest getLabelDigestFunction() { */ private transient List yamls; + private transient boolean readonlyFromUi; + @NonNull public String getId() { return id; @@ -1049,6 +1051,14 @@ private void optionalField(StringBuilder builder, String label, String value) { @Override public void save() {} + public boolean isReadonlyFromUi() { + return readonlyFromUi; + } + + public void setReadonlyFromUi(boolean readonlyFromUi) { + this.readonlyFromUi = readonlyFromUi; + } + @Extension public static class DescriptorImpl extends Descriptor { diff --git a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/config.jelly b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/config.jelly index a39c09c730..9b19ac3b74 100644 --- a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/config.jelly +++ b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/config.jelly @@ -21,113 +21,120 @@ THE SOFTWARE. - - - + + + + This Pod template is associated with a non-configurable cloud setup. + +
+ + + + + + + - - - + + + - - - + + + - - - + + ${it.description} + - - ${it.description} - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + - + + + - - - + + + - - - + + + - - - + + + - - - + - + + + - - + + - - - - - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - + - + +
diff --git a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly index bd2562ff0f..b5f9fd1743 100644 --- a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly +++ b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly @@ -34,9 +34,11 @@ THE SOFTWARE. - - - + + + + + diff --git a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/sidepanel.jelly b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/sidepanel.jelly index fd21032463..b31b8e19e2 100644 --- a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/sidepanel.jelly +++ b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/sidepanel.jelly @@ -24,7 +24,9 @@ THE SOFTWARE. - + + + diff --git a/src/main/webapp/css/custom-style.css b/src/main/webapp/css/custom-style.css new file mode 100644 index 0000000000..ad997d87a8 --- /dev/null +++ b/src/main/webapp/css/custom-style.css @@ -0,0 +1,3 @@ +.readonly-block { + pointer-events: none; +} \ No newline at end of file From 9dc33046708bc0e7e50e470bf706919c21ab8402 Mon Sep 17 00:00:00 2001 From: Dmitry_Platonov Date: Thu, 30 May 2024 15:15:52 +0300 Subject: [PATCH 2/7] [JENKINS-72854] use readOnlyMode to make pod templates readonly from UI for NonConfigurableKubernetesCloud --- .../jenkins/plugins/kubernetes/PodTemplate/config.jelly | 7 ------- .../jenkins/plugins/kubernetes/PodTemplate/index.jelly | 4 ++++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/config.jelly b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/config.jelly index 9b19ac3b74..e9c0b37783 100644 --- a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/config.jelly +++ b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/config.jelly @@ -21,12 +21,6 @@ THE SOFTWARE. - - - - This Pod template is associated with a non-configurable cloud setup. - -
@@ -135,6 +129,5 @@ THE SOFTWARE. -
diff --git a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly index b5f9fd1743..a7ecb41484 100644 --- a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly +++ b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly @@ -29,6 +29,10 @@ THE SOFTWARE. + + + This Pod template is associated with a non-configurable cloud setup. + From 73417f1f0abff94efe8931e8e5c85c99007b5abf Mon Sep 17 00:00:00 2001 From: Dmitry_Platonov Date: Fri, 31 May 2024 15:13:42 +0300 Subject: [PATCH 3/7] [JENKINS-72854] revert diff in config jelly --- .../kubernetes/PodTemplate/config.jelly | 162 +++++++++--------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/config.jelly b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/config.jelly index e9c0b37783..a39c09c730 100644 --- a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/config.jelly +++ b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/config.jelly @@ -21,113 +21,113 @@ THE SOFTWARE. - - - + + + - - - + + + - - - + + + - - - + + + - - ${it.description} - + + ${it.description} + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - + - - - + + + - - - + + + - - - - - - - + + + - + + + - - - + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + + + + + - + - + From e7a24f472f0eceff451848e7e71bb3ce312b9e02 Mon Sep 17 00:00:00 2001 From: Dmitry_Platonov Date: Fri, 31 May 2024 15:28:22 +0300 Subject: [PATCH 4/7] [JENKINS-72854] remove redundant css file --- src/main/webapp/css/custom-style.css | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 src/main/webapp/css/custom-style.css diff --git a/src/main/webapp/css/custom-style.css b/src/main/webapp/css/custom-style.css deleted file mode 100644 index ad997d87a8..0000000000 --- a/src/main/webapp/css/custom-style.css +++ /dev/null @@ -1,3 +0,0 @@ -.readonly-block { - pointer-events: none; -} \ No newline at end of file From 131fc4c6247e472738e9194b6b6816c9ae2d68f7 Mon Sep 17 00:00:00 2001 From: Dmitry Platonov <47667812+Pldi23@users.noreply.github.com> Date: Tue, 4 Jun 2024 08:19:08 +0300 Subject: [PATCH 5/7] Update src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly Co-authored-by: Vincent Latombe --- .../jenkins/plugins/kubernetes/PodTemplate/index.jelly | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly index a7ecb41484..539a5018e4 100644 --- a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly +++ b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly @@ -29,8 +29,8 @@ THE SOFTWARE. - - + + This Pod template is associated with a non-configurable cloud setup. From 39ef859f6b4781db9e826af0a7987b1da95908fb Mon Sep 17 00:00:00 2001 From: Dmitry Platonov <47667812+Pldi23@users.noreply.github.com> Date: Tue, 4 Jun 2024 08:19:21 +0300 Subject: [PATCH 6/7] Update src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly Co-authored-by: Vincent Latombe --- .../csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly index 539a5018e4..d06741494f 100644 --- a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly +++ b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/index.jelly @@ -38,7 +38,7 @@ THE SOFTWARE. - + From 6c8c64392ee7c3ece89a38334ce043d9041615a9 Mon Sep 17 00:00:00 2001 From: Dmitry Platonov <47667812+Pldi23@users.noreply.github.com> Date: Tue, 4 Jun 2024 08:19:32 +0300 Subject: [PATCH 7/7] Update src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/sidepanel.jelly Co-authored-by: Vincent Latombe --- .../jenkins/plugins/kubernetes/PodTemplate/sidepanel.jelly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/sidepanel.jelly b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/sidepanel.jelly index b31b8e19e2..a6a21f0681 100644 --- a/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/sidepanel.jelly +++ b/src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/sidepanel.jelly @@ -24,7 +24,7 @@ THE SOFTWARE. - +