Skip to content

Commit

Permalink
[JENKINS-73948] Extract inline JavaScript from `LockableResourcesRoot…
Browse files Browse the repository at this point in the history
…Action/tableQueue/table.jelly` (#719)
  • Loading branch information
yaroslavafenkin authored Oct 22, 2024
1 parent 83131d9 commit 102a16c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
document.addEventListener("DOMContentLoaded", function () {
notificationBar.show(
document.querySelector(".lockable-resources-queue-too-long-message").dataset.warningMessage,
notificationBar.WARNING,
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ THE SOFTWARE.
</j:when>
<j:otherwise>
<j:if test="${oldestQueue.takeTooLong()}">
<script type="text/javascript">notificationBar.show('${%queue.warning.count(queue.getAll().size(), h.getTimeSpanString(oldestQueue.getQueuedTimestamp()))}', notificationBar.WARNING)</script>
<span class="lockable-resources-queue-too-long-message"
data-warning-message="${%queue.warning.count(queue.getAll().size(), h.getTimeSpanString(oldestQueue.getQueuedTimestamp()))}"
style="display:none"/>
<st:adjunct
includes="org.jenkins.plugins.lockableresources.actions.LockableResourcesRootAction.tableQueue.queue-too-long"/>
<p class="jenkins-!-warning-color">${%queue.warning.count(queue.getAll().size(), h.getTimeSpanString(oldestQueue.getQueuedTimestamp()))}</p>
<pre>${%queue.warning.count.detail}</pre>
</j:if>
Expand Down Expand Up @@ -94,8 +98,8 @@ THE SOFTWARE.
<td>
<l:hasPermission permission="${it.QUEUE}">
<button
onClick="changeQueueOrder(this, '${queuedItem.id}');"
class="jenkins-button jenkins-!-success-color"
data-queue-item-id="${queuedItem.id}"
class="jenkins-button jenkins-!-success-color lockable-resources-change-queue-order"
tooltip="${%btn.changeOrder.detail} ${queuedItem.id}"
>
${%btn.changeOrder}
Expand Down
7 changes: 6 additions & 1 deletion src/main/webapp/js/lockable-resources.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2020, Tobias Gruetzmacher

function changeQueueOrder(button, queueId) {
function changeQueueOrder(queueId) {

dialog
.prompt(i18n("queue-title", queueId), {
Expand Down Expand Up @@ -154,6 +154,11 @@ jQuery(document).ready(function () {
});
});

document.querySelectorAll(".lockable-resources-change-queue-order").forEach(function (button) {
button.addEventListener("click", function (event) {
changeQueueOrder(event.target.dataset.queueItemId);
});

document.querySelectorAll(".lockable-resources-replace-note").forEach(function (anchor) {
anchor.addEventListener("click", function (event) {
event.preventDefault();
Expand Down

0 comments on commit 102a16c

Please sign in to comment.