Skip to content

Commit 08874cd

Browse files
authored
Merge pull request #156 from jenkinsci/dialogs
use confirm dialog instead of browser built-in pop-ups
2 parents f9f17ec + 18e0c95 commit 08874cd

File tree

5 files changed

+48
-29
lines changed

5 files changed

+48
-29
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<revision>2</revision>
4343
<changelist>999999-SNAPSHOT</changelist>
4444
<gitHubRepo>jenkinsci/agent-maintenance-plugin</gitHubRepo>
45-
<jenkins.version>2.387.3</jenkins.version>
45+
<jenkins.version>2.426.1</jenkins.version>
4646
<powermock.version>1.6.1</powermock.version>
4747
<checkstyle.version>10.12.4</checkstyle.version>
4848
<hpi.compatibleSinceVersion>2.0</hpi.compatibleSinceVersion>
@@ -52,8 +52,8 @@
5252
<dependencies>
5353
<dependency>
5454
<groupId>io.jenkins.tools.bom</groupId>
55-
<artifactId>bom-2.387.x</artifactId>
56-
<version>2244.vd60654536b_96</version>
55+
<artifactId>bom-2.426.x</artifactId>
56+
<version>2571.vede9dc5a_2e23</version>
5757
<type>pom</type>
5858
<scope>import</scope>
5959
</dependency>

src/main/resources/com/sap/prd/jenkins/plugins/agent_maintenance/MaintenanceAction/index.jelly

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@
7272
</table>
7373
<p:hasAnyPermission permissions="${it.CONFIGURE_AND_DISCONNECT}">
7474
<f:bottomButtonBar>
75-
<div class="am__div--select">
75+
<div id="am__div--select" class="jenkins-hidden">
7676
Select:
7777
<span id="select-all" class="am__select">${%All}</span>,
7878
<span id="select-active" class="am__select">${%Active}</span>,
7979
<span id="select-inactive" class="am__select">${%Inactive}</span>,
8080
<span id="select-none" class="am__select">${%None}</span>
8181
</div>
8282
<div class="am__div--break"/>
83-
<button type="button" id="edit-button" class="jenkins-button jenkins-button--primary">${%Edit}</button>
83+
<button type="button" id="edit-button" class="jenkins-button jenkins-button--primary jenkins-hidden">${%Edit}</button>
8484
<button id="add-button" type="button"
85-
class="jenkins-button jenkins-button--primary">${%Add}</button>
85+
class="jenkins-button jenkins-button--primary jenkins-hidden">${%Add}</button>
8686
<button id="delete-selected-button-action" type="button"
87-
class="jenkins-button jenkins-button--primary"
87+
class="jenkins-button jenkins-button--primary jenkins-hidden"
8888
data-message-success="${%All selected maintenance windows were deleted successfully}">${%Delete selected}</button>
8989
</f:bottomButtonBar>
9090
</p:hasAnyPermission>

src/main/resources/com/sap/prd/jenkins/plugins/agent_maintenance/MaintenanceLink/index.jelly

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<div class="am__link-delete"
7474
data-message="${%deleteMaintenanceOf} ${c.displayName}"
7575
data-message-success="${%Maintenance window was successfully deleted}">
76-
<l:icon src="symbol-close-outline plugin-ionicons-api" class="icon-sm alert-danger am__table-icon"
76+
<l:icon src="symbol-trash-outline plugin-ionicons-api" class="icon-sm icon-red am__table-icon"
7777
tooltip="Delete this maintenance windows for ${h.escape(c.displayName)}"/>
7878
</div>
7979
</td>
@@ -94,7 +94,7 @@
9494
</div>
9595
</j:if>
9696
<f:bottomButtonBar>
97-
<div class="am__div--select">
97+
<div id="am__div--select" class="jenkins-hidden">
9898
Select:
9999
<span id="select-all" class="am__select">${%All}</span>,
100100
<span id="select-active" class="am__select">${%Active}</span>,

src/main/resources/com/sap/prd/jenkins/plugins/agent_maintenance/agent-maintenance.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
height: 0;
8888
}
8989

90-
.am__div--select {
90+
#am__div--select {
9191
flex-grow: 1;
9292
}
9393

src/main/resources/com/sap/prd/jenkins/plugins/agent_maintenance/agent-maintenance.js

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,17 @@ function refresh() {
3737
tBody.removeChild(row);
3838
}
3939
}
40+
if (tBody.children.length == 0) {
41+
document.getElementById("delete-selected-button-action").style.display = "none";
42+
document.getElementById("edit-button").style.display = "none";
43+
document.getElementById("am__div--select").style.display = "none";
44+
}
4045
});
4146
}
4247

4348

4449
window.addEventListener("DOMContentLoaded", (event) => {
45-
window.setInterval(refresh, 20000);;
50+
window.setInterval(refresh, 20000);
4651
});
4752

4853
var selectMaintenanceWindows = function(toggle, className) {
@@ -59,7 +64,7 @@ Behaviour.specify(".am__action-delete", 'agent-maintenance', 0, function(e) {
5964
let message = this.getAttribute("data-message");
6065
let messageSuccess = this.getAttribute("data-message-success");
6166
let id = row.id;
62-
if (confirm(message)) {
67+
dialog.confirm(message).then( () => {
6368
maintenanceJavaScriptBind.deleteMaintenance(id, function(response) {
6469
let result = response.responseObject();
6570
if (result) {
@@ -69,12 +74,13 @@ Behaviour.specify(".am__action-delete", 'agent-maintenance', 0, function(e) {
6974
if (tbody.children.length == 0) {
7075
document.getElementById("edit-button").style.display = "none";
7176
document.getElementById("delete-selected-button-action").style.display = "none";
77+
document.getElementById("am__div--select").style.display = "none";
7278
}
7379
} else {
7480
notificationBar.show("Something went wrong. Please check the logs.", notificationBar.ERROR);
7581
}
7682
});
77-
}
83+
});
7884
}
7985
});
8086

@@ -84,7 +90,7 @@ Behaviour.specify(".am__action-delete-recurring", 'agent-maintenance', 0, functi
8490
let message = this.getAttribute("data-message");
8591
let messageSuccess = this.getAttribute("data-message-success");
8692
let id = row.id;
87-
if (confirm(message)) {
93+
dialog.confirm(message).then( () => {
8894
maintenanceJavaScriptBind.deleteRecurringMaintenance(id, function(response) {
8995
let result = response.responseObject();
9096
if (result) {
@@ -94,12 +100,13 @@ Behaviour.specify(".am__action-delete-recurring", 'agent-maintenance', 0, functi
94100
if (tbody.children.length == 0) {
95101
document.getElementById("edit-recurring").style.display = "none";
96102
document.getElementById("delete-selected-recurring-action").style.display = "none";
103+
document.getElementById("am__div--select").style.display = "none";
97104
}
98105
} else {
99106
notificationBar.show("Something went wrong. Please check the logs.", notificationBar.ERROR);
100107
}
101108
});
102-
}
109+
});
103110
}
104111
});
105112

@@ -110,7 +117,7 @@ Behaviour.specify(".am__link-delete", 'agent-maintenance', 0, function(e) {
110117
let row = findAncestor(this, "TR");
111118
let id = row.id;
112119
let computerName = row.getAttribute("data-computer-name");
113-
if (confirm(message)) {
120+
dialog.confirm(message).then( () => {
114121
maintenanceJavaScriptBind.deleteMaintenance(id, computerName, function(response) {
115122
let result = response.responseObject();
116123
if (result) {
@@ -119,47 +126,50 @@ Behaviour.specify(".am__link-delete", 'agent-maintenance', 0, function(e) {
119126
notificationBar.show(messageSuccess, notificationBar.SUCCESS)
120127
if (tbody.children.length == 0) {
121128
document.getElementById("delete-selected-button-link").style.display = "none";
129+
document.getElementById("am__div--select").style.display = "none";
122130
}
123131
} else {
124132
notificationBar.show("Something went wrong. Please check the logs.", notificationBar.ERROR);
125133
}
126134
});
127-
}
135+
});
128136
}
129137
});
130138

131139
Behaviour.specify(".am__disable", 'agent-maintenance', 0, function(e) {
132140
e.onclick = function() {
133141
let message = this.getAttribute("data-message");
134-
if (confirm(message)) {
142+
dialog.confirm(message).then( () => {
135143
fetch("disable", {
136144
method: "POST",
137145
headers: crumb.wrap({}),
138146
}
139147
);
140148
location.reload();
141-
};
149+
});
142150
}
143151
});
144152

145153
Behaviour.specify(".am__enable", 'agent-maintenance', 0, function(e) {
146154
e.onclick = function() {
147155
let message = this.getAttribute("data-message");
148-
if (confirm(message)) {
156+
dialog.confirm(message).then( () => {
149157
fetch("enable", {
150158
method: "POST",
151159
headers: crumb.wrap({}),
152160
}
153161
);
154162
location.reload();
155-
};
163+
});
156164
}
157165
});
158166

159167
Behaviour.specify("#add-button", 'agent-maintenance', 0, function(e) {
160-
e.onclick = function() {
168+
e.onclick = function() {
161169
openForm("maintenance-add-form")
162-
};
170+
};
171+
e.style.display = 'inline-flex';
172+
e.classList.remove("jenkins-hidden");
163173
});
164174

165175
Behaviour.specify("#add-recurring", 'agent-maintenance', 0, function(e) {
@@ -174,8 +184,9 @@ Behaviour.specify("#edit-button", 'agent-maintenance', 0, function(e) {
174184
}
175185
let table = document.getElementById("maintenance-table");
176186
let tbody = table.tBodies[0];
177-
if (tbody.children.length == 0) {
178-
e.style.display = 'none';
187+
if (tbody.children.length != 0) {
188+
e.style.display = 'inline-flex';
189+
e.classList.remove("jenkins-hidden");
179190
}
180191
});
181192

@@ -237,8 +248,12 @@ Behaviour.specify("#delete-selected-button-action", 'agent-maintenance', 0, func
237248
});
238249
}
239250
}
240-
if (tbody.children.length == 0) {
241-
e.style.display = 'none';
251+
if (tbody.children.length != 0) {
252+
e.style.display = 'inline-flex';
253+
e.classList.remove("jenkins-hidden");
254+
let select = document.getElementById("am__div--select");
255+
select.classList.remove("jenkins-hidden");
256+
select.style.display="block";
242257
}
243258
});
244259

@@ -319,8 +334,12 @@ Behaviour.specify("#delete-selected-button-link", 'agent-maintenance', 0, functi
319334
});
320335
}
321336
}
322-
if (tbody.children.length == 0) {
323-
e.style.display = 'none';
337+
if (tbody.children.length != 0) {
338+
e.style.display = "inline-flex";
339+
e.classList.remove("jenkins-hidden")
340+
let select = document.getElementById("am__div--select");
341+
select.classList.remove("jenkins-hidden");
342+
select.style.display="block";
324343
}
325344
});
326345

0 commit comments

Comments
 (0)