jenkins icon indicating copy to clipboard operation
jenkins copied to clipboard

Rewrite the build history widget

Open janfaracik opened this issue 10 months ago • 33 comments

This PR implements the changes discussed https://community.jenkins.io/t/revamped-build-history-widget/10944. In essence it's a rewrite/redesign of the build history widget. The goal is to be cleaner and simpler, whilst still retaining existing functionality and density.

Before image image image

After image

image image image

What's changed

  • The JS has been rewritten and does away with a lot of the complicated layout logic in favour of CSS flex/grid.
  • A new card component has been added (with the intention of replacing the existing widget component) that supports inline actions
  • Builds now group by date, keeping the UI simpler/easier to read
  • RSS feed has been moved to a dropdown, rather than a fixed button row
  • Build overflow menus are now always present on the right of the link

What doesn't work

  • ✅ ~Pagination controls are always visible at the moment~
  • ✅ ~The list doesn't auto refresh at the moment~
  • ✅ ~Items with long names/lots of actions don't scale very well~

Testing done

  • See https://github.com/jenkinsci/jenkins/pull/9148#issuecomment-2053640530 for a view of the scenarios tested
    • Normal scenarios work as expected (e.g. short build names, one or two badges)
    • Queued items look as expected
    • Items with plain text/HTML descriptions work as expected
    • Items with long names/lots of badges wrap as expected

Proposed changelog entries

  • Update the design of the build history widget

Proposed upgrade guidelines

N/A

### Submitter checklist
- [x] The Jira issue, if it exists, is well-described.
- [x] The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see [examples](https://github.com/jenkins-infra/jenkins.io/blob/master/content/_data/changelogs/weekly.yml)). Fill in the **Proposed upgrade guidelines** section only if there are breaking changes or changes that may require extra steps from users during upgrade.
- [x] There is automated testing or an explanation as to why this change has no tests.
- [x] New public classes, fields, and methods are annotated with `@Restricted` or have `@since TODO` Javadocs, as appropriate.
- [x] New deprecations are annotated with `@Deprecated(since = "TODO")` or `@Deprecated(forRemoval = true, since = "TODO")`, if applicable.
- [x] New or substantially changed JavaScript is not defined inline and does not call `eval` to ease future introduction of Content Security Policy (CSP) directives (see [documentation](https://www.jenkins.io/doc/developer/security/csp/)).
- [x] For dependency updates, there are links to external changelogs and, if possible, full differentials.
- [x] For new APIs and extension points, there is a link to at least one consumer.

Desired reviewers

@jenkinsci/sig-ux

Before the changes are marked as ready-for-merge:

### Maintainer checklist
- [ ] There are at least two (2) approvals for the pull request and no outstanding requests for change.
- [ ] Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
- [ ] Changelog entries in the pull request title and/or **Proposed changelog entries** are accurate, human-readable, and in the imperative mood.
- [ ] Proper changelog labels are set so that the changelog can be generated automatically.
- [ ] If the change needs additional upgrade steps from users, the `upgrade-guide-needed` label is set and there is a **Proposed upgrade guidelines** section in the pull request title (see [example](https://github.com/jenkinsci/jenkins/pull/4387)).
- [ ] If it would make sense to backport the change to LTS, a Jira issue must exist, be a _Bug_ or _Improvement_, and be labeled as `lts-candidate` to be considered (see [query](https://issues.jenkins.io/issues/?filter=12146)).

janfaracik avatar Apr 09 '24 08:04 janfaracik

can you add before screenshots too please

timja avatar Apr 09 '24 15:04 timja

How does this look when a build has a display name? How does it look when a build has many badges? Just an example how this looks currently: image

mawinter69 avatar Apr 09 '24 16:04 mawinter69

How does this look when a build has a display name? How does it look when a build has many badges? Just an example how this looks currently: image

image

It's okay but could be better - I think moving the badges onto a new row when its incredibly long would improve it.

janfaracik avatar Apr 10 '24 06:04 janfaracik

What made the previous implementation so big was the logic to find a suitable way to arrange all the things. See #9122 for my PR that changed they calculation to be more efficient.

mawinter69 avatar Apr 10 '24 09:04 mawinter69

Please take a moment and address the merge conflicts of your pull request. Thanks!

github-actions[bot] avatar Apr 10 '24 18:04 github-actions[bot]

Getting ReferenceError: "fetch" is not defined. (http://localhost:42617/jenkins/static/8bd93229/jsbundles/pages/project/builds-card.js#52) in tests - have you experienced this before @timja?

janfaracik avatar Apr 11 '24 10:04 janfaracik

Getting ReferenceError: "fetch" is not defined. (http://localhost:42617/jenkins/static/8bd93229/jsbundles/pages/project/builds-card.js#52) in tests - have you experienced this before @timja?

I see the issue, PR incoming

timja avatar Apr 11 '24 10:04 timja

https://github.com/jenkinsci/jenkins-test-harness/pull/753

timja avatar Apr 11 '24 10:04 timja

How does this look when a build has a display name? How does it look when a build has many badges? Just an example how this looks currently: image

image It's _okay_ but could be better - I think moving the badges onto a new row when its incredibly long would improve it.
image

Updated it to handle a ton of badges/long text - there's a lot of combinations so I might have missed something.

janfaracik avatar Apr 13 '24 13:04 janfaracik

No blockers from a security perspective.

However, I've noticed that the search filter doesn't seem to work properly. It takes quite long or never finishes.

Kevin-CB avatar Apr 23 '24 11:04 Kevin-CB

Please take a moment and address the merge conflicts of your pull request. Thanks!

github-actions[bot] avatar Apr 23 '24 19:04 github-actions[bot]

StaticRoutingDecisionProviderTest#test_objectCustom_withStandardWhitelist is passing locally but not on CI - wondering if this is actually an issue of this PR?

janfaracik avatar Apr 24 '24 19:04 janfaracik

The collapse arrow is no longer there. tbh I have never used it so I'm not missing it but don't know what others are thinking about it.

mawinter69 avatar Apr 25 '24 20:04 mawinter69

StaticRoutingDecisionProviderTest#test_objectCustom_withStandardWhitelist is passing locally but not on CI - wondering if this is actually an issue of this PR?

I can reproduce it locally by running the entire test class, not just the one test. This is a result of concurrent test execution within the same class. I was unaware we were doing this, is this new?

daniel-beck avatar Apr 29 '24 08:04 daniel-beck

StaticRoutingDecisionProviderTest#test_objectCustom_withStandardWhitelist is passing locally but not on CI - wondering if this is actually an issue of this PR?

I can reproduce it locally by running the entire test class, not just the one test. This is a result of concurrent test execution within the same class. I was unaware we were doing this, is this new?

I can't see it enabled =/

https://github.com/jenkinsci/jenkins/blob/065c2ba00e729fc947ef131ab143615b5dcb95ef/test/pom.xml#L359-L369

timja avatar Apr 29 '24 08:04 timja

OK then I'll dig further, my System.err based diagnostic probably wasn't good enough :)

daniel-beck avatar Apr 29 '24 08:04 daniel-beck

Running the entire class, I get this after modifying the test to not rely on @Before and changing the URL to be guaranteed not routable:

Screenshot 2024-04-29 at 11 32 57

@timja Thoughts? Am I missing something obvious?

daniel-beck avatar Apr 29 '24 09:04 daniel-beck

I've not looked into it in detail but this chases it away =/:

diff --git a/test/src/test/java/jenkins/security/stapler/StaticRoutingDecisionProviderTest.java b/test/src/test/java/jenkins/security/stapler/StaticRoutingDecisionProviderTest.java
index 9e849a2278..b76124047d 100644
--- a/test/src/test/java/jenkins/security/stapler/StaticRoutingDecisionProviderTest.java
+++ b/test/src/test/java/jenkins/security/stapler/StaticRoutingDecisionProviderTest.java
@@ -95,7 +95,7 @@ public class StaticRoutingDecisionProviderTest extends StaplerAbstractTest {
     }

     @Test
-    public void test_job_index() throws Exception {
+    public void zzTest_job_index() throws Exception {
         j.createFreeStyleProject("testProject");
         assertReachableWithoutOk("contentProvider/job/");
         assertTrue(ContentProvider.called);

timja avatar Apr 29 '24 11:04 timja

Its being loaded by build history ajax somehow.

From a breakpoint on all the called variables: image

timja avatar Apr 29 '24 11:04 timja

This also chases it away, I haven't run other sub-classes to see if any impact:

diff --git a/test/src/test/java/jenkins/security/stapler/StaplerAbstractTest.java b/test/src/test/java/jenkins/security/stapler/StaplerAbstractTest.java
index 4c3f5d28b6..d66902a724 100644
--- a/test/src/test/java/jenkins/security/stapler/StaplerAbstractTest.java
+++ b/test/src/test/java/jenkins/security/stapler/StaplerAbstractTest.java
@@ -43,7 +43,7 @@ import org.htmlunit.HttpMethod;
 import org.htmlunit.Page;
 import org.htmlunit.WebRequest;
 import org.junit.Before;
-import org.junit.ClassRule;
+import org.junit.Rule;
 import org.jvnet.hudson.test.JenkinsRule;
 import org.kohsuke.stapler.Stapler;
 import org.kohsuke.stapler.StaplerResponse;
@@ -51,8 +51,8 @@ import org.kohsuke.stapler.WebApp;
 import org.kohsuke.stapler.WebMethod;

 public abstract class StaplerAbstractTest {
-    @ClassRule
-    public static JenkinsRule rule = new JenkinsRule();
+    @Rule
+    public JenkinsRule rule = new JenkinsRule();
     protected JenkinsRule j;

     protected JenkinsRule.WebClient wc;

timja avatar Apr 29 '24 12:04 timja

Nice find. Web client reuse seems sus and unnecessary, I'm looking into cleaning that up, hoping this goes away with that.

Making JenkinsRule a @ClassRule probably speeds tests up considerably, would need to look into whether that decision was documented.

daniel-beck avatar Apr 29 '24 15:04 daniel-beck

Making JenkinsRule a @ClassRule probably speeds tests up considerably, would need to look into whether that decision was documented.

Yeah, 3 sec ClassRule, 11 sec Rule

timja avatar Apr 29 '24 15:04 timja

nice build passes now, cheers Daniel

timja avatar Apr 30 '24 13:04 timja

Big thanks both 🎉

janfaracik avatar Apr 30 '24 15:04 janfaracik

lint is failing

timja avatar May 12 '24 13:05 timja

Please take a moment and address the merge conflicts of your pull request. Thanks!

github-actions[bot] avatar May 17 '24 15:05 github-actions[bot]

ATH passing - https://github.com/jenkinsci/acceptance-test-harness/pull/1557

janfaracik avatar May 22 '24 07:05 janfaracik

Looks good now

Some minor thought:

  • the navigation buttons are at the bottom. so when I want to look at later builds I need to scroll down first

Here a screenshot with some badges: image

mawinter69 avatar May 23 '24 10:05 mawinter69

Badges can overflow the box:

image

May not be realistic but is it fixable without too much effort?

the navigation buttons are at the bottom. so when I want to look at later builds I need to scroll down first

Its normal for pagination to be at the bottom, I think this should be fine

timja avatar May 23 '24 18:05 timja

I'm not able to reproduce the badge overflowing, but having many badges with icons from Badge plugin leads to the icons getting very small. Probably also an issue with the badge plugin itself. But ideally the badges would start flowing in the next row.

Seems with the refactoring of the badge plugin things do indeed overflow.

image

mawinter69 avatar May 23 '24 20:05 mawinter69