Skip to content

Commit

Permalink
Improves score and plugin details (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecharp authored May 23, 2023
1 parent 7bafdbb commit df4d6c2
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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<String, ProbeResultView> probeResults,
Collection<ScoreResultView> details) {
Expand Down
38 changes: 38 additions & 0 deletions war/src/main/less/modules/score.less
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
19 changes: 18 additions & 1 deletion war/src/main/resources/templates/scores/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@

<section data-layout-fragment="content">
<h1 data-th-utext="'Score of <em>' + ${score.pluginName} + '</em> plugin'"></h1>
<div class="card score" data-th-text="${score.value}"></div>

<div class="plugin--details">
<div class="plugin--details--tab" data-th-if="${ score.scm }">
<ion-icon name="logo-github"></ion-icon>
<a data-th-href="${ score.scm }" data-th-text="${ score.scm }"></a>
</div>
<div class="plugin--details--tab">
<ion-icon name="version-tag"></ion-icon>
<span data-th-text="${ score.version }"></span>
</div>
<div class="plugin--details--tab">
<ion-icon name="calendar"></ion-icon>
<span data-th-text="${ #temporals.format(score.releaseTimestamp) }"></span>
</div>
</div>

<div class="card score" data-th-text="${score.value}">
</div>

<h3>Details</h3>
<table class="table">
Expand Down
1 change: 1 addition & 0 deletions war/src/main/svg/calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions war/src/main/svg/logo-github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions war/src/main/svg/version-tag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit df4d6c2

Please sign in to comment.