Skip to content

Commit

Permalink
Move Node monitoring option to app bar (#8381)
Browse files Browse the repository at this point in the history
* Init

* Update index.jelly

* Update index.jelly

* Add description

* Add description

* Fix test

* Update ComputerSetTest.java

---------

Co-authored-by: Alexander Brandes <[email protected]>
  • Loading branch information
janfaracik and NotMyFault authored Sep 9, 2023
1 parent 2971155 commit 30540d7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,26 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<l:layout permissions="${app.MANAGE_AND_SYSTEM_READ}" title="${%Node Monitoring Configuration}">
<l:layout permissions="${app.MANAGE_AND_SYSTEM_READ}" title="${%Node Monitoring Configuration}" type="one-column">
<j:set var="readOnlyMode" value="${!app.hasPermission(app.MANAGE)}" />
<st:include page="sidepanel.jelly" />
<l:breadcrumb title="${%Node Monitoring}" />
<l:main-panel>
<l:app-bar title="${%Node Monitoring}" />

<!-- to make the form field binding work -->
<j:set var="instance" value="${it}" />
<j:set var="descriptor" value="${it.descriptor}" />

<div class="jenkins-description">${%description}</div>

<f:form method="post" action="configSubmit" name="config">
<f:descriptorList title="${%Preventive Node Monitoring}"
descriptors="${it.nodeMonitorDescriptors}"
instances="${it.nonIgnoredMonitors}" />

<l:hasAdministerOrManage>
<f:bottomButtonBar>
<f:submit value="${%OK}" />
<f:submit value="${%Save}" />
<f:apply />
</f:bottomButtonBar>
</l:hasAdministerOrManage>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
description=Jenkins monitors each attached node for disk space, free temp space, free swap, clock time/sync, and response time. Nodes will be taken offline if any of these values go outside of the configured threshold.
20 changes: 13 additions & 7 deletions core/src/main/resources/hudson/model/ComputerSet/index.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ THE SOFTWARE.
<!-- no need for additional breadcrumb here as we're on an index page already including breadcrumb -->
<l:main-panel>
<l:app-bar title="${%Nodes}">
<j:getStatic var="createPermission" className="hudson.model.Computer" field="CREATE"/>
<j:if test="${h.hasPermission(createPermission)}">
<a class="jenkins-button jenkins-button--primary" href="new">
<l:icon src="symbol-add" />
${%New Node}
</a>
</j:if>
<j:getStatic var="createPermission" className="hudson.model.Computer" field="CREATE"/>
<j:if test="${h.hasPermission(createPermission)}">
<a class="jenkins-button jenkins-button--primary" href="new">
<l:icon src="symbol-add" />
${%New Node}
</a>
</j:if>
<j:set var="hasPermission" value="${h.hasAnyPermission(it, app.MANAGE_AND_SYSTEM_READ)}" />
<j:if test="${hasPermission}">
<a class="jenkins-button" href="configure">
${%Node Monitoring}
</a>
</j:if>
<l:hasAdministerOrManage>
<form method="post" action="updateNow" class="jenkins-!-display-contents">
<button tooltip="${%Refresh status}" class="jenkins-button">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ THE SOFTWARE.
title="${%Nodes}"/>
<l:task href="../cloud/" icon="symbol-cloud" permission="${app.SYSTEM_READ}"
title="${app.hasPermission(app.ADMINISTER) ? '%Clouds' : '%View Clouds'}"/>
<l:task href="configure" icon="symbol-settings" permissions="${app.MANAGE_AND_SYSTEM_READ}" title="${%Node Monitoring}"/>
</l:tasks>
<j:forEach var="w" items="${it.widgets}">
<st:include it="${w}" page="index" />
Expand Down
8 changes: 4 additions & 4 deletions test/src/test/java/hudson/model/ComputerSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void managePermissionCanConfigure() throws Exception {
HtmlPage page = wc.goTo("computer/");
assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
String responseContent = page.getWebResponse().getContentAsString();
// the "Node Monitoring" link in the sidepanel is not visible
// the "Node Monitoring" link in the app bar is not visible
assertThat(responseContent, not(containsString("Node Monitoring")));
page = wc.goTo("computer/configure");
assertEquals(HttpURLConnection.HTTP_FORBIDDEN, page.getWebResponse().getStatusCode());
Expand All @@ -129,13 +129,13 @@ public void managePermissionCanConfigure() throws Exception {
page = wc.goTo("computer/");
assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
responseContent = page.getWebResponse().getContentAsString();
// the "Node Monitoring" link in the sidepanel is visible
// the "Node Monitoring" link in the app bar is visible
assertThat(responseContent, containsString("Node Monitoring"));
page = wc.goTo("computer/configure");
assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
// and the OK (save) button is visible
// and the save button is visible
responseContent = page.getWebResponse().getContentAsString();
assertThat(responseContent, containsString("OK"));
assertThat(responseContent, containsString("Save"));
}

@Test
Expand Down

0 comments on commit 30540d7

Please sign in to comment.