mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-27 23:50:30 +00:00
Settings link is hidden to non-JS users when beta and AMC unavailable
Bug: T198265 Change-Id: I6340da6dbbd031d8c91ae99801065bafe9245920
This commit is contained in:
parent
3ec0ca1e6e
commit
da5798ef22
|
@ -207,14 +207,31 @@ final class Definitions {
|
|||
*/
|
||||
public function insertMobileOptionsItem( Group $group ) {
|
||||
$title = $this->context->getTitle();
|
||||
$config = $this->context->getConfig();
|
||||
$returnToTitle = $title->getPrefixedText();
|
||||
$user = $this->user;
|
||||
$betaEnabled = $config->get( 'MFEnableBeta' );
|
||||
/*
|
||||
* to avoid linking to an empty settings page we make this jsonly when:
|
||||
* - AMC and beta is disabled (if logged in there is nothing to show)
|
||||
* - user is logged out and beta is disabled (beta is the only thing a non-js user can do)
|
||||
* In future we might want to make this a static function on Special:MobileOptions.
|
||||
*/
|
||||
$jsonly = ( $user->isAnon() && !$betaEnabled ) ||
|
||||
( !$user->isAnon() && !$config->get( 'MFAdvancedMobileContributions' ) &&
|
||||
!$betaEnabled
|
||||
);
|
||||
|
||||
$group->insertEntry( SingleMenuEntry::create(
|
||||
$item = SingleMenuEntry::create(
|
||||
'settings',
|
||||
$this->context->msg( 'mobile-frontend-main-menu-settings' )->escaped(),
|
||||
SpecialPage::getTitleFor( 'MobileOptions' )
|
||||
->getLocalURL( [ 'returnto' => $returnToTitle ] )
|
||||
) );
|
||||
);
|
||||
if ( $jsonly ) {
|
||||
$item->setJSOnly();
|
||||
}
|
||||
$group->insertEntry( $item );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,6 +32,10 @@ class SingleMenuEntry implements IMenuEntry {
|
|||
* @var array
|
||||
*/
|
||||
private $attributes;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isJSOnly;
|
||||
|
||||
/**
|
||||
* Create a simple menu element with one component
|
||||
|
@ -82,7 +86,7 @@ class SingleMenuEntry implements IMenuEntry {
|
|||
* @inheritDoc
|
||||
*/
|
||||
public function getCSSClasses(): array {
|
||||
return [];
|
||||
return $this->isJSOnly ? [ 'jsonly' ] : [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,4 +139,11 @@ class SingleMenuEntry implements IMenuEntry {
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark entry as JS only.
|
||||
*/
|
||||
public function setJSOnly() {
|
||||
$this->isJSOnly = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue