Merge "Remove redundant wgPopupsShouldSendModuleToUser variable"

This commit is contained in:
jenkins-bot 2019-04-12 17:09:56 +00:00 committed by Gerrit Code Review
commit 515ed91475
6 changed files with 15 additions and 18 deletions

View file

@ -135,8 +135,6 @@ class PopupsHooks {
* previews should be enabled. Depending on the general setting done on the wiki and
* - in cases where the feature is used as BetaFeature - of the user's BetaFeature
* setting.
* * `wgPopupsShouldSendModuleToUser' - The server's notion of whether or not the
* user has enabled Page Previews (see `\Popups\PopupsContext#shouldSendModuleToUser`).
* * `wgPopupsConflictsWithNavPopupGadget' - The server's notion of whether or not the
* user has enabled conflicting Navigational Popups Gadget.
*
@ -151,7 +149,6 @@ class PopupsHooks {
$user = $out->getUser();
$vars['wgPopupsReferencePreviews'] = self::isReferencePreviewsEnabled( $user, $config );
$vars['wgPopupsShouldSendModuleToUser'] = $context->shouldSendModuleToUser( $user );
$vars['wgPopupsConflictsWithNavPopupGadget'] = $context->conflictsWithNavPopupsGadget(
$user
);

Binary file not shown.

Binary file not shown.

View file

@ -24,12 +24,17 @@ export default function isEnabled( user, userSettings, config ) {
}
if ( !user.isAnon() ) {
return config.get( 'wgPopupsShouldSendModuleToUser' );
}
if ( !userSettings.hasIsEnabled() ) {
// For logged-in users, enablement is equal to the
// loading of this very code.
return true;
} else {
// For anonymous users, the code loads always, but the feature
// can be toggled at run-time via local storage.
if ( !userSettings.hasIsEnabled() ) {
// Default when no setting is stored.
return true;
} else {
return userSettings.getIsEnabled();
}
}
return userSettings.getIsEnabled();
}

View file

@ -54,8 +54,6 @@ QUnit.test( 'it should handle logged in users', ( assert ) => {
userSettings = createStubUserSettings( false ),
config = new Map();
config.set( 'wgPopupsShouldSendModuleToUser', true );
assert.ok(
isEnabled( user, userSettings, config ),
'If the user is logged in and the user is in the on group, then it\'s enabled.'

View file

@ -281,7 +281,7 @@ class PopupsHooksTest extends MediaWikiTestCase {
->disableOriginalConstructor()
->getMock();
$outputPage->expects( $this->once() )
$outputPage->expects( $this->any() )
->method( 'getUser' )
->willReturn( $user );
@ -289,11 +289,11 @@ class PopupsHooksTest extends MediaWikiTestCase {
->setMethods( [ 'shouldSendModuleToUser', 'conflictsWithNavPopupsGadget' ] )
->disableOriginalConstructor()
->getMock();
$contextMock->expects( $this->once() )
$contextMock->expects( $this->any() )
->method( 'shouldSendModuleToUser' )
->with( $user )
->willReturn( false );
$contextMock->expects( $this->once() )
$contextMock->expects( $this->any() )
->method( 'conflictsWithNavPopupsGadget' )
->with( $user )
->willReturn( false );
@ -301,12 +301,9 @@ class PopupsHooksTest extends MediaWikiTestCase {
$this->setService( 'Popups.Context', $contextMock );
$vars = [];
PopupsHooks::onMakeGlobalVariablesScript( $vars, $outputPage );
$this->assertCount( 3, $vars, 'Three globals are are made.' );
$this->assertFalse( $vars[ 'wgPopupsShouldSendModuleToUser' ],
'The PopupsShouldSendModuleToUser global is present and false.' );
$this->assertCount( 2, $vars, 'Number of added variables.' );
$this->assertFalse( $vars[ 'wgPopupsConflictsWithNavPopupGadget' ],
'The PopupsConflictsWithNavPopupGadget global is present and false.' );
}