jenkins-bot has submitted this change and it was merged.

Change subject: Avoid loading Minerva code in Vector
......................................................................


Avoid loading Minerva code in Vector

* Introduce ext.gather.init.minerva to handle Minerva specific
dependencies
* Update gather init script to consider that it might be run without
skins.minerva.script when accessing Skin or MainMenu
* Expose global mw.gather.getSkin method and use this instead of
skins.minerva.scripts/skin

Bug: T108432
Change-Id: I39959a5a13e2e6662fa90023ed2ce9f4c60b3809
---
M extension.json
M includes/Gather.hooks.php
M resources/ext.gather.collections.list/CollectionsList.js
M resources/ext.gather.init/init.js
M resources/ext.gather.routes/routes.js
M resources/ext.gather.special.usercollections/init.js
6 files changed, 67 insertions(+), 26 deletions(-)

Approvals:
  Jhernandez: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index 8da07ab..f0d1b32 100644
--- a/extension.json
+++ b/extension.json
@@ -197,9 +197,8 @@
                                "mobile.infiniteScroll",
                                "mobile.toast",
                                "ext.gather.api",
-                               "ext.gather.menu.icon",
                                "ext.gather.collection.editor",
-                               "skins.minerva.scripts",
+                               "ext.gather.init",
                                "mobile.startup"
                        ],
                        "styles": [],
@@ -385,23 +384,31 @@
                                "resources/ext.gather.desktop/init.js"
                        ]
                },
-               "ext.gather.init": {
+               "ext.gather.init.minerva": {
                        "class": "MFResourceLoaderParsedMessageModule",
                        "targets": [
-                               "mobile",
-                               "desktop"
-                       ],
-                       "dependencies": [
-                               "ext.gather.menu.icon",
-                               "mediawiki.experiments",
-                               "mobile.watchstar",
-                               "ext.gather.watchstar",
-                               "skins.minerva.scripts"
+                               "mobile"
                        ],
                        "messages": {
                                "gather-main-menu-new-feature": [ "parse" ],
                                "gather-menu-guider": "gather-menu-guider"
                        },
+                       "dependencies": [
+                               "ext.gather.init",
+                               "ext.gather.menu.icon",
+                               "skins.minerva.scripts"
+                       ]
+               },
+               "ext.gather.init": {
+                       "targets": [
+                               "mobile",
+                               "desktop"
+                       ],
+                       "dependencies": [
+                               "mediawiki.experiments",
+                               "mobile.watchstar",
+                               "ext.gather.watchstar"
+                       ],
                        "scripts": [
                                "resources/ext.gather.init/init.js"
                        ],
@@ -576,8 +583,7 @@
                        "dependencies": [
                                "ext.gather.api",
                                "mobile.toast",
-                               "mobile.overlays",
-                               "skins.minerva.scripts"
+                               "mobile.overlays"
                        ],
                        "scripts": [
                                "resources/ext.gather.routes/routes.js"
@@ -608,7 +614,7 @@
                        "dependencies": [
                                "ext.gather.special.base",
                                "ext.gather.collections.list",
-                               "skins.minerva.scripts"
+                               "ext.gather.init"
                        ],
                        "scripts": [
                                
"resources/ext.gather.special.usercollections/init.js"
diff --git a/includes/Gather.hooks.php b/includes/Gather.hooks.php
index 8a358c1..6b116bb 100644
--- a/includes/Gather.hooks.php
+++ b/includes/Gather.hooks.php
@@ -227,7 +227,7 @@
         */
        public static function onSkinMinervaDefaultModules( $skin, &$modules ) {
                // Gather code should be loaded unconditionally since it also 
controls revealing the menu item.
-               $modules['watch'] = array( 'ext.gather.init' );
+               $modules['watch'] = array( 'ext.gather.init.minerva' );
                // FIXME: abuse of the hook.
                $skin->getOutput()->addModuleStyles( 'ext.gather.menu.icon' );
                return true;
diff --git a/resources/ext.gather.collections.list/CollectionsList.js 
b/resources/ext.gather.collections.list/CollectionsList.js
index c26fca4..86ec794 100644
--- a/resources/ext.gather.collections.list/CollectionsList.js
+++ b/resources/ext.gather.collections.list/CollectionsList.js
@@ -18,7 +18,7 @@
                 * @cfg {String} defaults.userIconClass user profile icon
                 */
                defaults: {
-                       skin: M.require( 'skins.minerva.scripts/skin' ),
+                       skin: undefined,
                        collections: [],
                        // FIXME: Use the icon partials in server and client 
when supported in server templates.
                        userIconClass: new Icon( {
diff --git a/resources/ext.gather.init/init.js 
b/resources/ext.gather.init/init.js
index b393d50..72a2df9 100644
--- a/resources/ext.gather.init/init.js
+++ b/resources/ext.gather.init/init.js
@@ -1,7 +1,8 @@
 // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
+// Note this code should only ever run in Minerva
 ( function ( M, $ ) {
 
-       var $star, watchstar, pageActionPointer, actionOverlay,
+       var skin, $star, watchstar, pageActionPointer, actionOverlay,
                bucket, useGatherStar,
                CollectionsGateway = M.require( 
'ext.gather.api/CollectionsGateway' ),
                sampleRate = mw.config.get( 'wgGatherEnableSample' ),
@@ -14,8 +15,7 @@
                mainMenuPointerDismissed = 'gather-has-dismissed-mainmenu',
                user = M.require( 'mobile.user/user' ),
                context = M.require( 'mobile.context/context' ),
-               skin = M.require( 'skins.minerva.scripts/skin' ),
-               mainMenu = M.require( 'skins.minerva.scripts/mainMenu' ),
+               Skin = M.require( 'mobile.startup/Skin' ),
                Page = M.require( 'mobile.startup/Page' ),
                page = new Page( {
                        title: mw.config.get( 'wgPageName' ).replace( /_/g, ' ' 
),
@@ -24,6 +24,29 @@
                        id: mw.config.get( 'wgArticleId' ),
                        namespaceNumber: mw.config.get( 'wgNamespaceNumber' )
                } );
+
+       /**
+        * Access the currently active skin
+        *
+        * @method
+        * @ignore
+        * @returns {Skin}
+        */
+       function getSkin() {
+               if ( skin ) {
+                       return skin;
+               } else {
+                       try {
+                               skin = M.require( 'skins.minerva.scripts/skin' 
);
+                       } catch ( e ) {
+                               skin = new Skin( {
+                                       tabletModules: [],
+                                       page: page
+                               } );
+                       }
+                       return skin;
+               }
+       }
 
        /**
         * Determines if collection tutorial should be shown
@@ -70,7 +93,7 @@
                var $star = watchstar.$el;
 
                actionOverlay = new WatchstarPageActionOverlay( {
-                       skin: skin,
+                       skin: getSkin(),
                        target: $star
                } );
 
@@ -98,9 +121,16 @@
         * @ignore
         */
        function revealCollectionsInMainMenu() {
+               var mainMenu;
+               try {
+                       mainMenu = M.require( 'skins.minerva.scripts/mainMenu' 
);
+               } catch ( e ) {
+                       // In desktop mode, nothing to do
+                       return $();
+               }
                if ( !mw.storage.get( mainMenuPointerDismissed ) ) {
                        mainMenu.advertiseNewFeature( '.collection-menu-item',
-                               mw.msg( 'gather-main-menu-new-feature' ), skin 
).done( function ( pointerOverlay ) {
+                               mw.msg( 'gather-main-menu-new-feature' ), 
getSkin() ).done( function ( pointerOverlay ) {
                                        pointerOverlay.on( 'hide', function () {
                                                mw.storage.set( 
mainMenuPointerDismissed, true );
                                        } );
@@ -153,7 +183,7 @@
                                // Only append the overlay if it is not there 
yet
                                if ( $( '#mw-mf-page-center .tutorial-overlay' 
).length === 0 ) {
                                        pageActionPointer = new 
PageActionOverlay( {
-                                               skin: skin,
+                                               skin: getSkin(),
                                                target: $( 
'#mw-mf-main-menu-button' ),
                                                summary: mw.msg( 
'gather-menu-guider' ),
                                                cancelMsg: mw.msg( 
'gather-add-to-collection-cancel' )
@@ -198,9 +228,14 @@
                                isWatched: $star.hasClass( 'watched' )
                        } );
                }
-               skin.emit( 'changed' );
+               getSkin().emit( 'changed' );
        } else if ( useGatherStar ) {
                revealCollectionsInMainMenu();
        }
 
+       // FIXME: Use module loading (define/require when available in core)
+       mw.gather = {
+               getSkin: getSkin
+       };
+
 }( mw.mobileFrontend, jQuery ) );
diff --git a/resources/ext.gather.routes/routes.js 
b/resources/ext.gather.routes/routes.js
index 2b5a6e3..d454ff1 100644
--- a/resources/ext.gather.routes/routes.js
+++ b/resources/ext.gather.routes/routes.js
@@ -24,7 +24,7 @@
                                        loadingOverlay.hide();
                                        d.resolve(
                                                new CollectionEditOverlay( {
-                                                       skin: M.require( 
'skins.minerva.scripts/skin' ),
+                                                       skin: 
mw.gather.getSkin(),
                                                        api: new mw.Api(),
                                                        collection: collection,
                                                        reloadOnSave: 
isSpecialPage,
diff --git a/resources/ext.gather.special.usercollections/init.js 
b/resources/ext.gather.special.usercollections/init.js
index 7523f05..4ff7ce0 100644
--- a/resources/ext.gather.special.usercollections/init.js
+++ b/resources/ext.gather.special.usercollections/init.js
@@ -7,7 +7,7 @@
        $( function () {
                new CollectionsList( {
                        api: new mw.Api(),
-                       skin: M.require( 'skins.minerva.scripts/skin' ),
+                       skin: mw.gather.getSkin(),
                        el: $collectionsList,
                        enhance: true,
                        owner: owner,

-- 
To view, visit https://gerrit.wikimedia.org/r/261276
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I39959a5a13e2e6662fa90023ed2ce9f4c60b3809
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: dev
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to