Add drawer when user is not logged in and anonymous edits are disabled

Bug: T206823
Change-Id: Ibd77ff0966f2d4b86e61f66caaafb94e85b02235
This commit is contained in:
Bjornskjald 2018-11-02 18:35:37 +01:00
parent 6a73c395f1
commit 10978e5022
No known key found for this signature in database
GPG Key ID: 93BC6F739C9CA641
4 changed files with 21 additions and 3 deletions

View File

@ -6,6 +6,7 @@
"minerva-talk-add-topic": "Add discussion",
"mobile-frontend-cookies-required": "Cookies are required to switch view modes. Please enable them and try again.",
"mobile-frontend-editor-disabled": "This page is protected to prevent vandalism.",
"mobile-frontend-editor-disabled-anon": "You need to log in to edit this page.",
"mobile-frontend-editor-edit": "Edit",
"minerva-download": "Download",
"skin-minerva-share": "Share",

View File

@ -15,6 +15,7 @@
"minerva-talk-add-topic": "Label for button which shows at bottom of talk pages in mobile view prompting addition of topic",
"mobile-frontend-cookies-required": "Error message shown when user attempts to switch site modes and cookies are not enabled.",
"mobile-frontend-editor-disabled": "Toast message that appears when a user is unable to edit a page and clicks edit icon.",
"mobile-frontend-editor-disabled-anon": "Message that appears in a drawer when a user is not logged in and anonymous edits are disabled.",
"mobile-frontend-editor-edit": "Caption for the link showing edit form. (In the imperative mood)\n{{Identical|Edit}}",
"minerva-download": "Caption for the download button (in the imperative mood).\n{{Identical|Download}}",
"skin-minerva-share": "Caption for the share button (in the imperative mood).\n{{Identical|Share}}",

View File

@ -12,6 +12,7 @@
$allEditLinks = $( '#ca-edit a, .mw-editsection a, .edit-link' ),
user = M.require( 'mobile.startup/user' ),
popup = M.require( 'mobile.startup/toast' ),
CtaDrawer = M.require( 'mobile.startup/CtaDrawer' ),
// FIXME: Disable on IE < 10 for time being
blacklisted = /MSIE \d\./.test( navigator.userAgent ),
contentModel = mw.config.get( 'wgPageContentModel' ),
@ -219,7 +220,7 @@
* @ignore
*/
function init() {
var isReadOnly, isEditable, editErrorMessage;
var isReadOnly, isEditable, editErrorMessage, drawer, editRestrictions;
// see: https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#Page-specific
isReadOnly = mw.config.get( 'wgMinervaReadOnly' );
isEditable = !isReadOnly && mw.config.get( 'wgIsProbablyEditable' );
@ -229,8 +230,22 @@
setupEditor( currentPage );
} else {
hideSectionEditIcons();
editErrorMessage = isReadOnly ? mw.msg( 'apierror-readonly' ) : mw.msg( 'mobile-frontend-editor-disabled' );
showSorryToast( editErrorMessage );
editRestrictions = mw.config.get( 'wgRestrictionEdit' );
if ( mw.user.isAnon() && Array.isArray( editRestrictions ) && editRestrictions.indexOf( '*' ) !== -1 ) {
drawer = new CtaDrawer( {
content: mw.msg( 'mobile-frontend-editor-disabled-anon' ),
signupQueryParams: {
warning: 'mobile-frontend-watchlist-signup-action'
}
} );
$allEditLinks.on( 'click', function ( ev ) {
drawer.show();
ev.preventDefault();
} );
} else {
editErrorMessage = isReadOnly ? mw.msg( 'apierror-readonly' ) : mw.msg( 'mobile-frontend-editor-disabled' );
showSorryToast( editErrorMessage );
}
}
}

View File

@ -513,6 +513,7 @@
],
"messages": [
"mobile-frontend-editor-disabled",
"mobile-frontend-editor-disabled-anon",
"mobile-frontend-editor-uploadenable",
"apierror-readonly"
],