Skip to content

Commit 84417bf

Browse files
committed
Collapsing Deployment View
Improvement to the deployment dashboard to hide/show deployments to multiple servers for an application Signed-off-by: Stuart Mallan <[email protected]>
1 parent c9cff43 commit 84417bf

File tree

6 files changed

+87
-31
lines changed

6 files changed

+87
-31
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ target/
22
!.mvn/wrapper/maven-wrapper.jar
33
!**/src/main/**
44
!**/src/test/**
5+
work/
56

67
### STS ###
78
.apt_generated

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<groupId>org.jenkins-ci.plugins</groupId>
2222
<artifactId>plugin</artifactId>
23-
<version>3.57</version>
23+
<version>4.9</version>
2424
</parent>
2525

2626
<dependencies>
@@ -33,7 +33,7 @@
3333
<dependency>
3434
<groupId>org.jenkins-ci.plugins.workflow</groupId>
3535
<artifactId>workflow-multibranch</artifactId>
36-
<version>2.21</version>
36+
<version>2.9.2</version>
3737
</dependency>
3838
</dependencies>
3939

src/main/java/org/jenkinsci/plugins/environmentdashboard/DeploymentView.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ private List<Unit.Environment> getEnvs(TopLevelItem item) {
4848

4949
return runs
5050
.stream()
51-
.map(run -> run.getAction(DeploymentAction.class))
51+
.map(run -> run.getActions(DeploymentAction.class))
52+
.flatMap(List::stream)
5253
.filter(Objects::nonNull)
5354
.collect(Collectors.groupingBy(DeploymentAction::getEnv))
5455
.entrySet()

src/main/resources/org/jenkinsci/plugins/environmentdashboard/DeploymentView/main.jelly

+53-28
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<j:set var="units" value="${it.getUnits(it.items)}"/>
1919
<div class="pane-frame">
2020
<table id="projectstatus" class="pane bigtable stripped-odd">
21-
<tbody>
21+
<thead>
2222
<tr class="header">
2323
<th>
2424
<span style="margin-left: 1em">
@@ -46,35 +46,49 @@
4646
</span>
4747
</th>
4848
</tr>
49-
<j:forEach var="unit" indexVar="i" items="${units}">
49+
</thead>
50+
<j:forEach var="unit" indexVar="i" items="${units}">
51+
<tbody class="apps">
52+
<tr id="job_build">
53+
<td colspan="4">
54+
<a href="${unit.getJob().getAbsoluteUrl()}" style="margin-left: .5em">${unit.getJob().name}</a>
55+
</td>
56+
<td colspan="1">
57+
<div class="toggle">
58+
<button>
59+
<span>Details</span>
60+
<img src="/plugin/deploy-dashboard/chevron.svg" />
61+
</button>
62+
</div>
63+
</td>
64+
</tr>
65+
</tbody>
66+
<tbody class="hideRows">
5067
<j:forEach var="environment" indexVar="j" items="${unit.getEnvironments()}">
51-
<tr id="job_build">
52-
<td>
53-
<j:if test="${j == 0}">
54-
<a href="${unit.getJob().getAbsoluteUrl()}" style="margin-left: .5em">${unit.getJob().name}</a>
55-
</j:if>
56-
</td>
57-
<td>
58-
<a href="javascript:toggle('${i}_${j}');">
59-
${environment.getName()}
60-
</a>
61-
</td>
62-
<td>
63-
<a href="${environment.getCurrentAction().run.getAbsoluteUrl()}">
64-
${environment.getCurrentAction().buildNumber}
65-
</a>
66-
</td>
67-
<td>
68-
<l:icon alt="${environment.getCurrentAction().run.description}"
69-
class="${environment.getCurrentAction().run.buildStatusIconClassName} icon-lg"/>
70-
</td>
71-
<td>
72-
${environment.getCurrentAction().run.timestampString}
73-
</td>
74-
</tr>
68+
<tr id="job_build">
69+
<td>
70+
</td>
71+
<td>
72+
<a href="javascript:toggle('${i}_${j}');">
73+
${environment.getName()}
74+
</a>
75+
</td>
76+
<td>
77+
<a href="${environment.getCurrentAction().run.getAbsoluteUrl()}">
78+
${environment.getCurrentAction().buildNumber}
79+
</a>
80+
</td>
81+
<td>
82+
<l:icon alt="${environment.getCurrentAction().run.description}"
83+
class="${environment.getCurrentAction().run.buildStatusIconClassName} icon-lg"/>
84+
</td>
85+
<td>
86+
${environment.getCurrentAction().run.timestampString}
87+
</td>
88+
</tr>
7589
</j:forEach>
76-
</j:forEach>
77-
</tbody>
90+
</tbody>
91+
</j:forEach>
7892
</table>
7993
</div>
8094

@@ -155,6 +169,17 @@
155169
window.addEventListener('click', windowClose);
156170
span.addEventListener('click', close);
157171
}
172+
173+
const apps = document.querySelectorAll(".toggle button");
174+
175+
apps.forEach((apps) =>
176+
apps.addEventListener("click", (event) => {
177+
event.currentTarget
178+
.closest(".apps")
179+
.nextElementSibling.classList.toggle("hideRows");
180+
event.currentTarget.querySelector(".toggle img").classList.toggle("expand");
181+
})
182+
);
158183
</script>
159184
</j:otherwise>
160185
</j:choose>

src/main/webapp/chevron.svg

+1
Loading

src/main/webapp/css/blink.css

+28
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,32 @@
8686

8787
.modal-body tbody tr:first-child th:first-child {
8888
padding: .7em !important;
89+
}
90+
91+
.hideRows {
92+
display: none;
93+
}
94+
95+
.toggle {
96+
float: right !important;
97+
}
98+
99+
.toggle button {
100+
border: 0;
101+
padding: 0 !important;
102+
background-color: transparent;
103+
}
104+
105+
.toggle img {
106+
height: 20px;
107+
vertical-align: middle;
108+
transition: transform 0.2s, -webkit-transform 0.2s;
109+
}
110+
111+
.toggle img.expand {
112+
transform: rotate(180deg);
113+
}
114+
115+
.toggle span {
116+
vertical-align: middle !important;
89117
}

0 commit comments

Comments
 (0)