mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-24 23:55:53 +00:00
Merge "Show empty language portal if HTML has been added after portal"
This commit is contained in:
commit
9d9ed35629
|
@ -346,12 +346,16 @@ class VectorTemplate extends BaseTemplate {
|
||||||
case 'LANGUAGES':
|
case 'LANGUAGES':
|
||||||
// @phan-suppress-next-line PhanUndeclaredMethod
|
// @phan-suppress-next-line PhanUndeclaredMethod
|
||||||
$languages = $skin->getLanguages();
|
$languages = $skin->getLanguages();
|
||||||
if ( count( $languages ) ) {
|
$portal = $this->getMenuData(
|
||||||
$props[] = $this->getMenuData(
|
'lang',
|
||||||
'lang',
|
$languages,
|
||||||
$languages,
|
self::MENU_TYPE_PORTAL
|
||||||
self::MENU_TYPE_PORTAL
|
);
|
||||||
);
|
// The language portal will be added provided either
|
||||||
|
// languages exist or there is a value in html-after-portal
|
||||||
|
// for example to show the add language wikidata link (T252800)
|
||||||
|
if ( count( $languages ) || $portal['html-after-portal'] ) {
|
||||||
|
$props[] = $portal;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -445,7 +449,6 @@ class VectorTemplate extends BaseTemplate {
|
||||||
array $options = [],
|
array $options = [],
|
||||||
bool $setLabelToSelected = false
|
bool $setLabelToSelected = false
|
||||||
) : array {
|
) : array {
|
||||||
$class = ( count( $urls ) == 0 ) ? 'vector-menu-empty emptyPortlet' : '';
|
|
||||||
$extraClasses = [
|
$extraClasses = [
|
||||||
self::MENU_TYPE_DROPDOWN => 'vector-menu vector-menu-dropdown vectorMenu',
|
self::MENU_TYPE_DROPDOWN => 'vector-menu vector-menu-dropdown vectorMenu',
|
||||||
self::MENU_TYPE_TABS => 'vector-menu vector-menu-tabs vectorTabs',
|
self::MENU_TYPE_TABS => 'vector-menu vector-menu-tabs vectorTabs',
|
||||||
|
@ -459,7 +462,6 @@ class VectorTemplate extends BaseTemplate {
|
||||||
$msgObj = $this->msg( self::MENU_LABEL_KEYS[ $label ] ?? $label );
|
$msgObj = $this->msg( self::MENU_LABEL_KEYS[ $label ] ?? $label );
|
||||||
$props = [
|
$props = [
|
||||||
'id' => "p-$label",
|
'id' => "p-$label",
|
||||||
'class' => trim( "$class $extraClasses[$type]" ),
|
|
||||||
'label-id' => "p-{$label}-label",
|
'label-id' => "p-{$label}-label",
|
||||||
// If no message exists fallback to plain text (T252727)
|
// If no message exists fallback to plain text (T252727)
|
||||||
'label' => $msgObj->exists() ? $msgObj->text() : $label,
|
'label' => $msgObj->exists() ? $msgObj->text() : $label,
|
||||||
|
@ -482,6 +484,11 @@ class VectorTemplate extends BaseTemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
$props['html-after-portal'] = $isPortal ? $this->getAfterPortlet( $label ) : '';
|
$props['html-after-portal'] = $isPortal ? $this->getAfterPortlet( $label ) : '';
|
||||||
|
|
||||||
|
// Mark the portal as empty if it has no content
|
||||||
|
$class = ( count( $urls ) == 0 && !$props['html-after-portal'] )
|
||||||
|
? 'vector-menu-empty emptyPortlet' : '';
|
||||||
|
$props['class'] = trim( "$class $extraClasses[$type]" );
|
||||||
return $props;
|
return $props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,15 +154,14 @@ class VectorTemplateTest extends MediaWikiIntegrationTestCase {
|
||||||
|
|
||||||
$this->assertSame( $views, [
|
$this->assertSame( $views, [
|
||||||
'id' => 'p-views',
|
'id' => 'p-views',
|
||||||
'class' => 'vector-menu-empty emptyPortlet vector-menu vector-menu-tabs vectorTabs',
|
|
||||||
'label-id' => 'p-views-label',
|
'label-id' => 'p-views-label',
|
||||||
'label' => 'Views',
|
'label' => 'Views',
|
||||||
'html-userlangattributes' => $langAttrs,
|
'html-userlangattributes' => $langAttrs,
|
||||||
'html-items' => '',
|
'html-items' => '',
|
||||||
'class' => 'vector-menu-empty emptyPortlet vector-menu vector-menu-tabs vectorTabs',
|
|
||||||
'is-dropdown' => false,
|
'is-dropdown' => false,
|
||||||
'html-tooltip' => '',
|
'html-tooltip' => '',
|
||||||
'html-after-portal' => ''
|
'html-after-portal' => '',
|
||||||
|
'class' => 'vector-menu-empty emptyPortlet vector-menu vector-menu-tabs vectorTabs',
|
||||||
] );
|
] );
|
||||||
|
|
||||||
$variants = $props['data-variants'];
|
$variants = $props['data-variants'];
|
||||||
|
|
Loading…
Reference in a new issue