User:Justarandomamerican/globalUserLock.js: Difference between revisions
From WikiOasis Meta
More actions
No edit summary |
No edit summary |
||
| Line 14: | Line 14: | ||
const TOOL_TITLE = 'Global User Lock'; | const TOOL_TITLE = 'Global User Lock'; | ||
const PORTLET_ID = 'ca-global-user-lock'; | const PORTLET_ID = 'ca-global-user-lock'; | ||
const MAX_ACCOUNTS = 200; | const MAX_ACCOUNTS = 200; | ||
| Line 66: | Line 65: | ||
windowManager = new OO.ui.WindowManager(); | windowManager = new OO.ui.WindowManager(); | ||
$( document.body ).append( windowManager.$element ); | $( document.body ).append( windowManager.$element ); | ||
windowManager.addWindows( [ new GULDialog() ] ); | // Add BOTH dialogs to the same manager to prevent the focus trap freeze | ||
windowManager.addWindows( [ new GULDialog(), new OO.ui.MessageDialog() ] ); | |||
} | } | ||
windowManager.openWindow( 'gulDialog' ); | windowManager.openWindow( 'gulDialog' ); | ||
| Line 468: | Line 468: | ||
'\nThis action will be logged. Proceed?'; | '\nThis action will be logged. Proceed?'; | ||
windowManager.openWindow( 'message', { | |||
if ( ! | title: 'Confirm global lock', | ||
message: confirmMessage, | |||
actions: [ | |||
{ action: 'accept', label: 'Lock accounts', flags: [ 'primary', 'destructive' ] }, | |||
{ action: 'reject', label: 'Cancel', flags: [ 'safe' ] } | |||
] | |||
} ).closed.then( function ( data ) { | |||
if ( !data || data.action !== 'accept' ) { return; } | |||
$( '#gul-btn-lock, #gul-btn-search' ).prop( 'disabled', true ); | $( '#gul-btn-lock, #gul-btn-search' ).prop( 'disabled', true ); | ||
| Line 502: | Line 509: | ||
lockAccount( username, reason, hide, suppress ) | lockAccount( username, reason, hide, suppress ) | ||
.done( function ( | .done( function ( result ) { | ||
if ( | if ( result.error ) { | ||
failed++; | failed++; | ||
setBadge( username, 'failed', 'Error: ' + mw.html.escape( | setBadge( username, 'failed', 'Error: ' + mw.html.escape( result.error.info || result.error.code ) ); | ||
} else { | } else { | ||
locked++; | locked++; | ||