Skip to content

Commit

Permalink
[JENKINS-73956] Extract inline event handlers from `LegacyJobConfigMi…
Browse files Browse the repository at this point in the history
…grationMonitor/manage.jelly` (#241)
  • Loading branch information
yaroslavafenkin authored Oct 24, 2024
1 parent 4af9723 commit 0536558
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,31 @@ THE SOFTWARE.
<a href="#"
class="action"
title="${%SelectAll.title}"
onclick="selectAll(this);return false;">${%SelectAll}</a>
data-action="select-all">${%SelectAll}</a>
<a href="#"
class="action"
title="${%SelectAllMigratable.title}"
onclick="selectAllMigratable(this);return false;">${%SelectAllMigratable}</a>
data-action="select-migratable">${%SelectAllMigratable}</a>
<a href="#"
class="action"
title="${%SelectAllValid.title}"
onclick="selectAllValid(this);return false;">${%SelectAllValid}</a>
data-action="select-all-valid">${%SelectAllValid}</a>
<a href="#"
class="action"
title="${%SelectAllInvalid.title}"
onclick="selectAllInvalid(this);return false;">${%SelectAllInvalid}</a>
data-action="select-all-invalid">${%SelectAllInvalid}</a>
</div>
<div class="action-panel">
<span class="yui-button">
<button class="action-migrate-selected" onclick="confirmAndMigrateAllSelected(this);"
<button class="action action-migrate-selected"
data-url="${rootURL}/${it.url}/migrateAllSelected"
data-confirm-template="${%MigrateAllSelected_confirm}"
data-nothing-selected="${%MigrateAllSelected_nothing}">
${%MigrateAllSelected}
</button>
</span>
<span class="yui-button">
<button class="action-ignore-selected" onclick="confirmAndIgnoreAllSelected(this);"
<button class="action action-ignore-selected"
data-url="${rootURL}/${it.url}/ignoreAllSelected"
data-confirm-template="${%IgnoreAllSelected_confirm}"
data-nothing-selected="${%IgnoreMigrateAllSelected_nothing}">
Expand Down Expand Up @@ -187,32 +187,32 @@ THE SOFTWARE.
<a href="#"
class="action"
title="${%SelectAll.title}"
onclick="selectAll(this);return false;">${%SelectAll}</a>
data-action="select-all">${%SelectAll}</a>
<a href="#"
class="action"
title="${%SelectAllMigratable.title}"
onclick="selectAllMigratable(this);return false;">${%SelectAllMigratable}</a>
data-action="select-migratable">${%SelectAllMigratable}</a>
<a href="#"
class="action"
title="${%SelectAllValid.title}"
onclick="selectAllValid(this);return false;">${%SelectAllValid}</a>
data-action="select-all-valid">${%SelectAllValid}</a>
<a href="#"
class="action"
title="${%SelectAllInvalid.title}"
onclick="selectAllInvalid(this);return false;">${%SelectAllInvalid}</a>
data-action="select-all-invalid">${%SelectAllInvalid}</a>
</div>

<div class="action-panel">
<span class="yui-button">
<button class="action-migrate-selected" onclick="confirmAndMigrateAllSelected(this);"
<button class="action action-migrate-selected"
data-url="${rootURL}/${it.url}/migrateAllSelected"
data-confirm-template="${%MigrateAllSelected_confirm}"
data-nothing-selected="${%MigrateAllSelected_nothing}">
${%MigrateAllSelected}
</button>
</span>
<span class="yui-button">
<button class="action-ignore-selected" onclick="confirmAndIgnoreAllSelected(this);"
<button class="action action-ignore-selected"
data-url="${rootURL}/${it.url}/ignoreAllSelected"
data-confirm-template="${%IgnoreAllSelected_confirm}"
data-nothing-selected="${%IgnoreMigrateAllSelected_nothing}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
function selectAll(anchor){
_selectAllThat(anchor, '.checkbox-line');
}
function selectAllMigratable(anchor){
_selectAllThat(anchor, '.checkbox-line.migratable-line.valid-line');
}
function selectAllValid(anchor){
_selectAllThat(anchor, '.checkbox-line.valid-line');
}
function selectAllInvalid(anchor){
_selectAllThat(anchor, '.checkbox-line.invalid-line');
}

function _selectAllThat(anchor, selector){
var parent = anchor.closest('.legacy-copy-artifact');
Expand Down Expand Up @@ -67,14 +55,6 @@ function checkTheDesiredOne(allCheckBoxes, concernedCheckBoxes){
}
}

function confirmAndIgnoreAllSelected(button){
confirmAndSendRequest(button);
}

function confirmAndMigrateAllSelected(button){
confirmAndSendRequest(button);
}

function confirmAndSendRequest(button){
var parent = button.closest('.legacy-copy-artifact');
var allCheckBoxes = parent.querySelectorAll('.checkbox-line');
Expand Down Expand Up @@ -181,5 +161,25 @@ function onCheckChanged(checkBox){
return false;
}
);

const actionSelectors = {
"select-all": '.checkbox-line',
"select-migratable": '.checkbox-line.migratable-line.valid-line',
"select-all-valid": '.checkbox-line.valid-line',
"select-all-invalid": '.checkbox-line.invalid-line'
}

document.querySelectorAll("a.action").forEach(anchor => {
anchor.addEventListener("click", (event) => {
event.preventDefault();
_selectAllThat(event.target, actionSelectors[event.target.dataset.action]);
});
});

document.querySelectorAll(".action-panel button.action").forEach((button) => {
button.addEventListener("click", (event) => {
confirmAndSendRequest(event.target);
});
});
});
})();

0 comments on commit 0536558

Please sign in to comment.