Drop smart logout handling in favor of core ready.js

MediaWiki core added support of overrideLogoutSelector skin
config variable which allows us to define the logout button
selector. Thanks to that we do not have to ship our
custom/duplicated smart logout handler as we can use the
one shipped with ready.js.

Depends-On: Id313337c85229a5e8d0aada3a67d722048709597
Bug: T259200
Change-Id: Ie0192a176dfa8be994a544221aa71de75028d502
This commit is contained in:
Piotr Miazga (polishdeveloper) 2021-02-01 20:35:16 +01:00 committed by Jdlrobson
parent f31db9edf5
commit 5a2527d71d
3 changed files with 2 additions and 35 deletions

View file

@ -383,6 +383,7 @@ class MinervaHooks {
$config['search'] = false;
$config['collapsible'] = false;
$config['sortable'] = false;
$config['selectorLogoutLink'] = 'a.menu__item--logout';
}
}
}

View file

@ -268,37 +268,6 @@ module.exports = function () {
}
}
/**
* For logout links do the API logout first so system do not show interstitial step,
* and then redirect to LogoutPage (when user is already logged out) to show information
* about successful logout and information about caching.
*
* @param {string} selector Logout links selector
*/
function initSmartLogout( selector ) {
// Turn logout to a POST action
$( selector ).on( 'click', function ( e ) {
mw.notify(
mw.message( 'logging-out-notify' ).text(), {
tag: 'logout',
autoHide: false
}
);
api.postWithToken( 'csrf', {
action: 'logout'
} ).then(
function () {
location.reload();
},
function () {
toast.showOnPageReload( mw.message( 'logout-failed' ).text() );
location.reload();
}
);
e.preventDefault();
} );
}
/**
* Initialisation function for registration date on user page
*
@ -453,7 +422,6 @@ module.exports = function () {
return !isUserUri( element.href );
} )
);
initSmartLogout( '.menu__item--logout' );
initUserRedLinks();
} );
};

View file

@ -540,9 +540,7 @@
"mobile-frontend-redirected-from",
"minerva-talk-full-page",
"minerva-talk-topic-feedback",
"minerva-talk-reply-success",
"logging-out-notify",
"logout-failed"
"minerva-talk-reply-success"
],
"styles": [
"resources/skins.minerva.scripts/styles.less",