jenkins-bot has submitted this change and it was merged. Change subject: Hygiene: Move anonymousEditing config to EditorOptions ......................................................................
Hygiene: Move anonymousEditing config to EditorOptions Replace wgMFAnonymousEditing into the new editor config array wgMFEditorOptions. This gives us the possibility to group all editor related configurations to one array. Change-Id: I8d11fa1521e317aa2f069d87bb49adb6fff3e4be --- M MobileFrontend.php M includes/skins/SkinMinerva.php M includes/skins/SkinMinervaAlpha.php M javascripts/api.js M javascripts/modules/editor/init.js M tests/qunit/modules/talk/test_TalkSectionAddOverlay.js M tests/qunit/test_api.js 7 files changed, 24 insertions(+), 24 deletions(-) Approvals: Jdlrobson: Looks good to me, approved jenkins-bot: Verified diff --git a/MobileFrontend.php b/MobileFrontend.php index a0fdf0e..bf6a21d 100644 --- a/MobileFrontend.php +++ b/MobileFrontend.php @@ -442,13 +442,18 @@ $wgMFEnableXAnalyticsLogging = false; /** - * Whether or not anonymous (not logged in) users should be able to edit. - * Note this is highly experimental and comes without any warranty and may introduce bugs - * until anonymous editing experience is addressed in this extension. Anonymous editing - * on mobile is still a big unknown. See bug 53069. - * Thoughts welcomed on https://www.mediawiki.org/wiki/Mobile_wikitext_editing#Anonymous_editing + * Options to control several functions of the mobile editor. + * Possible values: + * - 'anonymousEditing': + * Whether or not anonymous (not logged in) users should be able to edit. + * Note this is highly experimental and comes without any warranty and may introduce bugs + * until anonymous editing experience is addressed in this extension. Anonymous editing + * on mobile is still a big unknown. See bug 53069. + * Thoughts welcomed on https://www.mediawiki.org/wiki/Mobile_wikitext_editing#Anonymous_editing */ -$wgMFAnonymousEditing = false; +$wgMFEditorOptions = array( + 'anonymousEditing' => false, +); /** * A css selector which is used by mf-photo.js to test whether to prompt the user photo uploads on diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php index a676013..b092ed9 100644 --- a/includes/skins/SkinMinerva.php +++ b/includes/skins/SkinMinerva.php @@ -841,7 +841,7 @@ $wgMFUseCentralAuthToken, $wgMFDeviceWidthTablet, $wgMFAjaxUploadProgressSupport, - $wgMFAnonymousEditing, + $wgMFEditorOptions, $wgMFWikiDataEndpoint, $wgMFPhotoUploadEndpoint, $wgMFPhotoUploadAppendToDesc, $wgMFCollapseSectionsByDefault, $wgMFShowRedLinksAnon, @@ -854,7 +854,7 @@ 'wgMFWikiDataEndpoint' => $wgMFWikiDataEndpoint, 'wgMFUseCentralAuthToken' => $wgMFUseCentralAuthToken, 'wgMFAjaxUploadProgressSupport' => $wgMFAjaxUploadProgressSupport, - 'wgMFAnonymousEditing' => $wgMFAnonymousEditing, + 'wgMFEditorOptions' => $wgMFEditorOptions, 'wgMFPhotoUploadAppendToDesc' => $wgMFPhotoUploadAppendToDesc, 'wgMFLeadPhotoUploadCssSelector' => $wgMFLeadPhotoUploadCssSelector, 'wgMFPhotoUploadEndpoint' => $wgMFPhotoUploadEndpoint ? $wgMFPhotoUploadEndpoint : '', diff --git a/includes/skins/SkinMinervaAlpha.php b/includes/skins/SkinMinervaAlpha.php index cd3ffdd..d1653a3 100644 --- a/includes/skins/SkinMinervaAlpha.php +++ b/includes/skins/SkinMinervaAlpha.php @@ -102,7 +102,7 @@ */ public function getSkinConfigVariables() { $vars = parent::getSkinConfigVariables(); - $vars['wgMFAnonymousEditing'] = true; + $vars['wgMFEditorOptions']['anonymousEditing'] = true; $vars['wgMFDescription'] = $this->getOutput()->getProperty( 'wgMFDescription' ); return $vars; } diff --git a/javascripts/api.js b/javascripts/api.js index 3ae14d7..218f8c1 100644 --- a/javascripts/api.js +++ b/javascripts/api.js @@ -146,7 +146,8 @@ var token, data, isCacheable, d = $.Deferred(), // token types available from mw.user.tokens - easyTokens = [ 'edit', 'watch', 'patrol' ]; + easyTokens = [ 'edit', 'watch', 'patrol' ], + editorConfig = mw.config.get( 'wgMFEditorOptions' ); tokenType = tokenType || 'edit'; isCacheable = tokenType !== 'centralauth'; @@ -159,7 +160,7 @@ // FIXME: Per the separation of concerns design principle, we should probably // not be worrying about whether or not the user is anonymous within getToken. // We'll need to check upstream usage though before removing this. - if ( user.isAnon() && !mw.config.get( 'wgMFAnonymousEditing' ) ) { + if ( user.isAnon() && !editorConfig.anonymousEditing ) { return d.reject( 'Token requested when not logged in.' ); // If the token is cached, return it from cache. } else if ( isCacheable && this.tokenCache[ endpoint ].hasOwnProperty( tokenType ) ) { @@ -167,7 +168,7 @@ // If the token is available from mw.user.tokens, get it from there. } else if ( $.inArray( tokenType, easyTokens ) > -1 && !endpoint && !caToken ) { token = user.tokens.get( tokenType + 'Token' ); - if ( token && ( token !== '+\\' || mw.config.get( 'wgMFAnonymousEditing' ) ) ) { + if ( token && ( token !== '+\\' || editorConfig.anonymousEditing ) ) { d.resolve( token ); } else { d.reject( 'Anonymous token.' ); @@ -192,7 +193,7 @@ } ).done( function ( tokenData ) { if ( tokenData && tokenData.tokens && !tokenData.warnings ) { token = tokenData.tokens[ tokenType + 'token' ]; - if ( token && ( token !== '+\\' || mw.config.get( 'wgMFAnonymousEditing' ) ) ) { + if ( token && ( token !== '+\\' || editorConfig.anonymousEditing ) ) { d.resolve( token ); } else { d.reject( 'Anonymous token.' ); diff --git a/javascripts/modules/editor/init.js b/javascripts/modules/editor/init.js index 3f883d8..e520707 100644 --- a/javascripts/modules/editor/init.js +++ b/javascripts/modules/editor/init.js @@ -260,7 +260,7 @@ } else { if ( user.isAnon() ) { // Cta's will be rendered in EditorOverlay, if anonymous editing is enabled. - if ( mw.config.get( 'wgMFAnonymousEditing' ) ) { + if ( mw.config.get( 'wgMFEditorOptions' ).anonymousEditing ) { init(); } else { initCta(); diff --git a/tests/qunit/modules/talk/test_TalkSectionAddOverlay.js b/tests/qunit/modules/talk/test_TalkSectionAddOverlay.js index f08d25c..6571f14 100644 --- a/tests/qunit/modules/talk/test_TalkSectionAddOverlay.js +++ b/tests/qunit/modules/talk/test_TalkSectionAddOverlay.js @@ -5,14 +5,7 @@ QUnit.module( 'MobileFrontend TalkSectionAddOverlay', { setup: function() { - // tokens for anonymous users only when anonymous editing is allowed - this.anonEditing = mw.config.get( 'wgMFAnonymousEditing' ); - mw.config.set( 'wgMFAnonymousEditing', true ); this.sandbox.stub( api, 'postWithToken' ).returns( $.Deferred().resolve() ); - }, - teardown: function() { - // restore old value of wgMFAnonymousEditing - mw.config.set( 'wgMFAnonymousEditing', this.anonEditing ); } } ); @@ -37,4 +30,4 @@ assert.strictEqual( overlay._saveHit, true, 'The save was recognized' ); } ); -}( mw.mobileFrontend, jQuery ) ); \ No newline at end of file +}( mw.mobileFrontend, jQuery ) ); diff --git a/tests/qunit/test_api.js b/tests/qunit/test_api.js index eb4bed7..6c2437b 100644 --- a/tests/qunit/test_api.js +++ b/tests/qunit/test_api.js @@ -135,14 +135,15 @@ } ); QUnit.test( '#getTokenWithEndpoint - get anon token (stable)', 1, function( assert ) { - mw.config.set( 'wgMFAnonymousEditing', false ); + mw.config.set( 'wgMFEditorOptions', { + 'anonymousEditing': false + } ); this.api.getTokenWithEndpoint( 'upload' ).fail( function( msg ) { assert.strictEqual( msg, 'Anonymous token.', 'No token given - user must be anon' ); } ); } ); QUnit.test ( '#getTokenWithEndpoint - get anon token (alpha)', 1, function( assert ) { - mw.config.set( 'wgMFAnonymousEditing', true ); this.api.getTokenWithEndpoint( 'edit' ).done( function( token ) { assert.strictEqual( token, '123', 'Got a token for anonymous editing' ); } ); -- To view, visit https://gerrit.wikimedia.org/r/180122 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8d11fa1521e317aa2f069d87bb49adb6fff3e4be Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Florianschmidtwelzow <[email protected]> Gerrit-Reviewer: Awjrichards <[email protected]> Gerrit-Reviewer: Florianschmidtwelzow <[email protected]> Gerrit-Reviewer: Jdlrobson <[email protected]> Gerrit-Reviewer: MaxSem <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
