Skip to content

Commit d9674ce

Browse files
authored
Use notification bar to report result of rebuild and cancel button actions (jenkinsci#776)
1 parent ce4e847 commit d9674ce

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

eslint.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,12 @@ export default [
4747
],
4848
},
4949
},
50+
{
51+
languageOptions: {
52+
globals: {
53+
dialog: "readonly",
54+
notificationBar: "readonly",
55+
},
56+
},
57+
},
5058
];

src/main/resources/io/jenkins/plugins/pipelinegraphview/consoleview/PipelineConsoleViewAction/index.jelly

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<j:set var="proxyId" value="${h.generateId()}" />
1414
<st:bind value="${it}" var="cancelAction${proxyId}"/>
1515
<button id="pgv-cancel" data-confirm="${%Confirm(it.buildFullDisplayName)}"
16+
data-success-message="${%Build cancelled}"
1617
data-proxy-name="cancelAction${proxyId}"
1718
class="jenkins-button jenkins-!-error-color">
1819
<l:icon src="symbol-stop-circle-outline plugin-ionicons-api"/>

src/main/resources/io/jenkins/plugins/pipelinegraphview/consoleview/PipelineConsoleViewAction/index.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
Build\ cancelled=Build cancelled
12
Cancel=Cancel
23
Confirm=Are you sure you want to abort {0}?
34
Rebuild=Rebuild

src/main/webapp/js/build.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if (rebuildButton) {
77
rebuildAction.doRebuild(function (success) {
88
const result = success.responseJSON;
99
if (result) {
10-
window.hoverNotification(rebuildButton.dataset.successMessage, rebuildButton);
10+
notificationBar.show(rebuildButton.dataset.successMessage, notificationBar.SUCCESS);
1111
}
1212
});
1313
})
@@ -21,11 +21,18 @@ if (cancelButton) {
2121
const question = cancelButton.getAttribute("data-confirm");
2222
const execute = function () {
2323
const cancelAction = window[`${cancelButton.dataset.proxyName}`];
24-
cancelAction.doCancel();
24+
cancelAction.doCancel(function (response) {
25+
const result = response.responseJSON;
26+
if (result.status === "ok") {
27+
notificationBar.show(cancelButton.dataset.successMessage)
28+
} else {
29+
notificationBar.show(result.message, notificationBar.WARNING)
30+
}
31+
});
32+
2533
};
2634

2735
if (question != null) {
28-
/*eslint-disable no-undef*/
2936
dialog.confirm(question).then(() => {
3037
execute();
3138
return null;

0 commit comments

Comments
 (0)