mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-28 09:30:17 +00:00
Merge "Refactor: Make VectorTabs template data conform with MenuDefinition"
This commit is contained in:
commit
358f26323e
|
@ -415,10 +415,11 @@ class VectorTemplate extends BaseTemplate {
|
|||
*/
|
||||
private function buildNamespacesProps() : array {
|
||||
$props = [
|
||||
'tabs-id' => 'p-namespaces',
|
||||
'empty-portlet' => ( count( $this->get( 'namespace_urls', [] ) ) == 0 ) ? 'emptyPortlet' : '',
|
||||
'id' => 'p-namespaces',
|
||||
'class' => ( count( $this->get( 'namespace_urls', [] ) ) == 0 ) ?
|
||||
'emptyPortlet vectorTabs' : 'vectorTabs',
|
||||
'label-id' => 'p-namespaces-label',
|
||||
'msg-label' => $this->getMsg( 'namespaces' )->text(),
|
||||
'label' => $this->getMsg( 'namespaces' )->text(),
|
||||
'html-userlangattributes' => $this->get( 'userlangattributes', '' ),
|
||||
'html-items' => '',
|
||||
];
|
||||
|
@ -464,10 +465,11 @@ class VectorTemplate extends BaseTemplate {
|
|||
*/
|
||||
private function buildViewsProps() : array {
|
||||
$props = [
|
||||
'tabs-id' => 'p-views',
|
||||
'empty-portlet' => ( count( $this->get( 'view_urls', [] ) ) == 0 ) ? 'emptyPortlet' : '',
|
||||
'id' => 'p-views',
|
||||
'class' => ( count( $this->get( 'view_urls', [] ) ) == 0 ) ?
|
||||
'emptyPortlet vectorTabs' : 'vectorTabs',
|
||||
'label-id' => 'p-views-label',
|
||||
'msg-label' => $this->getMsg( 'views' )->text(),
|
||||
'label' => $this->getMsg( 'views' )->text(),
|
||||
'html-userlangattributes' => $this->get( 'userlangattributes', '' ),
|
||||
'html-items' => '',
|
||||
];
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
{{!
|
||||
string tabs-id
|
||||
string|null empty-portlet
|
||||
string label-id
|
||||
string|null msg-label
|
||||
string|null html-userlangattributes
|
||||
string|null html-items
|
||||
See @typedef MenuDefinition
|
||||
}}
|
||||
<div id="{{tabs-id}}" role="navigation" class="vectorTabs {{empty-portlet}}" aria-labelledby="{{label-id}}">
|
||||
<h3 id="{{label-id}}">{{msg-label}}</h3>
|
||||
<div id="{{id}}" role="navigation" class="{{class}}" aria-labelledby="{{label-id}}">
|
||||
<h3 id="{{label-id}}">{{label}}</h3>
|
||||
<ul {{{html-userlangattributes}}}>
|
||||
{{{html-items}}}
|
||||
</ul>
|
||||
|
|
|
@ -3,11 +3,14 @@ import vectorTabsTemplate from '!!raw-loader!../includes/templates/VectorTabs.mu
|
|||
|
||||
export { vectorTabsTemplate };
|
||||
|
||||
/**
|
||||
* @type {MenuDefinition}
|
||||
*/
|
||||
export const pageActionsData = {
|
||||
'tabs-id': 'p-views',
|
||||
'empty-portlet': '',
|
||||
id: 'p-views',
|
||||
class: 'vectorTabs',
|
||||
'label-id': 'p-views-label',
|
||||
'msg-label': 'Views',
|
||||
label: 'Views',
|
||||
'html-userlangattributes': htmluserlangattributes,
|
||||
'html-items': `<li id="ca-view" class="collapsible selected">
|
||||
<a href="/wiki/Main_Page">Read</a>
|
||||
|
@ -22,11 +25,14 @@ You can view its source [⌃⌥e]" accesskey="e">View source</a></li>
|
|||
`
|
||||
};
|
||||
|
||||
/**
|
||||
* @type {MenuDefinition}
|
||||
*/
|
||||
export const namespaceTabsData = {
|
||||
'tabs-id': 'p-namespaces',
|
||||
'empty-portlet': '',
|
||||
id: 'p-namespaces',
|
||||
class: 'vectorTabs',
|
||||
'label-id': 'p-namespaces-label',
|
||||
'msg-label': 'Namespaces',
|
||||
label: 'Namespaces',
|
||||
'html-userlangattributes': htmluserlangattributes,
|
||||
'html-items': `<li id="ca-nstab-main" class="selected"><a href="/wiki/Main_Page" title="View the content page [⌃⌥c]" accesskey="c">Main page</a></li>
|
||||
<li id="ca-talk"><a href="/wiki/Talk:Main_Page" rel="discussion" title="Discussion about the content page [⌃⌥t]" accesskey="t">Talk (3)</a></li>`
|
||||
|
|
|
@ -134,6 +134,7 @@ class VectorTemplateTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers ::buildViewsProps
|
||||
* @covers ::buildActionsProps
|
||||
* @covers ::buildVariantsProps
|
||||
* @covers ::buildNamespacesProps
|
||||
* @covers ::getMenuProps
|
||||
*/
|
||||
public function testGetMenuProps() {
|
||||
|
@ -147,17 +148,21 @@ class VectorTemplateTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$props = $openVectorTemplate->getMenuProps();
|
||||
$views = $openVectorTemplate->buildViewsProps();
|
||||
$namespaces = $openVectorTemplate->buildNamespacesProps();
|
||||
$this->assertSame( $views, [
|
||||
'tabs-id' => 'p-views',
|
||||
'empty-portlet' => 'emptyPortlet',
|
||||
'id' => 'p-views',
|
||||
'class' => 'emptyPortlet vectorTabs',
|
||||
'label-id' => 'p-views-label',
|
||||
'msg-label' => 'Views',
|
||||
'label' => 'Views',
|
||||
'html-userlangattributes' => $langAttrs,
|
||||
'html-items' => '',
|
||||
'class' => 'emptyPortlet vectorTabs',
|
||||
] );
|
||||
|
||||
$variants = $openVectorTemplate->buildVariantsProps();
|
||||
$actions = $openVectorTemplate->buildActionsProps();
|
||||
$this->assertSame( $namespaces['class'],
|
||||
'emptyPortlet vectorTabs' );
|
||||
$this->assertSame( $variants['class'],
|
||||
'emptyPortlet vectorMenu' );
|
||||
$this->assertSame( $actions['class'],
|
||||
|
|
Loading…
Reference in a new issue