Skip to content

Commit 0536558

Browse files
[JENKINS-73956] Extract inline event handlers from LegacyJobConfigMigrationMonitor/manage.jelly (#241)
1 parent 4af9723 commit 0536558

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

src/main/resources/hudson/plugins/copyartifact/monitor/LegacyJobConfigMigrationMonitor/manage.jelly

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,31 @@ THE SOFTWARE.
3939
<a href="#"
4040
class="action"
4141
title="${%SelectAll.title}"
42-
onclick="selectAll(this);return false;">${%SelectAll}</a>
42+
data-action="select-all">${%SelectAll}</a>
4343
<a href="#"
4444
class="action"
4545
title="${%SelectAllMigratable.title}"
46-
onclick="selectAllMigratable(this);return false;">${%SelectAllMigratable}</a>
46+
data-action="select-migratable">${%SelectAllMigratable}</a>
4747
<a href="#"
4848
class="action"
4949
title="${%SelectAllValid.title}"
50-
onclick="selectAllValid(this);return false;">${%SelectAllValid}</a>
50+
data-action="select-all-valid">${%SelectAllValid}</a>
5151
<a href="#"
5252
class="action"
5353
title="${%SelectAllInvalid.title}"
54-
onclick="selectAllInvalid(this);return false;">${%SelectAllInvalid}</a>
54+
data-action="select-all-invalid">${%SelectAllInvalid}</a>
5555
</div>
5656
<div class="action-panel">
5757
<span class="yui-button">
58-
<button class="action-migrate-selected" onclick="confirmAndMigrateAllSelected(this);"
58+
<button class="action action-migrate-selected"
5959
data-url="${rootURL}/${it.url}/migrateAllSelected"
6060
data-confirm-template="${%MigrateAllSelected_confirm}"
6161
data-nothing-selected="${%MigrateAllSelected_nothing}">
6262
${%MigrateAllSelected}
6363
</button>
6464
</span>
6565
<span class="yui-button">
66-
<button class="action-ignore-selected" onclick="confirmAndIgnoreAllSelected(this);"
66+
<button class="action action-ignore-selected"
6767
data-url="${rootURL}/${it.url}/ignoreAllSelected"
6868
data-confirm-template="${%IgnoreAllSelected_confirm}"
6969
data-nothing-selected="${%IgnoreMigrateAllSelected_nothing}">
@@ -187,32 +187,32 @@ THE SOFTWARE.
187187
<a href="#"
188188
class="action"
189189
title="${%SelectAll.title}"
190-
onclick="selectAll(this);return false;">${%SelectAll}</a>
190+
data-action="select-all">${%SelectAll}</a>
191191
<a href="#"
192192
class="action"
193193
title="${%SelectAllMigratable.title}"
194-
onclick="selectAllMigratable(this);return false;">${%SelectAllMigratable}</a>
194+
data-action="select-migratable">${%SelectAllMigratable}</a>
195195
<a href="#"
196196
class="action"
197197
title="${%SelectAllValid.title}"
198-
onclick="selectAllValid(this);return false;">${%SelectAllValid}</a>
198+
data-action="select-all-valid">${%SelectAllValid}</a>
199199
<a href="#"
200200
class="action"
201201
title="${%SelectAllInvalid.title}"
202-
onclick="selectAllInvalid(this);return false;">${%SelectAllInvalid}</a>
202+
data-action="select-all-invalid">${%SelectAllInvalid}</a>
203203
</div>
204204

205205
<div class="action-panel">
206206
<span class="yui-button">
207-
<button class="action-migrate-selected" onclick="confirmAndMigrateAllSelected(this);"
207+
<button class="action action-migrate-selected"
208208
data-url="${rootURL}/${it.url}/migrateAllSelected"
209209
data-confirm-template="${%MigrateAllSelected_confirm}"
210210
data-nothing-selected="${%MigrateAllSelected_nothing}">
211211
${%MigrateAllSelected}
212212
</button>
213213
</span>
214214
<span class="yui-button">
215-
<button class="action-ignore-selected" onclick="confirmAndIgnoreAllSelected(this);"
215+
<button class="action action-ignore-selected"
216216
data-url="${rootURL}/${it.url}/ignoreAllSelected"
217217
data-confirm-template="${%IgnoreAllSelected_confirm}"
218218
data-nothing-selected="${%IgnoreMigrateAllSelected_nothing}">

src/main/resources/hudson/plugins/copyartifact/monitor/LegacyJobConfigMigrationMonitor/resources.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,6 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
* THE SOFTWARE.
2323
*/
24-
function selectAll(anchor){
25-
_selectAllThat(anchor, '.checkbox-line');
26-
}
27-
function selectAllMigratable(anchor){
28-
_selectAllThat(anchor, '.checkbox-line.migratable-line.valid-line');
29-
}
30-
function selectAllValid(anchor){
31-
_selectAllThat(anchor, '.checkbox-line.valid-line');
32-
}
33-
function selectAllInvalid(anchor){
34-
_selectAllThat(anchor, '.checkbox-line.invalid-line');
35-
}
3624

3725
function _selectAllThat(anchor, selector){
3826
var parent = anchor.closest('.legacy-copy-artifact');
@@ -67,14 +55,6 @@ function checkTheDesiredOne(allCheckBoxes, concernedCheckBoxes){
6755
}
6856
}
6957

70-
function confirmAndIgnoreAllSelected(button){
71-
confirmAndSendRequest(button);
72-
}
73-
74-
function confirmAndMigrateAllSelected(button){
75-
confirmAndSendRequest(button);
76-
}
77-
7858
function confirmAndSendRequest(button){
7959
var parent = button.closest('.legacy-copy-artifact');
8060
var allCheckBoxes = parent.querySelectorAll('.checkbox-line');
@@ -181,5 +161,25 @@ function onCheckChanged(checkBox){
181161
return false;
182162
}
183163
);
164+
165+
const actionSelectors = {
166+
"select-all": '.checkbox-line',
167+
"select-migratable": '.checkbox-line.migratable-line.valid-line',
168+
"select-all-valid": '.checkbox-line.valid-line',
169+
"select-all-invalid": '.checkbox-line.invalid-line'
170+
}
171+
172+
document.querySelectorAll("a.action").forEach(anchor => {
173+
anchor.addEventListener("click", (event) => {
174+
event.preventDefault();
175+
_selectAllThat(event.target, actionSelectors[event.target.dataset.action]);
176+
});
177+
});
178+
179+
document.querySelectorAll(".action-panel button.action").forEach((button) => {
180+
button.addEventListener("click", (event) => {
181+
confirmAndSendRequest(event.target);
182+
});
183+
});
184184
});
185185
})();

0 commit comments

Comments
 (0)