Skip to content

Commit 3b0fcce

Browse files
authored
Add separator to card (#134)
1 parent e47fd90 commit 3b0fcce

File tree

4 files changed

+54
-20
lines changed

4 files changed

+54
-20
lines changed

src/main/frontend/pipeline-graph-view/_cards.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
min-height: 400px;
3030
max-height: 400px;
3131

32+
hr {
33+
background: var(--secondary);
34+
border: none;
35+
height: 2px;
36+
margin: 0.4rem 0 calc(0.4rem + 15px);
37+
opacity: 0.2;
38+
}
39+
3240
&:hover {
3341
.pgv-cards__item__title__actions {
3442
opacity: 1;

src/main/java/io/jenkins/plugins/pipelinegraphview/PipelineGraphViewAction.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ public RunDetailsCard getRunDetailsCard() {
3030

3131
List<RunDetailsItem> runDetailsItems = new ArrayList<>();
3232

33+
runDetailsItems.addAll(SCMRunDetailsItems.get(run));
34+
35+
if (!runDetailsItems.isEmpty()) {
36+
runDetailsItems.add(new RunDetailsItem.Builder().separator().build());
37+
}
38+
3339
CauseRunDetailsItem.get(run).ifPresent(runDetailsItems::add);
3440

3541
runDetailsItems.addAll(TimingRunDetailsItems.get(run));
36-
runDetailsItems.addAll(SCMRunDetailsItems.get(run));
3742

3843
return new RunDetailsCard(runDetailsItems);
3944
}

src/main/java/io/jenkins/plugins/pipelinegraphview/cards/RunDetailsItem.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ public class RunDetailsItem {
77
private final String icon;
88
private final String text;
99
private final String href;
10+
private final boolean separator;
1011

11-
private RunDetailsItem(String icon, String text, String href) {
12+
RunDetailsItem(String icon, String text, String href, boolean separator) {
1213
this.icon = icon;
1314
this.text = text;
1415
this.href = href;
16+
this.separator = separator;
1517
}
1618

1719
public String getIcon() {
@@ -26,11 +28,16 @@ public String getHref() {
2628
return href;
2729
}
2830

31+
public boolean isSeparator() {
32+
return separator;
33+
}
34+
2935
public static class Builder {
3036

3137
private String icon;
3238
private String text;
3339
private String href;
40+
private boolean separator;
3441

3542
public Builder text(String text) {
3643
this.text = text;
@@ -52,9 +59,16 @@ public Builder href(String href) {
5259
return this;
5360
}
5461

62+
public Builder separator() {
63+
this.separator = true;
64+
return this;
65+
}
66+
5567
public RunDetailsItem build() {
56-
requireNonNull(icon);
57-
return new RunDetailsItem(icon, text, href);
68+
if (!separator) {
69+
requireNonNull(icon);
70+
}
71+
return new RunDetailsItem(icon, text, href, separator);
5872
}
5973
}
6074
}

src/main/resources/io/jenkins/plugins/pipelinegraphview/PipelineGraphViewAction/index.jelly

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,29 @@
3535
</p:card>
3636
<p:card title="${it.runDetailsCard.title}">
3737
<j:forEach var="card" items="${it.runDetailsCard.items}">
38-
<p class="app-details__item">
39-
<l:icon src="${card.icon}"/>
40-
<j:choose>
41-
<j:when test="${!empty(card.href)}">
42-
<a
43-
class="app-details__item--link"
44-
href="${card.href}"
45-
>
46-
${card.text}
47-
</a>
48-
</j:when>
49-
<j:otherwise>
50-
${card.text}
51-
</j:otherwise>
52-
</j:choose>
53-
</p>
38+
<j:choose>
39+
<j:when test="${card.separator}">
40+
<hr/>
41+
</j:when>
42+
<j:otherwise>
43+
<p class="app-details__item">
44+
<l:icon src="${card.icon}"/>
45+
<j:choose>
46+
<j:when test="${!empty(card.href)}">
47+
<a
48+
class="app-details__item--link"
49+
href="${card.href}"
50+
>
51+
${card.text}
52+
</a>
53+
</j:when>
54+
<j:otherwise>
55+
${card.text}
56+
</j:otherwise>
57+
</j:choose>
58+
</p>
59+
</j:otherwise>
60+
</j:choose>
5461
</j:forEach>
5562
</p:card>
5663
</div>

0 commit comments

Comments
 (0)