Make the preferences links into OOUI buttons when available

Change-Id: I87f665304f3bfc4ac63ca32ba28f0e37b79440f5
This commit is contained in:
James D. Forrester 2018-09-07 12:25:34 -07:00
parent 7a7713cb93
commit 2b7aa6ecad

View file

@ -115,23 +115,34 @@ class OATHAuthHooks {
$oathUser = self::getOATHUserRepository()->findByUser( $user );
// If there is no existing key, and the user is not allowed to enable it,
// we have nothing to show. (
// we have nothing to show.
if ( $oathUser->getKey() === null && !$user->isAllowed( 'oathauth-enable' ) ) {
return true;
}
$title = SpecialPage::getTitleFor( 'OATH' );
$msg = $oathUser->getKey() !== null ? 'oathauth-disable' : 'oathauth-enable';
$preferences[$msg] = [
'type' => 'info',
'raw' => 'true',
'default' => Linker::link(
$title,
// TODO: Drop this when isOouiEnabled always returns true.
if ( SpecialPreferences::isOouiEnabled( RequestContext::getMain() ) ) {
$control = new \OOUI\ButtonWidget( [
'href' => SpecialPage::getTitleFor( 'OATH' )->getLinkURL( [
'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText()
] ),
'label' => wfMessage( $msg )->text(),
] );
} else {
$control = Linker::link(
SpecialPage::getTitleFor( 'OATH' ),
wfMessage( $msg )->escaped(),
[],
[ 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() ]
),
);
}
$preferences[$msg] = [
'type' => 'info',
'raw' => true,
'default' => (string)$control,
'label-message' => 'oathauth-prefs-label',
'section' => 'personal/info', ];