Rename data-user-menu prefix to data-user-links, matching the template and component naming convention, create UserLinksDropdown.mustache

Change-Id: I6f0de836e39ba6bdcd5a8ff832e951164d69e586
This commit is contained in:
bwang 2023-02-01 16:09:18 -06:00
parent 422f5b0741
commit fcc3d3c9a9
4 changed files with 23 additions and 22 deletions

View file

@ -124,8 +124,8 @@ class VectorComponentUserLinks implements VectorComponent {
return $additionalData + [ return $additionalData + [
'is-temp-user' => $user->isTemp(), 'is-temp-user' => $user->isTemp(),
'is-wide' => count( $overflowMenu ) > 3, 'is-wide' => count( $overflowMenu ) > 3,
'data-user-menu-overflow' => $overflowMenu->getTemplateData(), 'data-user-links-overflow-menu' => $overflowMenu->getTemplateData(),
'data-user-menu-dropdown' => $userMenuDropdown->getTemplateData(), 'data-user-links-dropdown' => $userMenuDropdown->getTemplateData(),
'data-dropdown-menu' => $userMenu->getTemplateData(), 'data-dropdown-menu' => $userMenu->getTemplateData(),
'data-account-links' => $this->accountMenu->getTemplateData(), 'data-account-links' => $this->accountMenu->getTemplateData(),
]; ];

View file

@ -1,20 +1,4 @@
<nav class="vector-user-links{{#is-wide}} vector-user-links-wide{{/is-wide}}" aria-label="{{msg-personaltools}}" role="navigation" > <nav class="vector-user-links{{#is-wide}} vector-user-links-wide{{/is-wide}}" aria-label="{{msg-personaltools}}" role="navigation" >
{{#data-user-menu-overflow}}{{>Menu}}{{/data-user-menu-overflow}} {{#data-user-links-overflow-menu}}{{>Menu}}{{/data-user-links-overflow-menu}}
{{#data-user-menu-dropdown}} {{>UserLinksDropdown}}
{{>Dropdown/Open}}
{{#is-anon}}
{{#is-temp-user}}
{{>UserLinks__templogin}}
{{/is-temp-user}}
{{^is-temp-user}}
{{>UserLinks__login}}
{{/is-temp-user}}
{{/is-anon}}
{{#data-dropdown-menu}}{{>MenuContents}}{{/data-dropdown-menu}}
{{^is-anon}}
{{!-- The #pt-logout ID is required for the AJAX enabled logout in mediawiki.page.ready to work.}}
{{#data-account-links}}{{>MenuContents}}{{/data-account-links}}
{{/is-anon}}
{{>Dropdown/Close}}
{{/data-user-menu-dropdown}}
</nav> </nav>

View file

@ -0,0 +1,15 @@
{{#data-user-links-dropdown}}{{>Dropdown/Open}}{{/data-user-links-dropdown}}
{{#is-anon}}
{{#is-temp-user}}
{{>UserLinks__templogin}}
{{/is-temp-user}}
{{^is-temp-user}}
{{>UserLinks__login}}
{{/is-temp-user}}
{{/is-anon}}
{{#data-dropdown-menu}}{{>MenuContents}}{{/data-dropdown-menu}}
{{^is-anon}}
{{!-- The #pt-logout ID is required for the AJAX enabled logout in mediawiki.page.ready to work.}}
{{#data-account-links}}{{>MenuContents}}{{/data-account-links}}
{{/is-anon}}
{{#data-user-links-dropdown}}{{>Dropdown/Close}}{{/data-user-links-dropdown}}

View file

@ -2,6 +2,7 @@ const mustache = require( 'mustache' );
const fs = require( 'fs' ); const fs = require( 'fs' );
const menuContents = fs.readFileSync( 'includes/templates/MenuContents.mustache', 'utf8' ); const menuContents = fs.readFileSync( 'includes/templates/MenuContents.mustache', 'utf8' );
const userLinksTemplate = fs.readFileSync( 'includes/templates/UserLinks.mustache', 'utf8' ); const userLinksTemplate = fs.readFileSync( 'includes/templates/UserLinks.mustache', 'utf8' );
const userLinksDropdownTemplate = fs.readFileSync( 'includes/templates/UserLinksDropdown.mustache', 'utf8' );
const dropdownOpenTemplate = fs.readFileSync( 'includes/templates/Dropdown/Open.mustache', 'utf8' ); const dropdownOpenTemplate = fs.readFileSync( 'includes/templates/Dropdown/Open.mustache', 'utf8' );
const dropdownCloseTemplate = fs.readFileSync( 'includes/templates/Dropdown/Close.mustache', 'utf8' ); const dropdownCloseTemplate = fs.readFileSync( 'includes/templates/Dropdown/Close.mustache', 'utf8' );
const pinnedContainerOpenTemplate = fs.readFileSync( 'includes/templates/PinnableContainer/Pinned/Open.mustache', 'utf8' ); const pinnedContainerOpenTemplate = fs.readFileSync( 'includes/templates/PinnableContainer/Pinned/Open.mustache', 'utf8' );
@ -16,7 +17,7 @@ const MenuListItem = fs.readFileSync( 'includes/templates/MenuListItem.mustache'
const templateData = { const templateData = {
'is-wide': false, 'is-wide': false,
'data-user-menu-overflow': { 'data-user-links-overflow-menu': {
id: 'p-personal-more', id: 'p-personal-more',
class: 'mw-portlet mw-portlet-vector-user-menu-overflow vector-user-menu-overflow', class: 'mw-portlet mw-portlet-vector-user-menu-overflow vector-user-menu-overflow',
label: 'Toggle sidebar', label: 'Toggle sidebar',
@ -28,7 +29,7 @@ const templateData = {
<li id="pt-watchlist-2" class="user-links-collapsible-item mw-list-item"><a href="/wiki/Special:Watchlist" class="mw-ui-button mw-ui-quiet mw-ui-icon mw-ui-icon-element mw-ui-icon-watchlist mw-ui-icon-wikimedia-watchlist" title="A list of pages you are monitoring for changes [⌃⌥l]" accesskey="l"><span>Watchlist</span></a></li> <li id="pt-watchlist-2" class="user-links-collapsible-item mw-list-item"><a href="/wiki/Special:Watchlist" class="mw-ui-button mw-ui-quiet mw-ui-icon mw-ui-icon-element mw-ui-icon-watchlist mw-ui-icon-wikimedia-watchlist" title="A list of pages you are monitoring for changes [⌃⌥l]" accesskey="l"><span>Watchlist</span></a></li>
` `
}, },
'data-user-menu-dropdown': { 'data-user-links-dropdown': {
id: 'p-personal', id: 'p-personal',
class: 'mw-portlet mw-portlet-personal vector-user-menu vector-user-menu-logged-in vector-menu-dropdown', class: 'mw-portlet mw-portlet-personal vector-user-menu vector-user-menu-logged-in vector-menu-dropdown',
label: 'Personal tools' label: 'Personal tools'
@ -61,6 +62,7 @@ const templateData = {
}; };
const dropdownPartials = { const dropdownPartials = {
UserLinksDropdown: userLinksDropdownTemplate,
'Dropdown/Open': dropdownOpenTemplate, 'Dropdown/Open': dropdownOpenTemplate,
'Dropdown/Close': dropdownCloseTemplate, 'Dropdown/Close': dropdownCloseTemplate,
'PinnableContainer/Pinned/Open': pinnedContainerOpenTemplate, 'PinnableContainer/Pinned/Open': pinnedContainerOpenTemplate,