Florianschmidtwelzow has uploaded a new change for review.

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

Change subject: WIP: Fixes for Talk feature
......................................................................

WIP: Fixes for Talk feature

* Use Overlay.hogan, instead of talk.hogan as base Overlay template

* Fix Bug 70989

* Remove error code from error message when post new discussion and add
more specific error messages for some errors

Bug: 70989
Change-Id: Ic9a4d6b216509d28e4fa24869372c41fe31eb7a6
---
M i18n/en.json
M includes/Resources.php
M javascripts/modules/talk/TalkOverlay.js
M javascripts/modules/talk/TalkSectionAddOverlay.js
M javascripts/modules/talk/TalkSectionOverlay.js
M templates/modules/talk/talk.hogan
6 files changed, 61 insertions(+), 32 deletions(-)


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

diff --git a/i18n/en.json b/i18n/en.json
index 0644aa8..1f9374e 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -280,7 +280,11 @@
     "mobile-frontend-talk-reply-info": "Note your reply will be automatically 
signed with your username.",
     "mobile-frontend-talk-reply-success": "Your reply was successfully saved 
to the talk page.",
     "mobile-frontend-talk-topic-feedback": "New topic added to talk page!",
-    "mobile-frontend-talk-topic-error": "The topic can't be added. Error: $1",
+    "mobile-frontend-talk-topic-error": "The topic can't be added due to an 
unknown Error.",
+    "mobile-frontend-talk-topic-error-protected": "This Talk page is 
protected, you don't have the permission to add topics to it.",
+    "mobile-frontend-talk-topic-error-permission": "The topic can't be added. 
You don't have the permission to edit pages.",
+    "mobile-frontend-talk-topic-error-spam": "The topic was refused because it 
contained a spam fragment.",
+    "mobile-frontend-talk-topic-error-badtoken": "There was an error on the 
server. Your edit can't be saved. Try reloading this page.",
     "mobile-frontend-terms-text": "Terms of Use",
     "mobile-frontend-terms-url": "",
     "mobile-frontend-thanked-notice": "$1 was told that you liked 
{{GENDER:$2|his|her|their}} edit.",
diff --git a/includes/Resources.php b/includes/Resources.php
index 27e1c2c..e7c1fd6 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -522,6 +522,10 @@
                        'mobile-frontend-talk-reply-info',
                        'mobile-frontend-talk-topic-feedback',
                        'mobile-frontend-talk-topic-error',
+                       'mobile-frontend-talk-topic-error-protected',
+                       'mobile-frontend-talk-topic-error-permission',
+                       'mobile-frontend-talk-topic-error-spam',
+                       'mobile-frontend-talk-topic-error-badtoken',
                        // @todo FIXME: Gets loaded twice if editor and talk 
both loaded.
                        'mobile-frontend-editor-cancel',
                        'mobile-frontend-editor-cancel-confirm',
diff --git a/javascripts/modules/talk/TalkOverlay.js 
b/javascripts/modules/talk/TalkOverlay.js
index 4858056..5918da7 100644
--- a/javascripts/modules/talk/TalkOverlay.js
+++ b/javascripts/modules/talk/TalkOverlay.js
@@ -12,14 +12,17 @@
                 * @class TalkOverlay
                 */
                TalkOverlay = Overlay.extend( {
-                       template: M.template.get( 'modules/talk/talk.hogan' ),
                        templatePartials: {
-                               header: M.template.get( 
'modules/talk/talkHeader.hogan' )
+                               content: M.template.get( 
'modules/talk/talk.hogan' )
                        },
                        defaults: {
-                               addTopicLabel: mw.msg( 
'mobile-frontend-talk-add-overlay-submit' ),
                                heading: '<strong>' + mw.msg( 
'mobile-frontend-talk-overlay-header' ) + '</strong>',
-                               leadHeading: mw.msg( 
'mobile-frontend-talk-overlay-lead-header' )
+                               leadHeading: mw.msg( 
'mobile-frontend-talk-overlay-lead-header' ),
+                               headerButtonsListClassName: 'overlay-action',
+                               headerButtons: [ {
+                                       className: 'add continue hidden',
+                                       msg: mw.msg( 
'mobile-frontend-talk-add-overlay-submit' )
+                               } ]
                        },
 
                        postRender: function( options ) {
@@ -117,7 +120,9 @@
                                                var overlay = new 
TalkSectionAddOverlay( {
                                                        title: page.title
                                                } );
-                                               overlay.show();
+                                               // Hide discussion list to 
disable scrolling - bug 70989
+                                               // FIXME: Kill when 
OverlayManager is used for TalkSectionAdd
+                                               self.$board.hide();
                                                overlay.on( 
'talk-discussion-added', function() {
                                                        // reload the content
                                                        self._loadContent( 
options );
@@ -125,7 +130,9 @@
                                                        // re-enable 
TalkOverlay (it's closed by hide event (in Overlay)
                                                        // from 
TalkSectionAddOverlay)
                                                        self.show();
-                                               } );
+                                                       // FIXME: Kill when 
OverlayManager is used for TalkSectionAdd
+                                                       self.$board.show();
+                                               } ).show();
                                                // When closing this overlay, 
also close the child section overlay
                                                self.on( 'hide', function() {
                                                        overlay.remove();
@@ -149,7 +156,13 @@
                                                        title: page.title,
                                                        section: section
                                                } );
-                                       childOverlay.show();
+                                       // Hide discussion list to disable 
scrolling - bug 70989
+                                       // FIXME: Kill when OverlayManager is 
used for TalkSections
+                                       self.$board.hide();
+                                       childOverlay.on( 'hide', function() {
+                                               // FIXME: Kill when 
OverlayManager is used for TalkSections
+                                               self.$board.show();
+                                       } ).show();
                                        // When closing this overlay, also 
close the child section overlay
                                        self.on( 'hide', function() {
                                                childOverlay.remove();
diff --git a/javascripts/modules/talk/TalkSectionAddOverlay.js 
b/javascripts/modules/talk/TalkSectionAddOverlay.js
index 9fc479f..b9d9fe8 100644
--- a/javascripts/modules/talk/TalkSectionAddOverlay.js
+++ b/javascripts/modules/talk/TalkSectionAddOverlay.js
@@ -53,11 +53,29 @@
                                                        self.hide();
                                                }
                                        } ).fail( function( error ) {
+                                               var editMsg = 
'mobile-frontend-talk-topic-error';
+
                                                self.confirm.prop( 'disabled', 
false );
-                                               toast.show(
-                                                       mw.msg( 
'mobile-frontend-talk-topic-error', error.details ),
-                                                       'toast error'
-                                               );
+                                               switch ( error.details ) {
+                                                       case "protectedpage":
+                                                               editMsg = 
'mobile-frontend-talk-topic-error-protected';
+                                                               break;
+                                                       case "noedit":
+                                                       case "blocked":
+                                                               editMsg = 
'mobile-frontend-talk-topic-error-permission';
+                                                               break;
+                                                       case "spamdetected":
+                                                               editMsg = 
'mobile-frontend-talk-topic-error-spam';
+                                                               break;
+                                                       case "badtoken":
+                                                               editMsg = 
'mobile-frontend-talk-topic-error-badtoken';
+                                                               break;
+                                                       default:
+                                                               editMsg = 
'mobile-frontend-talk-topic-error';
+                                                               break;
+                                               }
+
+                                               toast.show( editMsg, 'toast 
error' );
                                        } );
                                }
                        } );
diff --git a/javascripts/modules/talk/TalkSectionOverlay.js 
b/javascripts/modules/talk/TalkSectionOverlay.js
index 9441a56..ddcafdb 100644
--- a/javascripts/modules/talk/TalkSectionOverlay.js
+++ b/javascripts/modules/talk/TalkSectionOverlay.js
@@ -14,10 +14,6 @@
                        confirmMsg: mw.msg( 'mobile-frontend-editor-save' ),
                        info: mw.msg( 'mobile-frontend-talk-reply-info' )
                },
-               // FIXME: Use Router for TalkSectionOverlay
-               hide: function() {
-                       this.remove();
-               },
                initialize: function( options ) {
                        // If terms of use is enabled, include it in the 
licensing message
                        if ( $( '#footer-places-terms-use' ).length > 0 ) {
diff --git a/templates/modules/talk/talk.hogan 
b/templates/modules/talk/talk.hogan
index 6670d00..aeeed84 100644
--- a/templates/modules/talk/talk.hogan
+++ b/templates/modules/talk/talk.hogan
@@ -1,17 +1,11 @@
-<div class="overlay-header-container position-fixed">
-       {{>header}}
+<div class="board">
+       <p class="content-header">
+               {{explanation}}
+       </p>
+       <ul class="page-list actionable">
+               <li class="lead-discussion">
+                       <a data-id="0">{{leadHeading}}</a>
+               </li>
+       </ul>
 </div>
-
-<div class="overlay-content">
-       <div class="board">
-               <p class="content-header">
-                       {{explanation}}
-               </p>
-               <ul class="page-list actionable">
-                       <li class="lead-discussion">
-                               <a data-id="0">{{leadHeading}}</a>
-                       </li>
-               </ul>
-       </div>
-       <div class="spinner loading"></div>
-</div>
+<div class="spinner loading"></div>

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic9a4d6b216509d28e4fa24869372c41fe31eb7a6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>

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

Reply via email to