/**
* @external MenuDefinition
* @external UserLinksDefinition
*/
import { menuTemplate } from './Menu.stories.data';
import userLinksTemplateLegacy from '!!raw-loader!../includes/templates/legacy/UserLinks.mustache';
import userLinksTemplate from '!!raw-loader!../includes/templates/UserLinks.mustache';
import { helperClassName, helperMakeMenuData } from './utils';
/**
* @type {MenuDefinition}
*/
const loggedOut = helperMakeMenuData(
'personal',
`
Not logged inTalkContributionsCreate accountLog in`,
helperClassName( 'vector-user-menu-legacy' )
);
const ECHO_ITEMS = `Alerts (0)Notices (3)`;
const USERNAME_ITEM = `WikiUser`;
const REST_ITEMS = `TalkSandboxPreferencesBetaWatchlistContributions`;
const LOGOUT_ITEM = `Log out`;
const ULS_LANGUAGE_SELECTOR = 'English';
/**
* @type {MenuDefinition}
*/
const loggedInWithEcho = helperMakeMenuData(
'personal',
`${USERNAME_ITEM}${ECHO_ITEMS}${REST_ITEMS}${LOGOUT_ITEM}`,
helperClassName( 'vector-user-menu-legacy' )
);
/**
* @type {MenuDefinition}
*/
const loggedInWithULS = helperMakeMenuData(
'personal',
`${ULS_LANGUAGE_SELECTOR}${USERNAME_ITEM}${ECHO_ITEMS}${REST_ITEMS}${LOGOUT_ITEM}`,
helperClassName( 'vector-user-menu-legacy' )
);
/**
* @type {Object.}
*/
const PERSONAL_MENU_TEMPLATE_DATA = {
loggedOut,
loggedInWithEcho,
loggedInWithULS
};
const additionalMenuData = {
class: 'vector-user-menu vector-menu-dropdown',
'is-dropdown': true,
'heading-class': 'mw-ui-icon mw-ui-icon-element'
};
const loggedInData = {
'is-anon': true,
'html-after-portal': `
`
};
const loggedOutData = {
'is-anon': true,
'html-before-portal': `
`
};
/**
* @type {UserLinksDefinition}
*/
const USER_LINKS_LOGGED_IN_TEMPLATE_DATA = {
'is-anon': false,
'data-user-page': helperMakeMenuData( 'user-page', USERNAME_ITEM ),
'data-notifications': helperMakeMenuData( 'notifications', ECHO_ITEMS ),
'data-user-menu': helperMakeMenuData( 'new-personal', REST_ITEMS, Object.assign( {}, additionalMenuData, loggedInData ) )
};
/**
* @type {UserLinksDefinition}
*/
const USER_LINKS_LOGGED_OUT_TEMPLATE_DATA = {
'is-anon': true,
'html-create-account': `Create account`,
'data-user-menu': helperMakeMenuData( 'new-personal', REST_ITEMS, Object.assign( {}, additionalMenuData, loggedOutData ) )
};
export {
PERSONAL_MENU_TEMPLATE_DATA,
USER_LINKS_LOGGED_IN_TEMPLATE_DATA,
USER_LINKS_LOGGED_OUT_TEMPLATE_DATA,
menuTemplate,
userLinksTemplateLegacy,
userLinksTemplate
};