forked from jenkinsci/pipeline-graph-view-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
72 lines (67 loc) · 2.02 KB
/
build.js
File metadata and controls
72 lines (67 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const rerunButton = document.getElementById("pgv-rerun");
if (rerunButton) {
rerunButton.addEventListener("click", (event) => {
event.preventDefault();
const rerunAction = window[`${rerunButton.dataset.proxyName}`];
rerunAction.doRerun(function (success) {
const result = success.responseJSON;
if (result) {
notificationBar.show(
rerunButton.dataset.successMessage,
notificationBar.SUCCESS,
);
}
});
});
}
const cancelButton = document.getElementById("pgv-cancel");
if (cancelButton) {
cancelButton.addEventListener("click", (event) => {
event.preventDefault();
const question = cancelButton.getAttribute("data-confirm");
const execute = function () {
const cancelAction = window[`${cancelButton.dataset.proxyName}`];
cancelAction.doCancel(function (response) {
const result = response.responseJSON;
if (result.status === "ok") {
notificationBar.show(cancelButton.dataset.successMessage);
} else {
notificationBar.show(result.message, notificationBar.WARNING);
}
});
};
if (question != null) {
dialog
.confirm(question)
.then(() => {
execute();
return null;
})
.catch((error) => {
console.error("Error in cancel confirm dialog:", error);
});
} else {
execute();
}
});
function updateCancelButton() {
const buildCaption = document.querySelector(".jenkins-build-caption");
const url = buildCaption.dataset.statusUrl;
fetch(url)
.then((rsp) => {
if (rsp.ok) {
const isBuilding = rsp.headers.get("X-Building");
if (isBuilding === "true") {
setTimeout(updateCancelButton, 5000);
} else {
cancelButton.style.display = "none";
}
}
return null;
})
.catch((error) => {
console.error("Error fetching build caption status:", error);
});
}
setTimeout(updateCancelButton, 5000);
}