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

Change subject: Block info should be Minerva specific
......................................................................


Block info should be Minerva specific

Move methods from the generic library into the only place that
uses them skins.minerva.editor (the mobile.user and mobile.startup
libraries may be used by other things - the mobile.user library for
example should be upstreamed to mediawiki.user)

This makes the libraries more light weight and ties the block information
to the Minerva skin - the only place where it is current used.

Change-Id: Iba351e3285258c07bc11c57fb3255fca916621a4
---
M includes/skins/SkinMinerva.php
M resources/mobile.startup/Page.js
M resources/mobile.user/user.js
M resources/skins.minerva.editor/init.js
4 files changed, 15 insertions(+), 47 deletions(-)

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



diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index ef2e552..0a85cf2 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -917,7 +917,7 @@
                                        'blockReason' => $blockReason,
                                );
                        }
-                       $vars['wgMFUserBlockInfo'] = $blockInfo;
+                       $vars['wgMinervaUserBlockInfo'] = $blockInfo;
                }
 
                return $vars;
diff --git a/resources/mobile.startup/Page.js b/resources/mobile.startup/Page.js
index eedc3d1..5c1adb9 100644
--- a/resources/mobile.startup/Page.js
+++ b/resources/mobile.startup/Page.js
@@ -145,24 +145,6 @@
                },
 
                /**
-                * Checks whether the given user can edit the page.
-                * @method
-                * @param {mw.user} user Object representing a user
-                * @return {Boolean}
-                */
-               isEditable: function ( user ) {
-                       // see: 
https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#Page-specific
-                       var editable = mw.config.get( 'wgIsProbablyEditable' );
-
-                       // for logged in users check if they are blocked from 
editing this page
-                       if ( editable && !user.isAnon() ) {
-                               editable = !mw.config.get( 'wgMFUserBlockInfo' 
);
-                       }
-
-                       return editable;
-               },
-
-               /**
                 * Return the latest revision id for this page
                 * @method
                 * @return {Number}
diff --git a/resources/mobile.user/user.js b/resources/mobile.user/user.js
index 436ca40..fdd2454 100644
--- a/resources/mobile.user/user.js
+++ b/resources/mobile.user/user.js
@@ -45,27 +45,6 @@
                },
 
                /**
-                * Returns false, if the user isn't logged in or is blocked,
-                * otherwise true.
-                * @return {Boolean}
-                */
-               isBlocked: function () {
-                       return this.getBlockInfo() !== false;
-               },
-
-               /**
-                * Returns information about the block of this user, otherwise 
false.
-                * Always returns false for not-logged-in users!
-                * @return {Boolean|Object}
-                */
-               getBlockInfo: function () {
-                       if ( mw.user.isAnon() || !mw.config.get( 
'wgMFUserBlockInfo' ) ) {
-                               return false;
-                       }
-                       return mw.config.get( 'wgMFUserBlockInfo' );
-               },
-
-               /**
                * User Bucketing for A/B testing
                * (we want this to be the same everywhere)
                * @return {Boolean}
diff --git a/resources/skins.minerva.editor/init.js 
b/resources/skins.minerva.editor/init.js
index ac13aeb..cd474a2 100644
--- a/resources/skins.minerva.editor/init.js
+++ b/resources/skins.minerva.editor/init.js
@@ -1,6 +1,11 @@
 ( function ( M, $ ) {
 
        var
+               // see: 
https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#Page-specific
+               isEditable = mw.config.get( 'wgIsProbablyEditable' ),
+               blockInfo =  mw.config.get( 'wgMinervaUserBlockInfo', false ) ||
+                       // FIXME: Can be removed in 30 days 
(Iba351e3285258c07bc11c57fb3255fca916621a4)
+                       mw.config.get( 'wgMFUserBlockInfo' ),
                settings = M.require( 'mobile.settings/settings' ),
                router = M.require( 'mobile.startup/router' ),
                overlayManager = M.require( 'mobile.startup/overlayManager' ),
@@ -36,6 +41,12 @@
                $caEdit = $( '#ca-edit' ),
                SchemaEdit = M.require( 'mobile.loggingSchemas/SchemaEdit' );
 
+       if ( user.isAnon() ) {
+               blockInfo = false;
+       } else if ( isEditable ) {
+               // for logged in users check if they are blocked from editing 
this page
+               isEditable = !blockInfo;
+       }
        /**
         * Prepend an edit page button to the container
         * @method
@@ -280,14 +291,10 @@
         * @ignore
         */
        function init() {
-               var blockInfo;
-
-               if ( currentPage.isEditable( user ) ) {
+               if ( isEditable ) {
                        setupEditor( currentPage );
                } else {
-                       if ( user.isBlocked() ) {
-                               blockInfo = user.getBlockInfo();
-
+                       if ( blockInfo ) {
                                $caEdit.removeClass( 'hidden' );
                                $( '#ca-edit' ).on( 'click', function ( ev ) {
                                        popup.show(
@@ -315,7 +322,7 @@
        function initCta() {
                // Initialize edit button links (to show Cta) only, if page is 
editable,
                // otherwise show an error toast
-               if ( currentPage.isEditable( user ) ) {
+               if ( isEditable ) {
                        $caEdit.addClass( enabledClass ).removeClass( 
disabledClass ).removeClass( 'hidden' );
                        // Init lead section edit button
                        makeCta( $caEdit, 0 );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iba351e3285258c07bc11c57fb3255fca916621a4
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to