Skip to content

Commit

Permalink
[JENKINS-73885] Remove inline onclick handler from script removal form
Browse files Browse the repository at this point in the history
  • Loading branch information
yaroslavafenkin authored and basil committed Oct 10, 2024
1 parent 9510d9a commit a157cb6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
document.addEventListener('DOMContentLoaded', () => {
const removeScriptButtons = document.querySelectorAll(".scriptler-remove-script-form");
removeScriptButtons.forEach(button => button.addEventListener("click", (e) => {
const name = e.currentTarget.getAttribute('data-name');
if (!confirm("Sure you want to delete [" + name + "]?")) {
e.preventDefault();
}
}));
});
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
<a href="editScript?id=${t.id}" class="scriptler-link-button scriptler-icon-slot">
<l:icon tooltip="${%editScript} ${t.name}" src="symbol-create-outline plugin-ionicons-api" class="icon-sm jenkins-!-text-color-secondary" />
</a>
<form method="post" action="removeScript" class="scriptler-inline scriptler-icon-slot" data-name="${t.name}" onclick="return confirmDelete(this)">
<st:adjunct includes="org.jenkinsci.plugins.scriptler.ScriptlerManagement.confirm-remove" />
<form method="post" action="removeScript" class="scriptler-inline scriptler-icon-slot scriptler-remove-script-form" data-name="${t.name}">
<input type="hidden" name="id" value="${t.id}" />
<button type="submit" name="submit_param" value="submit_value" class="scriptler-link-button">
<l:icon tooltip="${%removeScript} ${t.name}" src="symbol-trash-outline plugin-ionicons-api" class="icon-sm jenkins-!-text-color-secondary" />
Expand Down Expand Up @@ -101,16 +102,6 @@
</j:forEach>
</table>
</div>
<script>
function confirmDelete(element) {
var name = element.getAttribute('data-name');
if (confirm("Sure you want to delete ["+name+"]?")) {
return true;
}else{
return false;
}
}
</script>
</l:main-panel>
</l:layout>
</j:jelly>

0 comments on commit a157cb6

Please sign in to comment.