jenkins-bot has submitted this change and it was merged. Change subject: Support for cached menu data in HTML ......................................................................
Support for cached menu data in HTML Follow on Ibf1cea If the user is looking at a cached page -- they're logged out -- then reformat the `wgMFMenuData` configuration variable. Bug: T98964 Bug: T98759 Change-Id: I768dbed35823ff0cdd96795a68c1eb39075d44bd --- M resources/mobile.mainMenu/MainMenu.js M resources/mobile.mainMenu/menu.mustache 2 files changed, 42 insertions(+), 4 deletions(-) Approvals: Jdlrobson: Looks good to me, approved jenkins-bot: Verified diff --git a/resources/mobile.mainMenu/MainMenu.js b/resources/mobile.mainMenu/MainMenu.js index b7e6bac..7edcdbd 100644 --- a/resources/mobile.mainMenu/MainMenu.js +++ b/resources/mobile.mainMenu/MainMenu.js @@ -11,11 +11,49 @@ */ MainMenu = View.extend( { template: mw.template.get( 'mobile.mainMenu', 'menu.hogan' ), + + /** @inheritdoc **/ + initialize: function ( options ) { + this.defaults = this._handleCachedMenuData( + mw.config.get( 'wgMFMenuData' ) + ); + + View.prototype.initialize.apply( this, options ); + }, + + // FIXME: [CACHE] Remove when cache clears. /** - * @inheritdoc - * @cfg {Object} defaults Default options hash + * Translates the old, but cached, format of `wgMFMenuData` to the new + * new format. + * + * @param {Object[]} menu The value of the `wgMFMenuData` config variable + * @private */ - defaults: $.extend( {}, mw.config.get( 'wgMFMenuData' ) || {} ), + _handleCachedMenuData: function ( menu ) { + var result = {}; + + $.each( menu, function ( key, entries ) { + + // New format? + if ( entries[0].components ) { + result = menu; + + return false; + } + + result[key] = $.map( entries, function ( entry ) { + // We don't have to address T98759 here as this bug only + // affects logged out users who are seeing a cached version + // of the page. + return { + name: entry.name, + components: [ entry ] + }; + } ); + } ); + + return result; + }, /** * Turn on event logging on the existing main menu by reading `event-name` data diff --git a/resources/mobile.mainMenu/menu.mustache b/resources/mobile.mainMenu/menu.mustache index 97a078c..83cb5a0 100644 --- a/resources/mobile.mainMenu/menu.mustache +++ b/resources/mobile.mainMenu/menu.mustache @@ -21,7 +21,7 @@ {{#sitelinks}} <li> {{#components}} - <a href="{{href}}" class="{{class}}" data-event-name="{{data-event-name}}">{{text}}</a> + <a href="{{href}}" class="{{class}}" data-event-name="{{data-event-name}}">{{text}}</a> {{/components}} </li> {{/sitelinks}} -- To view, visit https://gerrit.wikimedia.org/r/211078 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I768dbed35823ff0cdd96795a68c1eb39075d44bd Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Phuedx <g...@samsmith.io> Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits