Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

User:Justarandomamerican/globalUserLock.js: Difference between revisions

From WikiOasis Meta
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 API_ENDPOINT = mw.config.get( 'wgScriptPath' ) + '/api.php';
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?';


OO.ui.confirm( confirmMessage ).done( function ( confirmed ) {
windowManager.openWindow( 'message', {
if ( !confirmed ) { return; }
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 ( data ) {
.done( function ( result ) {
if ( data.error ) {
if ( result.error ) {
failed++;
failed++;
setBadge( username, 'failed', 'Error: ' + mw.html.escape( data.error.info || data.error.code ) );
setBadge( username, 'failed', 'Error: ' + mw.html.escape( result.error.info || result.error.code ) );
} else {
} else {
locked++;
locked++;
Cookies help us deliver our services. By using our services, you agree to our use of cookies.