Skip to content

UI renovation #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 11, 2024
Merged

UI renovation #506

merged 9 commits into from
Mar 11, 2024

Conversation

mawinter69
Copy link
Contributor

@mawinter69 mawinter69 commented Feb 24, 2024

Adjust all UI elements to use styling consistent with current Jenkins
This affects all tables, input fields, checkboxes, icons, buttons, ...
Follow guidelines from the design library and remove any backlinks in the sidebar
Use ionicons where possible
Only use Jenkins defined color names to ensure compatibility with dark theme

remove blockwrapper for compatibility with old Jenkins

remove some validation methods for integer values that can be covered by using f:number instead of f:textbox

reimplement the gerrit-server table with modern javascript (removes the old YUI related things). This requires to disable the jslint4jvava (10 year old version) as this doesn't understand modern js (e.g. no template literals, params with default values, const and let)

extract inline style definitions to separate css

remove inline javascript (onClick attribute of td) by using Behaviour.specify
checkurl without inline js

ScreenShots After Search: ![image](https://github.com/jenkinsci/gerrit-trigger-plugin/assets/17767050/2a163e21-067f-4354-911c-847188d3f7fc) ![image](https://github.com/jenkinsci/gerrit-trigger-plugin/assets/17767050/965d1b09-6ac3-400d-968d-b0eee0c19414)

Gerrit Management:
image

Gerrit Server:
image
image
image

Diagnostics:
image
image
image

Project Trigger configuration:
image
image

Testing done

Manual testing of UI

### Submitter checklist
- [x] Make sure you are opening from a **topic/feature/bugfix branch** (right side) and not your main branch!
- [x] Ensure that the pull request title represents the desired changelog entry
- [x] Please describe what you did
- [ ] Link to relevant issues in GitHub or Jira
- [ ] Link to relevant pull requests, esp. upstream and downstream changes
- [ ] Ensure you have provided tests - that demonstrates feature works or fixes the issue

Adjust all UI elements to use styling consistent with current Jenkins
This affects all tables, input fields, checkboxes, icons, buttons, ...
Follow guidelines from the design library and remove any backlinks in
the sidebar
Use ionicons where possible
only use Jenkins defined color names to ensure compatibility with dark
theme

remove blockwrapper for compatibility with old Jenkins

remove some validation methods for integer values that can be covered
by using f:number instead of f:textbox

reimplement the gerrit-server table with modern javascript (removes the
old YUI related things). This requires to disable the jslint4jvava (10
year old version) as this doesn't understand modern js (e.g. no template
literals, params with default values)

extract inline style definitions to separate css

remove inline javascript (onClick attribute of td) by using
Behaviour.specify
avoid undefined when not connected
readd skipVote name
htmlunit doesn't understand default values for js methods
jelly escape by default
@panicking
Copy link
Contributor

@mawinter69 Really nice. I found out two codestyle violation on the patcheset that I have fixed locally

@panicking
Copy link
Contributor

@mawinter69 the UI let me lost my server configuratoin that does not appear anymore

@panicking
Copy link
Contributor

panicking commented Feb 24, 2024

Please apply those fix

diff --git a/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/diagnostics/Diagnostics.java b/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/diagnostics/Diagnostics.java
index 00bc61b0..9363699f 100644
--- a/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/diagnostics/Diagnostics.java
+++ b/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/diagnostics/Diagnostics.java
@@ -88,8 +88,9 @@ public class Diagnostics implements ModelObjectWithChildren, ModelObjectWithCont
                          .withIconClass("symbol-clipboard-outline plugin-ionicons-api")
                          .withDisplayName(Messages.EventListenersReport_DisplayName()));
         if (isDebugMode()) {
-            MenuItem item = new MenuItem().withUrl("triggerDebugEvent").withIconClass("symbol-warning plugin-ionicons-api")
-                .withDisplayName("Trigger Debug");
+            MenuItem item = new MenuItem()
+                                    .withUrl("triggerDebugEvent").withIconClass("symbol-warning plugin-ionicons-api")
+                                    .withDisplayName("Trigger Debug");
             item.requiresConfirmation = true;
             menu.add(item);
         }
diff --git a/src/main/webapp/js/server-table.js b/src/main/webapp/js/server-table.js
index ff90c209..1a69dd42 100644
--- a/src/main/webapp/js/server-table.js
+++ b/src/main/webapp/js/server-table.js
@@ -30,9 +30,9 @@ function refreshServerTable() {
         return icons.content.querySelector(`#${name}`).cloneNode(true);
     }
 
-    function createLink(url, icon, tagName, callback, disabled) {
+    function createLink(url, icon, tagName, callback, disable) {
         tagName = tagName == null ? 'a' : tagName;
-        disabled = disable == null ? false : disabled;
+        disabled = disable == null ? false : disable;
         const td = document.createElement("td");
         td.classList.add("gt-table--center");
 
diff --git a/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/actions/manual/ManualTriggerActionApprovalTest.java b/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/actions/manual/ManualTriggerActionApprovalTest.java
index 1c0ba7e7..8470f0af 100644
--- a/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/actions/manual/ManualTriggerActionApprovalTest.java
+++ b/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/actions/manual/ManualTriggerActionApprovalTest.java
@@ -26,7 +26,6 @@ package com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.actions.man
 
 import org.htmlunit.html.DomNode;
 import org.htmlunit.html.HtmlForm;
-import org.htmlunit.html.HtmlImage;
 import org.htmlunit.html.HtmlPage;
 import org.htmlunit.html.HtmlSpan;
 import org.htmlunit.html.HtmlTable;

@panicking
Copy link
Contributor

If the server name contains special char like & then it does not get show as should be. I found this fix but I don't think that is the best way

+    function unEntity(str){
+        return str.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">");
+    }
+
     function createTableRow(server, tbody) {
         const row = document.createElement("tr");
         row.setAttribute("data-server-url", server.serverUrl);
@@ -86,7 +90,7 @@ function refreshServerTable() {
             a.href = server.frontEndUrl;
             a.target = "_blank";
             a.classList.add("gt-external-link");
-            a.appendChild(document.createTextNode(server.name));
+            a.appendChild(document.createTextNode(unEntity(server.name)));

@mawinter69
Copy link
Contributor Author

Thanks for the feedback

If the server name contains special char like & then it does not get show as should be. I found this fix but I don't think that is the best way

Fixed it in the correct way by using innerHTML

@panicking
Copy link
Contributor

Thanks for the feedback

If the server name contains special char like & then it does not get show as should be. I found this fix but I don't think that is the best way

Fixed it in the correct way by using innerHTML

Is possible for you to squash the latest 3 commits and clean the commit message. I mean if you have some fixes on not merged patches they can go back to the initial patch

@panicking
Copy link
Contributor

:+1 I have deployed it and it works as far I can test

@@ -304,7 +304,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<reuseForks>false</reuseForks>
<forkCount>${concurrency}</forkCount>
</configuration>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it prevented that the forkCount can be set by the ci and that you can set it via command line with -DforkCount ro othat the forkCount setting from line 68 was effective

<j:choose>
<j:when test="${other.hasBuild()}">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you point out, where this change impact?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when another build is referenced but that build has already been deleted the image was missing

@@ -3,7 +3,7 @@
<l:layout title="${%Gerrit Manual trigger}" norefresh="true" permission="${it.requiredPermission}">
<l:header>
<script src="${rootURL}${it.getJsUrl('gerrit-search.js')}" type="text/javascript"/>
<link rel="stylesheet" href="${rootURL}/plugin/gerrit-trigger/css/gerrit.css" type="text/css"/>
<link rel="stylesheet" href="${rootURL}/plugin/gerrit-trigger/css/gerrit.css" type="text/css"/>
</l:header>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it caused problems with using dark theme. Also to be conform with CSP, there should be no inline style tags

@@ -86,7 +86,7 @@ function refreshServerTable() {
a.href = server.frontEndUrl;
a.target = "_blank";
a.classList.add("gt-external-link");
a.appendChild(document.createTextNode(server.name));
a.innerHTML = server.name;
a.appendChild(generateSVGIcon("gerrit-symbol-link"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any security risk for server name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, It was using innerHTML before, the server.name is already escaped

@@ -28,12 +28,6 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout">
<l:layout norefresh="true" permission="${app.ADMINISTER}" title="${%Add New Server}">
<l:side-panel>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the side panel? It's nothing important, just curious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the the design library recommendations (https://weekly.ci.jenkins.io/design-library/Layouts/) hierarchical links should be avoided

<f:entry title="${%Started}"
help="/plugin/gerrit-trigger/help-GerritBuildStartedVerified.html">
<f:textbox name="gerritBuildStartedVerifiedValue"
value="${it.config.gerritBuildStartedVerifiedValue}"
checkUrl="'${rootURL}/${serverURL}/emptyOrIntegerCheck?value='+escape(this.value)"/>
clazz="number"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this allow empty values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

help="/plugin/gerrit-trigger/help-GerritVerifiedCmdBuildSuccessful.html">
<f:textarea name="gerritVerifiedCmdBuildSuccessful"
value="${it.config.gerritCmdBuildSuccessful}"
default="gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message 'Build Successful &lt;BUILDS_STATS&gt;' --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just merged a PR that added a parameter here to the defaults, so I guess there will be a merge conflict that needs to be resolved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe I didn't 🤔

Copy link
Member

@rsandell rsandell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for doing this! You are awesome!

And sorry for not reviewing until now.

@rsandell rsandell merged commit 633df2b into jenkinsci:master Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants