Florianschmidtwelzow has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/210950

Change subject: Show a better error message, when the user can't edit a page 
due to the false group
......................................................................

Show a better error message, when the user can't edit a page due to the false 
group

If a page is protected and a user isn't allowed to edit this page, show a 
ContentOverlay,
instead of a toast with the message, that the page is protected to prevent 
vandalism and
give the user a cancel button and a button that redirects him to the history 
page to
get more information (e.g. the reason why the page was protected and to which 
group).

Bug: T95305
Change-Id: I59122b568cd353ca5c3aba0a28522effb15cfab4
---
M i18n/en.json
M i18n/qqq.json
M includes/Resources.php
A resources/mobile.editor.disabledOverlay/DisabledOverlay.hogan
A resources/mobile.editor.disabledOverlay/DisabledOverlay.less
A resources/mobile.editor.disabledOverlay/Overlay.js
M resources/mobile.editor/init.js
7 files changed, 110 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/50/210950/1

diff --git a/i18n/en.json b/i18n/en.json
index f0c6917..6221d4f 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -100,7 +100,6 @@
        "mobile-frontend-editor-captcha-try-again": "Wrong code, try again.",
        "mobile-frontend-editor-continue": "Next",
        "mobile-frontend-editor-cta": "Help improve this page!",
-       "mobile-frontend-editor-disabled": "This page is protected to prevent 
vandalism.",
        "mobile-frontend-editor-edit": "Edit",
        "mobile-frontend-editor-editing": "Editing",
        "mobile-frontend-editor-editing-page": "<span><strong>Editing</strong> 
$1</span>",
@@ -138,6 +137,8 @@
        "mobile-frontend-editor-viewing-source-page": "<strong>Viewing source 
of</strong><span> $1</span>",
        "mobile-frontend-editor-visual-editor": "Edit",
        "mobile-frontend-editor-wait": "Saving edit, please wait.",
+       "mobile-frontend-editor-showhistory": "Show history",
+       "mobile-frontend-editor-protected": "This page is protected to prevent 
vandalism. You can consult the history page to see, whether a reason was given 
or not.",
        "mobile-frontend-enable-images": "Enable images on mobile site",
        "mobile-frontend-errorreport-button-label": "Report an error",
        "mobile-frontend-errorreport-error": "Error, feedback could not be 
posted.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 4251a07..6981ced 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -133,6 +133,8 @@
        "mobile-frontend-editor-viewing-source-page": "A heading saying which 
page's source code is being viewed. All text should be wrapped in a STRONG tag 
except the page title itself.\n\nParameters:\n* $1 - page 
title\n{{Related|Mobile-frontend-editor-page}}",
        "mobile-frontend-editor-visual-editor": "Label for button that switches 
to the \"visual editor\" (a WYSIWYG editing interface). Appears near 
{{msg-mw|mobile-frontend-editor-source-edit}}. See 
http://www.mediawiki.org/wiki/VisualEditor.\n{{Identical|Edit}}",
        "mobile-frontend-editor-wait": "Text that displays while a page edit is 
being saved.",
+       "mobile-frontend-editor-showhistory": "Label for a link redirect the 
user to the page history.",
+       "mobile-frontend-editor-protected": "Message that appears when a user 
is unable to edit a page and clicks edit icon.",
        "mobile-frontend-enable-images": "Unused at this time.\n\nSee also:\n* 
{{msg-mw|Mobile-frontend-disable-images}}",
        "mobile-frontend-errorreport-button-label": "Label for button for 
submitting an error report. Keep this short.",
        "mobile-frontend-errorreport-error": "Error displayed when feedback 
could not be posted.",
diff --git a/includes/Resources.php b/includes/Resources.php
index b6db40c..f1153e8 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -488,7 +488,6 @@
                ),
                'messages' => array(
                        // editor.js
-                       'mobile-frontend-editor-disabled',
                        'mobile-frontend-editor-unavailable',
                        'mobile-frontend-editor-uploadenable',
                        'mobile-frontend-editor-blocked-info-loggedin' => 
array( 'parse' ),
@@ -598,6 +597,26 @@
                ),
        ),
 
+       'mobile.editor.disabledOverlay' => 
$wgMFResourceParsedMessageModuleBoilerplate + array(
+               'dependencies' => array(
+                       'mobile.overlays',
+               ),
+               'scripts' => array(
+                       'resources/mobile.editor.disabledOverlay/Overlay.js',
+               ),
+               'styles' => array(
+                       
'resources/mobile.editor.disabledOverlay/DisabledOverlay.less',
+               ),
+               'templates' => array(
+                       'DisabledOverlay.hogan' => 
'resources/mobile.editor.disabledOverlay/DisabledOverlay.hogan',
+               ),
+               'messages' => array(
+                       'cancel',
+                       'mobile-frontend-editor-showhistory',
+                       'mobile-frontend-editor-protected',
+               ),
+       ),
+
        'mobile.editor.overlay' => $wgMFResourceFileModuleBoilerplate + array(
                'dependencies' => array(
                        'mobile.editor.common',
diff --git a/resources/mobile.editor.disabledOverlay/DisabledOverlay.hogan 
b/resources/mobile.editor.disabledOverlay/DisabledOverlay.hogan
new file mode 100644
index 0000000..15f5503
--- /dev/null
+++ b/resources/mobile.editor.disabledOverlay/DisabledOverlay.hogan
@@ -0,0 +1,5 @@
+<p>{{{summary}}}</p>
+<div class="button-bar">
+       <button class="button cancel inline">{{cancelMsg}}</button>
+       {{#showHistoryMsg}}<button class="button 
actionable">{{showHistoryMsg}}</button>{{/showHistoryMsg}}
+</div>
diff --git a/resources/mobile.editor.disabledOverlay/DisabledOverlay.less 
b/resources/mobile.editor.disabledOverlay/DisabledOverlay.less
new file mode 100644
index 0000000..b6c3a81
--- /dev/null
+++ b/resources/mobile.editor.disabledOverlay/DisabledOverlay.less
@@ -0,0 +1,26 @@
+@import "minerva.variables";
+@import "minerva.mixins";
+
+.content-overlay {
+       position: absolute;
+       top: 0;
+       left: 0;
+       right: 0;
+       padding: 1em @contentMargin;
+       line-height: 1.4;
+       font-size: .9em;
+       text-align: center;
+       box-shadow: 0 1px 5px 0 rgba(117, 117, 117, .8);
+
+       p {
+               line-height: 1.4;
+               margin: 0 0 1em;
+       }
+
+       .button {
+               // FIXME: without this the cloaked input seems to interfere 
making cancel button start upload
+               position: relative;
+               padding: 12px;
+               font-weight: bold;
+       }
+}
diff --git a/resources/mobile.editor.disabledOverlay/Overlay.js 
b/resources/mobile.editor.disabledOverlay/Overlay.js
new file mode 100644
index 0000000..9e2fd9e
--- /dev/null
+++ b/resources/mobile.editor.disabledOverlay/Overlay.js
@@ -0,0 +1,37 @@
+( function ( M ) {
+       var DisabledOverlay,
+               ContentOverlay = M.require( 'ContentOverlay' );
+
+       DisabledOverlay = ContentOverlay.extend( {
+               className: 'overlay content-overlay editor-disabled',
+               template: mw.template.get( 'mobile.editor.disabledOverlay', 
'DisabledOverlay.hogan' ),
+               /**
+                * @inheritdoc
+                * @cfg {Object} defaults Default options hash.
+                * @cfg {String} defaults.cancelMsg Cancel message.
+                */
+               defaults: {
+                       cancelMsg: mw.msg( 'cancel' ),
+                       showHistoryMsg: mw.msg( 
'mobile-frontend-editor-showhistory' ),
+                       summary: mw.msg( 'mobile-frontend-editor-protected' )
+               },
+               /**
+                * @inheritdoc
+                */
+               events: {
+                       'click .cancel': 'hide',
+                       'click .actionable': 'onHistoryClick'
+               },
+               /**
+                * Handles a click on the "Show history" button and redirects 
the user to the
+                * history page.
+                */
+               onHistoryClick: function () {
+                       var title = mw.Title.newFromText( mw.config.get( 
'wgPageName' ) );
+
+                       location.href = title.getUrl( { action: 'history' } );
+               }
+       } );
+
+       M.define( 'modules/editor/DisabledOverlay', DisabledOverlay );
+}( mw.mobileFrontend ) );
diff --git a/resources/mobile.editor/init.js b/resources/mobile.editor/init.js
index 2a0eed8..6798b94 100644
--- a/resources/mobile.editor/init.js
+++ b/resources/mobile.editor/init.js
@@ -246,8 +246,7 @@
                                } );
                                $( '.edit-page' ).detach();
                        } else {
-                               $caEdit.removeClass( 'hidden' );
-                               showSorryToast( 
'mobile-frontend-editor-disabled' );
+                               disableEditor();
                        }
                }
        }
@@ -276,10 +275,25 @@
                                makeCta( $a, section );
                        } );
                } else {
-                       $caEdit.removeClass( 'hidden' );
-                       showSorryToast( 'mobile-frontend-editor-disabled' );
+                       disableEditor();
                }
        }
+
+       /**
+        * Unhide the editor button, but still shows a locked editor icon, 
which, when clicked,
+        * shows a ContentOverlay with the message, that this page is protected.
+        */
+       function disableEditor() {
+               $caEdit.removeClass( 'hidden' ).on( 'click', function () {
+                       loader.loadModule( 'mobile.editor.disabledOverlay' 
).done( function () {
+                               var DisabledOverlay = M.require( 
'modules/editor/DisabledOverlay' ),
+                                       overlay;
+
+                               overlay = new DisabledOverlay();
+                               overlay.show();
+                       } );
+               } );
+       }
        /**
         * Show a toast message with sincere condolences.
         * @method

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I59122b568cd353ca5c3aba0a28522effb15cfab4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.wel...@t-online.de>

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

Reply via email to