Skip to content

Commit

Permalink
[JENKINS-74893] Extract inline JavaScript event handlers (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaroslavafenkin authored Nov 25, 2024
1 parent ae68af2 commit 11082ba
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import hudson.Functions
def f = namespace(lib.FormTagLib)
def l = namespace(lib.LayoutTagLib)
def j = namespace(lib.JenkinsTagLib)
def st = namespace("jelly:stapler")

l.layout(permission: PluginImpl.REMOVE_PERMISSION) {
l.header(title: _("Failure Cause Management - Confirm Remove"))
Expand Down Expand Up @@ -60,17 +61,18 @@ l.layout(permission: PluginImpl.REMOVE_PERMISSION) {
+ "background-image: url(\'" + imageUrl + "');") {}
h1(_("Failure Cause - Confirm Remove"))
div(style: "width: 70%") {
st.adjunct(includes: "com.sonyericsson.jenkins.plugins.bfa.CauseManagement.resource")
if (cause != null) {
form(method: "POST", action: "removeConfirm") {
p(_("removeQuestion", cause.getName()))
input(type: "hidden", value: cause.getId(), name: "id")
f.submit(value: _("Yes"))
raw("  ");
input(type: "button", value:_("Back"), onClick: "history.back(1)", class: "yui-button")
button(type: "button", class: "jenkins-button bfa-cause-management-back-button", _("Back"))
}
} else {
p(_("Not a valid cause id"))
input(type: "button", value:_("Back"), onClick: "history.back(1)", class: "yui-button")
button(class: "jenkins-button bfa-cause-management-back-button", _("Back"))
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
document.addEventListener("DOMContentLoaded", () => {
document.querySelector(".bfa-cause-management-back-button").addEventListener("click", () => {
history.back(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ l.layout(title: _("Failure Scan Options"), norefresh: true) {
}
st.include(it: mode.parent.project, page: "sidepanel.jelly")
l.'main-panel' {
st.adjunct(includes: "com.sonyericsson.jenkins.plugins.bfa.sod.ScanOnDemandBaseAction.ScanMode.resource")
f.form {
f.section(title: _("Select the option and scan the builds")) {
ScanOnDemandBaseAction.ScanMode.all().each { ScanOnDemandBaseAction.ScanMode option ->
f.entry(field: option.urlName,
f.entry(field: option.urlName, class: "bfa-scan-mode-build-type-radio-entry",
help: "/plugin/build-failure-analyzer/help/sod/${option.urlName}.html") {
span(class: "bfa-entry-data-holder", "data-root-url": "${rootURL}", "data-option-full-url": "${option.getFullUrl()}")
f.radio(name: "buildType",
value: option.urlName,
onclick: "document.location='${rootURL}/${option.getFullUrl()}';",
checked: option == mode,
title: option.displayName)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".bfa-scan-mode-build-type-radio-entry").forEach((entry) => {
const { rootUrl, optionFullUrl } = entry.querySelector(".bfa-entry-data-holder").dataset;

entry.querySelector(".jenkins-radio").addEventListener("click", () => {
document.location = `${rootURL}/${optionFullUrl}`;
});
})
});

0 comments on commit 11082ba

Please sign in to comment.