From df4d6c26262a3ac37b54fe208a6360df493fa891 Mon Sep 17 00:00:00 2001 From: Adrien Lecharpentier Date: Tue, 23 May 2023 10:41:16 +0200 Subject: [PATCH] Improves score and plugin details (#311) --- .../scoring/http/ScoreController.java | 6 ++- war/src/main/less/modules/score.less | 38 +++++++++++++++++++ .../resources/templates/scores/details.html | 19 +++++++++- war/src/main/svg/calendar.svg | 1 + war/src/main/svg/logo-github.svg | 1 + war/src/main/svg/version-tag.svg | 1 + .../scoring/http/ScoreControllerTest.java | 5 +++ 7 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 war/src/main/svg/calendar.svg create mode 100644 war/src/main/svg/logo-github.svg create mode 100644 war/src/main/svg/version-tag.svg diff --git a/war/src/main/java/io/jenkins/pluginhealth/scoring/http/ScoreController.java b/war/src/main/java/io/jenkins/pluginhealth/scoring/http/ScoreController.java index 77dbdd9b0..ed2d53dac 100644 --- a/war/src/main/java/io/jenkins/pluginhealth/scoring/http/ScoreController.java +++ b/war/src/main/java/io/jenkins/pluginhealth/scoring/http/ScoreController.java @@ -24,6 +24,7 @@ package io.jenkins.pluginhealth.scoring.http; +import java.time.ZonedDateTime; import java.util.Collection; import java.util.List; import java.util.Map; @@ -83,6 +84,9 @@ public ModelAndView getScoreOf(@PathVariable String pluginName) { final PluginScoreView view = new PluginScoreView( plugin.getName(), + plugin.getScm(), + plugin.getVersion().toString(), + plugin.getReleaseTimestamp(), score.getValue(), probeResultViews, scoreComponents @@ -96,7 +100,7 @@ public ModelAndView getScoreOf(@PathVariable String pluginName) { .orElseGet(() -> new ModelAndView("scores/unknown", Map.of("pluginName", pluginName), HttpStatus.NOT_FOUND)); } - private record PluginScoreView(String pluginName, + private record PluginScoreView(String pluginName, String scm, String version, ZonedDateTime releaseTimestamp, long value, Map probeResults, Collection details) { diff --git a/war/src/main/less/modules/score.less b/war/src/main/less/modules/score.less index e4e5af2e9..6ae556007 100644 --- a/war/src/main/less/modules/score.less +++ b/war/src/main/less/modules/score.less @@ -19,3 +19,41 @@ ion-icon { visibility: visible; } } + +.plugin--details { + font-size: .8rem; + margin-bottom: 1.5em; + display: inline-flex; + justify-content: flex-start; + align-items: flex-start; + + .plugin--details--tab { + &:not(:last-of-type) { + margin-right: 16px; + } + display: inline-flex; + justify-content: flex-start; + align-items: center; + + + padding: .75em; + border-radius: 1em; + + background-color: var(--light-grey); + } +} + +.card.score { + display: flex; + + justify-content: center; + align-items: center; + + font-size: 3rem; + font-weight: 700; + width: 128px; + height: 128px; + + border-radius: 1rem; + background-color: var(--light-grey); +} diff --git a/war/src/main/resources/templates/scores/details.html b/war/src/main/resources/templates/scores/details.html index c8805a57a..352d129bf 100644 --- a/war/src/main/resources/templates/scores/details.html +++ b/war/src/main/resources/templates/scores/details.html @@ -7,7 +7,24 @@

-
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+

Details

diff --git a/war/src/main/svg/calendar.svg b/war/src/main/svg/calendar.svg new file mode 100644 index 000000000..285849d7b --- /dev/null +++ b/war/src/main/svg/calendar.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/war/src/main/svg/logo-github.svg b/war/src/main/svg/logo-github.svg new file mode 100644 index 000000000..6676102ae --- /dev/null +++ b/war/src/main/svg/logo-github.svg @@ -0,0 +1 @@ +Logo Github \ No newline at end of file diff --git a/war/src/main/svg/version-tag.svg b/war/src/main/svg/version-tag.svg new file mode 100644 index 000000000..b86525ca9 --- /dev/null +++ b/war/src/main/svg/version-tag.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/war/src/test/java/io/jenkins/pluginhealth/scoring/http/ScoreControllerTest.java b/war/src/test/java/io/jenkins/pluginhealth/scoring/http/ScoreControllerTest.java index 3ed34c283..13e39f047 100644 --- a/war/src/test/java/io/jenkins/pluginhealth/scoring/http/ScoreControllerTest.java +++ b/war/src/test/java/io/jenkins/pluginhealth/scoring/http/ScoreControllerTest.java @@ -33,6 +33,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; +import java.time.ZonedDateTime; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -46,6 +47,7 @@ import io.jenkins.pluginhealth.scoring.service.ScoreService; import io.jenkins.pluginhealth.scoring.service.ScoringService; +import hudson.util.VersionNumber; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; @@ -88,6 +90,9 @@ void shouldDisplayScoreForSpecificPlugin() throws Exception { when(plugin.getDetails()).thenReturn(Map.of( probeKey, ProbeResult.success(probeKey, "message") )); + when(plugin.getScm()).thenReturn("this-is-the-url-of-the-plugin-location"); + when(plugin.getReleaseTimestamp()).thenReturn(ZonedDateTime.now().minusHours(1)); + when(plugin.getVersion()).thenReturn(new VersionNumber("1.0")); final Score score = mock(Score.class); when(score.getPlugin()).thenReturn(plugin);