mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-15 03:34:03 +00:00
Merge "Remove redundant wgPopupsShouldSendModuleToUser variable"
This commit is contained in:
commit
515ed91475
|
@ -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
|
||||
);
|
||||
|
|
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.map.json
vendored
BIN
resources/dist/index.js.map.json
vendored
Binary file not shown.
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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.'
|
||||
|
|
|
@ -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.' );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue