mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-24 14:23:53 +00:00
Merge "On user pages, move language icon from Toolbar to Overflow menu"
This commit is contained in:
commit
937d2b48ea
|
@ -56,6 +56,7 @@
|
|||
"minerva-page-actions-user-rights": "User rights",
|
||||
"minerva-page-actions-logs": "Logs",
|
||||
"minerva-page-actions-wikibase": "{{WBREPONAME}} item",
|
||||
"minerva-page-actions-language-switcher": "Languages",
|
||||
"skinname-minerva": "MinervaNeue",
|
||||
"minerva-skin-desc": "A responsive mobile first skin",
|
||||
"skin-minerva-issue-learn-more": "Learn more",
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
"minerva-page-actions-user-rights": "In the secondary page menu for user pages, the user rights button label",
|
||||
"minerva-page-actions-logs": "In the secondary page menu for user pages, the user logs button label",
|
||||
"minerva-page-actions-wikibase": "In the secondary page menu, the wikibase item button label",
|
||||
"minerva-page-actions-language-switcher": "In the secondary page menu, the language switcher item button label\n{{Identical|Languages}}",
|
||||
"skinname-minerva": "{{name}}",
|
||||
"minerva-skin-desc": "{{desc|name=Minerva Neue|url=https://www.mediawiki.org/wiki/Skin:Minerva_Neue|what=skin}}",
|
||||
"skin-minerva-issue-learn-more": "Label for link that allows expanding of ambox issue templates.",
|
||||
|
|
|
@ -52,10 +52,13 @@ return [
|
|||
*/
|
||||
$skinOptions = $services->getService( 'Minerva.SkinOptions' );
|
||||
$context = RequestContext::getMain();
|
||||
$title = $context->getTitle();
|
||||
$output = $context->getOutput();
|
||||
$user = $context->getUser();
|
||||
$userPageHelper = $services->getService( 'Minerva.SkinUserPageHelper' );
|
||||
$toolbarBuilder = new PageActionsMenu\ToolbarBuilder(
|
||||
$context->getTitle(),
|
||||
$context->getUser(),
|
||||
$title,
|
||||
$user,
|
||||
$context,
|
||||
$services->getPermissionManager(),
|
||||
$services->getService( 'Minerva.Permissions' ),
|
||||
|
@ -63,10 +66,15 @@ return [
|
|||
$services->get( 'Minerva.SkinUserPageHelper' )
|
||||
);
|
||||
if ( $skinOptions->get( SkinOptions::OPTION_OVERFLOW_SUBMENU ) ) {
|
||||
$hasVariants = $title->getPageLanguage()->hasVariants();
|
||||
$hasLanguages = count( $output->getLanguageLinks() );
|
||||
$overflowBuilder = $userPageHelper->isUserPage() ?
|
||||
new PageActionsMenu\UserNamespaceOverflowBuilder(
|
||||
$title,
|
||||
$context,
|
||||
$userPageHelper
|
||||
$userPageHelper,
|
||||
$services->getService( 'Minerva.Permissions' ),
|
||||
$hasVariants || $hasLanguages
|
||||
) :
|
||||
new PageActionsMenu\DefaultOverflowBuilder(
|
||||
$context
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
namespace MediaWiki\Minerva\Menu\Entries;
|
||||
|
||||
use MessageLocalizer;
|
||||
use MinervaUI;
|
||||
use SpecialPage;
|
||||
use Title;
|
||||
|
||||
|
@ -39,22 +38,37 @@ class LanguageSelectorEntry implements IMenuEntry {
|
|||
* @var bool
|
||||
*/
|
||||
private $doesPageHaveLanguages;
|
||||
/**
|
||||
* @var string An icon class generated via MinervaUI::iconClass()
|
||||
*/
|
||||
private $iconClass;
|
||||
|
||||
/**
|
||||
* @var string A translatable label used as text and title
|
||||
*/
|
||||
private $label;
|
||||
|
||||
/**
|
||||
* LanguageSelectorEntry constructor.
|
||||
* @param Title $title Current Title
|
||||
* @param bool $doesPageHaveLanguages Whether the page is also available in other
|
||||
* languages or variants
|
||||
* @param MessageLocalizer $messageLocalizer Used for translation texts
|
||||
*
|
||||
* @param string $iconClass An icon class generated via MinervaUI::iconClass()
|
||||
* @param string $label Menu entry label and title
|
||||
*/
|
||||
public function __construct(
|
||||
Title $title,
|
||||
$doesPageHaveLanguages,
|
||||
MessageLocalizer $messageLocalizer
|
||||
MessageLocalizer $messageLocalizer,
|
||||
$iconClass,
|
||||
$label = 'mobile-frontend-language-article-heading'
|
||||
) {
|
||||
$this->title = $title;
|
||||
$this->doesPageHaveLanguages = $doesPageHaveLanguages;
|
||||
$this->messageLocalizer = $messageLocalizer;
|
||||
$this->iconClass = $iconClass;
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,14 +100,14 @@ class LanguageSelectorEntry implements IMenuEntry {
|
|||
} else {
|
||||
$switcherClasses .= ' disabled';
|
||||
}
|
||||
$iconClass = MinervaUI::iconClass( 'language-switcher', 'element', $switcherClasses );
|
||||
$msg = $this->messageLocalizer->msg( $this->label );
|
||||
|
||||
return [
|
||||
[
|
||||
'href' => $switcherLink,
|
||||
'class' => $iconClass,
|
||||
'text' => $this->messageLocalizer->msg( 'mobile-frontend-language-article-heading' ),
|
||||
'title' => $this->messageLocalizer->msg( 'mobile-frontend-language-article-heading' )
|
||||
'class' => $this->iconClass . $switcherClasses,
|
||||
'text' => $msg,
|
||||
'title' => $msg
|
||||
]
|
||||
|
||||
];
|
||||
|
|
|
@ -108,10 +108,17 @@ class ToolbarBuilder {
|
|||
public function getGroup( $doesPageHaveLanguages ): Group {
|
||||
$group = new Group();
|
||||
$permissions = $this->permissions;
|
||||
$userPageWithOveflowMode = $this->skinOptions->get( SkinOptions::OPTION_OVERFLOW_SUBMENU ) &&
|
||||
$this->userPageHelper->isUserPage();
|
||||
|
||||
if ( $permissions->isAllowed( IMinervaPagePermissions::SWITCH_LANGUAGE ) ) {
|
||||
$group->insertEntry( new LanguageSelectorEntry( $this->title, $doesPageHaveLanguages,
|
||||
$this->messageLocalizer ) );
|
||||
if ( !$userPageWithOveflowMode && $permissions->isAllowed(
|
||||
IMinervaPagePermissions::SWITCH_LANGUAGE ) ) {
|
||||
$group->insertEntry( new LanguageSelectorEntry(
|
||||
$this->title,
|
||||
$doesPageHaveLanguages,
|
||||
$this->messageLocalizer,
|
||||
MinervaUI::iconClass( 'language-switcher', 'element', '' ) )
|
||||
);
|
||||
}
|
||||
|
||||
if ( $permissions->isAllowed( IMinervaPagePermissions::WATCH ) ) {
|
||||
|
@ -122,8 +129,7 @@ class ToolbarBuilder {
|
|||
$group->insertEntry( $this->getHistoryPageAction() );
|
||||
}
|
||||
|
||||
if ( $this->skinOptions->get( SkinOptions::OPTION_OVERFLOW_SUBMENU ) &&
|
||||
$this->userPageHelper->isUserPage() ) {
|
||||
if ( $userPageWithOveflowMode ) {
|
||||
// User links are hidden when Overflow menu is visible. We want to show Contributions
|
||||
// link on toolbar only when overflow is visible
|
||||
$group->insertEntry( $this->createContributionsPageAction() );
|
||||
|
|
|
@ -22,10 +22,13 @@ namespace MediaWiki\Minerva\Menu\PageActions;
|
|||
|
||||
use Hooks;
|
||||
use MediaWiki\Minerva\Menu\Group;
|
||||
use MediaWiki\Minerva\Menu\Entries\LanguageSelectorEntry;
|
||||
use MediaWiki\Minerva\Permissions\IMinervaPagePermissions;
|
||||
use MediaWiki\Minerva\SkinUserPageHelper;
|
||||
use MessageLocalizer;
|
||||
use MinervaUI;
|
||||
use MWException;
|
||||
use Title;
|
||||
use SpecialPage;
|
||||
use User;
|
||||
|
||||
|
@ -41,14 +44,41 @@ class UserNamespaceOverflowBuilder implements IOverflowBuilder {
|
|||
*/
|
||||
private $pageUser;
|
||||
|
||||
/**
|
||||
* @var Title
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @var IMinervaPagePermissions
|
||||
*/
|
||||
private $permissions;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $doesPageHaveLanguages;
|
||||
|
||||
/**
|
||||
* Initialize the overflow menu visible on the User namespace
|
||||
* @param Title $title
|
||||
* @param MessageLocalizer $msgLocalizer
|
||||
* @param SkinUserPageHelper $userPageHelper
|
||||
* @param IMinervaPagePermissions $permissions
|
||||
* @param bool $doesPageHaveLanguages
|
||||
*/
|
||||
public function __construct( MessageLocalizer $msgLocalizer, SkinUserPageHelper $userPageHelper ) {
|
||||
public function __construct(
|
||||
Title $title,
|
||||
MessageLocalizer $msgLocalizer,
|
||||
SkinUserPageHelper $userPageHelper,
|
||||
IMinervaPagePermissions $permissions,
|
||||
$doesPageHaveLanguages
|
||||
) {
|
||||
$this->title = $title;
|
||||
$this->messageLocalizer = $msgLocalizer;
|
||||
$this->pageUser = $userPageHelper->getPageUser();
|
||||
$this->permissions = $permissions;
|
||||
$this->doesPageHaveLanguages = $doesPageHaveLanguages;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,6 +87,14 @@ class UserNamespaceOverflowBuilder implements IOverflowBuilder {
|
|||
*/
|
||||
public function getGroup( array $toolbox ): Group {
|
||||
$group = new Group();
|
||||
if ( $this->permissions->isAllowed( IMinervaPagePermissions::SWITCH_LANGUAGE ) ) {
|
||||
$group->insertEntry( new LanguageSelectorEntry( $this->title,
|
||||
$this->doesPageHaveLanguages, $this->messageLocalizer,
|
||||
MinervaUI::iconClass( 'language-switcher-base20', 'before',
|
||||
'minerva-page-actions-language-switcher toggle-list-item__anchor--menu' ),
|
||||
'minerva-page-actions-language-switcher'
|
||||
) );
|
||||
}
|
||||
$group->insertEntry( $this->build(
|
||||
'uploads', 'upload', SpecialPage::getTitleFor( 'Uploads', $this->pageUser )->getLocalURL()
|
||||
) );
|
||||
|
@ -102,8 +140,8 @@ class UserNamespaceOverflowBuilder implements IOverflowBuilder {
|
|||
new PageActionMenuEntry(
|
||||
'page-actions-overflow-' . $name,
|
||||
$href,
|
||||
MinervaUI::iconClass(
|
||||
'', 'before', 'wikimedia-ui-' . $icon . '-base20 toggle-list-item__anchor--menu'
|
||||
MinervaUI::iconClass( '', 'before',
|
||||
'wikimedia-ui-' . $icon . '-base20 toggle-list-item__anchor--menu'
|
||||
),
|
||||
$this->messageLocalizer->msg( 'minerva-page-actions-' . $name )
|
||||
) : null;
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
}
|
||||
|
||||
// used to disable the languages icon.
|
||||
.mw-ui-icon-element.disabled {
|
||||
.mw-ui-icon-element.disabled,
|
||||
.language-selector.disabled {
|
||||
cursor: default;
|
||||
opacity: 0.25;
|
||||
}
|
||||
|
|
|
@ -306,6 +306,10 @@
|
|||
"invert": {
|
||||
"color": "#fff",
|
||||
"global": false
|
||||
},
|
||||
"base20": {
|
||||
"color": "#54595d",
|
||||
"global": false
|
||||
}
|
||||
},
|
||||
"images": {
|
||||
|
@ -315,7 +319,10 @@
|
|||
"mainmenu": "resources/skins.minerva.icons.images/hamburger.svg",
|
||||
"edit": "resources/skins.minerva.icons.images/editLocked.svg",
|
||||
"edit-enabled": "resources/skins.minerva.icons.images/edit.svg",
|
||||
"language-switcher": "resources/skins.minerva.icons.images/languageSwitcher.svg",
|
||||
"language-switcher": {
|
||||
"file": "resources/skins.minerva.icons.images/languageSwitcher.svg",
|
||||
"variants": [ "base20" ]
|
||||
},
|
||||
"profile": "resources/skins.minerva.icons.images/profile.svg",
|
||||
"clock": {
|
||||
"file": "resources/skins.minerva.icons.images/clock.svg",
|
||||
|
|
Loading…
Reference in a new issue