From 0b8a2fb05ca5766e98bfa340696eecb761b109c1 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Sun, 4 Sep 2022 23:16:41 +0100 Subject: [PATCH 1/8] Modernise --- Jenkinsfile | 7 ++-- pom.xml | 6 ++-- .../plugins/credentials/CredentialsStore.java | 19 ++++++++++- .../credentials/CredentialsStoreAction.java | 11 +----- .../concurrentModification.jelly | 2 +- .../CredentialsWrapper/delete.jelly | 2 +- .../CredentialsWrapper/index.jelly | 2 +- .../CredentialsWrapper/move.jelly | 2 +- .../CredentialsWrapper/sidepanel.jelly | 1 - .../CredentialsWrapper/sidepanel.properties | 24 ------------- .../sidepanel_de.properties | 1 - .../sidepanel_fr.properties | 1 - .../sidepanel_it.properties | 1 - .../sidepanel_ja.properties | 1 - .../CredentialsWrapper/update.jelly | 2 +- .../DomainWrapper/configure.jelly | 2 +- .../DomainWrapper/delete.jelly | 2 +- .../DomainWrapper/index.jelly | 2 +- .../DomainWrapper/sidepanel.jelly | 7 ++-- .../CredentialsStoreAction/index.jelly | 6 ++-- .../CredentialsStoreAction/newDomain.jelly | 4 +-- .../CredentialsStoreAction/sidepanel.jelly | 34 +++++++++++++++++++ .../index.jelly | 2 +- .../ViewCredentialsAction/index.jelly | 9 +++-- .../ViewCredentialsAction/index.properties | 2 +- .../UploadedKeyStoreSource/Upload/index.jelly | 2 +- 26 files changed, 82 insertions(+), 72 deletions(-) delete mode 100644 src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel.properties create mode 100644 src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/sidepanel.jelly diff --git a/Jenkinsfile b/Jenkinsfile index 033a4bab2..81318cdfb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,4 @@ buildPlugin(configurations: [ - [platform: 'linux', jdk: '8'], - [platform: 'linux', jdk: '11'], - [platform: 'windows', jdk: '11'], - ]) + [platform: 'linux', jdk: '11'], + [platform: 'windows', jdk: '11'], +]) diff --git a/pom.xml b/pom.xml index aee347eed..8f3ec0387 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ 999999-SNAPSHOT jenkinsci/${project.artifactId}-plugin - 2.340 + 2.361 8 4.9.3 @@ -89,8 +89,8 @@ io.jenkins.tools.bom - bom-2.332.x - 1246.va_b_50630c1d19 + bom-2.361.x + 1607.va_c1576527071 import pom diff --git a/src/main/java/com/cloudbees/plugins/credentials/CredentialsStore.java b/src/main/java/com/cloudbees/plugins/credentials/CredentialsStore.java index a1c1d8646..fd3626c55 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/CredentialsStore.java +++ b/src/main/java/com/cloudbees/plugins/credentials/CredentialsStore.java @@ -452,7 +452,8 @@ public String getRelativeLinkToContext() { return null; } if (context instanceof Jenkins) { - return URI.create(request.getContextPath() + "/").normalize().toString(); + String suffix = Jenkins.get().hasPermission(Jenkins.ADMINISTER) ? "/manage/" : "/"; + return URI.create(request.getContextPath() + suffix).normalize().toString(); } if (context instanceof User) { return URI.create(request.getContextPath() + "/" + ((User) context).getUrl()+"/") @@ -537,6 +538,22 @@ public final String getContextDisplayName() { } } + /** + * Resolves a display name from the Store + * @return the display name + */ + public String getDisplayName() { + Class c = this.getClass(); + while (c.getEnclosingClass() != null) { + c = c.getEnclosingClass(); + } + String name = c.getSimpleName().replaceAll("(?i)(Impl|Credentials|Provider|Store)+", ""); + if (StringUtils.isBlank(name)) { + name = c.getSimpleName(); + } + return StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(name), ' '); + } + /** * Return the {@link CredentialsStoreAction} for this store. The action will be displayed as a sub-item of the * {@link ViewCredentialsAction}. Return {@code null} if this store will take control of displaying its action diff --git a/src/main/java/com/cloudbees/plugins/credentials/CredentialsStoreAction.java b/src/main/java/com/cloudbees/plugins/credentials/CredentialsStoreAction.java index f511c9284..0f523bc64 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/CredentialsStoreAction.java +++ b/src/main/java/com/cloudbees/plugins/credentials/CredentialsStoreAction.java @@ -86,7 +86,6 @@ import net.sf.json.JSONObject; import org.acegisecurity.AccessDeniedException; import org.apache.commons.lang.StringUtils; -import org.jenkins.ui.icon.IconSet; import org.jenkins.ui.icon.IconSpec; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -240,15 +239,7 @@ public String getIconFileName() { public String getDisplayName() { CredentialsStore store = getStore(); if (this == store.getStoreAction()) { - Class c = store.getClass(); - while (c.getEnclosingClass() != null) { - c = c.getEnclosingClass(); - } - String name = c.getSimpleName().replaceAll("(?i)(Impl|Credentials|Provider|Store)+", ""); - if (StringUtils.isBlank(name)) { - name = c.getSimpleName(); - } - return StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(name), ' '); + return store.getDisplayName(); } else { return Messages.CredentialsStoreAction_DisplayName(); } diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/concurrentModification.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/concurrentModification.jelly index 71a28ceae..77c7c10d2 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/concurrentModification.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/concurrentModification.jelly @@ -29,7 +29,7 @@ - +

${%Concurrent Modification}

diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/delete.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/delete.jelly index b2e258977..186246216 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/delete.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/delete.jelly @@ -1,6 +1,6 @@ - +

${%Delete credentials}

diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/index.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/index.jelly index 692da3a1e..742b91c58 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/index.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/index.jelly @@ -28,7 +28,7 @@ --> - +

${it.displayName}

diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/move.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/move.jelly index d4898446d..f863801af 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/move.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/move.jelly @@ -1,6 +1,6 @@ - +

${%Move credentials}

diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel.jelly index 968c00207..454136c7f 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel.jelly @@ -27,7 +27,6 @@ - diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel.properties b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel.properties deleted file mode 100644 index 17177d7ad..000000000 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel.properties +++ /dev/null @@ -1,24 +0,0 @@ -# -# The MIT License -# -# Copyright (c) 2013, CloudBees, Inc.. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -backto=Back to {0} diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_de.properties b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_de.properties index f0ad91ac1..4a6f7d2f9 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_de.properties +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_de.properties @@ -21,6 +21,5 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # -backto=Zur\u00FCck zu {0} Update=Bearbeiten Delete=L\u00F6schen diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_fr.properties b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_fr.properties index 5af4342ca..cda85f7e5 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_fr.properties +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_fr.properties @@ -20,7 +20,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -backto=Revenir \u00e0 {0} Update=Mettre \u00e0 jour Delete=Supprimer Move=D\u00e9placer diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_it.properties b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_it.properties index 3a84234a9..76756ce70 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_it.properties +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_it.properties @@ -20,7 +20,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -backto=Torna a {0} Delete=Elimina Move=Sposta Update=Aggiorna diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_ja.properties b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_ja.properties index d7061892c..5f9981604 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_ja.properties +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel_ja.properties @@ -21,7 +21,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # -backto={0}\u3078\u623b\u308b Update=\u66f4\u65b0 Delete=\u524a\u9664 Move=\u79fb\u52d5 diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/update.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/update.jelly index b75f51ef0..20d8405b4 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/update.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/update.jelly @@ -29,7 +29,7 @@ - +

${%Update credentials}

diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/configure.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/configure.jelly index d9802f98a..d0dd27893 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/configure.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/configure.jelly @@ -29,7 +29,7 @@ - +

${%Update domain}

diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/delete.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/delete.jelly index 1ce2cf46d..612157b9e 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/delete.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/delete.jelly @@ -1,6 +1,6 @@ - +

${%Delete domain}

diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/index.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/index.jelly index 7bc784e9a..0e3f8c88b 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/index.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/index.jelly @@ -25,7 +25,7 @@ --> - + diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/sidepanel.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/sidepanel.jelly index d2194cedb..75338f8b5 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/sidepanel.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/sidepanel.jelly @@ -27,12 +27,11 @@ - - - + + - + diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/index.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/index.jelly index 1b218c299..c582f6ee5 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/index.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/index.jelly @@ -27,15 +27,15 @@ xmlns:f="/lib/form" xmlns:c="/lib/credentials" xmlns:t="/lib/hudson"> - +

Not found

- - + + diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/newDomain.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/newDomain.jelly index b0fccbac2..fb7e97f12 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/newDomain.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/newDomain.jelly @@ -25,8 +25,8 @@ - - + +

${%New domain}

diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/sidepanel.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/sidepanel.jelly new file mode 100644 index 000000000..b90e5dd80 --- /dev/null +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/sidepanel.jelly @@ -0,0 +1,34 @@ + + + + + + + + + + + + diff --git a/src/main/resources/com/cloudbees/plugins/credentials/GlobalCredentialsConfiguration/index.jelly b/src/main/resources/com/cloudbees/plugins/credentials/GlobalCredentialsConfiguration/index.jelly index bad6787cd..e9412e42f 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/GlobalCredentialsConfiguration/index.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/GlobalCredentialsConfiguration/index.jelly @@ -25,7 +25,7 @@ --> - +

${it.displayName}

diff --git a/src/main/resources/com/cloudbees/plugins/credentials/ViewCredentialsAction/index.jelly b/src/main/resources/com/cloudbees/plugins/credentials/ViewCredentialsAction/index.jelly index cc9186060..8137dbf4b 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/ViewCredentialsAction/index.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/ViewCredentialsAction/index.jelly @@ -25,8 +25,7 @@ --> - - +