mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-23 15:16:50 +00:00
Remove all BetaFeature code from ReferencePreviews
The extension is out of beta and will be enabled by default now. Leaving some hints if we decide to also remove the feature flag. Bug: T282999 Bug: T351708 Change-Id: I1556b2f3592294d094770ede2c276eddeef8bbe9
This commit is contained in:
parent
7596165a5d
commit
b218a77ca4
|
@ -5,7 +5,6 @@ $cfg['directory_list'] = array_merge(
|
||||||
$cfg['directory_list'],
|
$cfg['directory_list'],
|
||||||
[
|
[
|
||||||
'../../extensions/Gadgets',
|
'../../extensions/Gadgets',
|
||||||
'../../extensions/BetaFeatures',
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -13,7 +12,6 @@ $cfg['exclude_analysis_directory_list'] = array_merge(
|
||||||
$cfg['exclude_analysis_directory_list'],
|
$cfg['exclude_analysis_directory_list'],
|
||||||
[
|
[
|
||||||
'../../extensions/Gadgets',
|
'../../extensions/Gadgets',
|
||||||
'../../extensions/BetaFeatures',
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
"UserGetDefaultOptions": "PopupsHooks",
|
"UserGetDefaultOptions": "PopupsHooks",
|
||||||
"MakeGlobalVariablesScript": "PopupsHooks",
|
"MakeGlobalVariablesScript": "PopupsHooks",
|
||||||
"LocalUserCreated": "PopupsHooks",
|
"LocalUserCreated": "PopupsHooks",
|
||||||
"GetBetaFeaturePreferences": "PopupsHooks",
|
|
||||||
"ResourceLoaderRegisterModules": "PopupsHooks"
|
"ResourceLoaderRegisterModules": "PopupsHooks"
|
||||||
},
|
},
|
||||||
"HookHandlers": {
|
"HookHandlers": {
|
||||||
|
@ -86,10 +85,6 @@
|
||||||
"description": "Feature flag to enable or disable the separate popup type for references created via the Cite extension's <ref> tag.",
|
"description": "Feature flag to enable or disable the separate popup type for references created via the Cite extension's <ref> tag.",
|
||||||
"value": true
|
"value": true
|
||||||
},
|
},
|
||||||
"PopupsReferencePreviewsBetaFeature": {
|
|
||||||
"description": "Make Reference Previews a Beta feature.",
|
|
||||||
"value": true
|
|
||||||
},
|
|
||||||
"PopupsStatsvSamplingRate": {
|
"PopupsStatsvSamplingRate": {
|
||||||
"description": "Sampling rate for logging performance data to statsv.",
|
"description": "Sampling rate for logging performance data to statsv.",
|
||||||
"value": 0
|
"value": 0
|
||||||
|
|
|
@ -33,7 +33,5 @@
|
||||||
"popups-refpreview-note": "Note",
|
"popups-refpreview-note": "Note",
|
||||||
"popups-refpreview-web": "Web reference",
|
"popups-refpreview-web": "Web reference",
|
||||||
"popups-refpreview-collapsible-placeholder": "This reference includes a figure which does not fit in the preview.",
|
"popups-refpreview-collapsible-placeholder": "This reference includes a figure which does not fit in the preview.",
|
||||||
"popups-refpreview-user-preference-label": "Enable reference previews (get quick previews of a reference while reading a page)",
|
"popups-refpreview-user-preference-label": "Enable reference previews (get quick previews of a reference while reading a page)"
|
||||||
"popups-refpreview-beta-feature-message": "Reference Previews",
|
|
||||||
"popups-refpreview-beta-feature-description": "Show a preview of a reference by hovering over its footnote marker.\n\nPlease note: If you're using the [//en.wikipedia.org/wiki/Wikipedia:Tools/Navigation_popups Navigation popups] gadget or the [[mw:Special:MyLanguage/Reference Tooltips|Reference Tooltips]] gadget, you won't see reference previews."
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,5 @@
|
||||||
"popups-refpreview-note": "Heading for a popup previewing a footnote.\n{{Identical|Note}}",
|
"popups-refpreview-note": "Heading for a popup previewing a footnote.\n{{Identical|Note}}",
|
||||||
"popups-refpreview-web": "Heading for a popup previewing a citation from a website.\n{{Identical|Website}}",
|
"popups-refpreview-web": "Heading for a popup previewing a citation from a website.\n{{Identical|Website}}",
|
||||||
"popups-refpreview-collapsible-placeholder": "Placeholder text for collapsible tables, templates, or other large elements inside of a reference.",
|
"popups-refpreview-collapsible-placeholder": "Placeholder text for collapsible tables, templates, or other large elements inside of a reference.",
|
||||||
"popups-refpreview-user-preference-label": "Label for the user option to enable or disable reference preview popups",
|
"popups-refpreview-user-preference-label": "Label for the user option to enable or disable reference preview popups"
|
||||||
"popups-refpreview-beta-feature-message": "Label for the Reference Previews Beta feature.",
|
|
||||||
"popups-refpreview-beta-feature-description": "Description for the Reference Previews Beta feature, describing the feature that will be enabled."
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ namespace Popups;
|
||||||
|
|
||||||
use Config;
|
use Config;
|
||||||
use ExtensionRegistry;
|
use ExtensionRegistry;
|
||||||
use MediaWiki\Extension\BetaFeatures\BetaFeatures;
|
|
||||||
use MediaWiki\MediaWikiServices;
|
use MediaWiki\MediaWikiServices;
|
||||||
use MediaWiki\SpecialPage\SpecialPageFactory;
|
use MediaWiki\SpecialPage\SpecialPageFactory;
|
||||||
use MediaWiki\Title\Title;
|
use MediaWiki\Title\Title;
|
||||||
|
@ -63,18 +62,12 @@ class PopupsContext {
|
||||||
*/
|
*/
|
||||||
public const REFERENCE_PREVIEWS_PREFERENCE_NAME = 'popups-reference-previews';
|
public const REFERENCE_PREVIEWS_PREFERENCE_NAME = 'popups-reference-previews';
|
||||||
|
|
||||||
/**
|
|
||||||
* User preference key to enable/disable Reference Previews
|
|
||||||
*/
|
|
||||||
public const REFERENCE_PREVIEWS_BETA_PREFERENCE_NAME = 'popupsreferencepreviews';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flags passed on to JS representing preferences
|
* Flags passed on to JS representing preferences
|
||||||
*/
|
*/
|
||||||
private const NAV_POPUPS_ENABLED = 1;
|
private const NAV_POPUPS_ENABLED = 1;
|
||||||
private const REF_TOOLTIPS_ENABLED = 2;
|
private const REF_TOOLTIPS_ENABLED = 2;
|
||||||
private const REFERENCE_PREVIEWS_ENABLED = 4;
|
private const REFERENCE_PREVIEWS_ENABLED = 4;
|
||||||
private const REFERENCE_PREVIEWS_BETA = 8;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Config
|
* @var \Config
|
||||||
|
@ -163,28 +156,11 @@ class PopupsContext {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove when not in Beta any more
|
|
||||||
if ( $this->isReferencePreviewsInBeta() ) {
|
|
||||||
return BetaFeatures::isFeatureEnabled(
|
|
||||||
$user,
|
|
||||||
self::REFERENCE_PREVIEWS_BETA_PREFERENCE_NAME
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return !$user->isNamed() || $this->userOptionsLookup->getBoolOption(
|
return !$user->isNamed() || $this->userOptionsLookup->getBoolOption(
|
||||||
$user, self::REFERENCE_PREVIEWS_PREFERENCE_NAME
|
$user, self::REFERENCE_PREVIEWS_PREFERENCE_NAME
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool whether or not reference previews are a beta feature
|
|
||||||
*/
|
|
||||||
public function isReferencePreviewsInBeta() {
|
|
||||||
// TODO: Remove when not in Beta any more
|
|
||||||
return $this->config->get( 'PopupsReferencePreviewsBetaFeature' ) &&
|
|
||||||
\ExtensionRegistry::getInstance()->isLoaded( 'BetaFeatures' );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \User $user User whose preferences are checked
|
* @param \User $user User whose preferences are checked
|
||||||
* @return int
|
* @return int
|
||||||
|
@ -192,8 +168,7 @@ class PopupsContext {
|
||||||
public function getConfigBitmaskFromUser( \User $user ) {
|
public function getConfigBitmaskFromUser( \User $user ) {
|
||||||
return ( $this->conflictsWithNavPopupsGadget( $user ) ? self::NAV_POPUPS_ENABLED : 0 ) |
|
return ( $this->conflictsWithNavPopupsGadget( $user ) ? self::NAV_POPUPS_ENABLED : 0 ) |
|
||||||
( $this->conflictsWithRefTooltipsGadget( $user ) ? self::REF_TOOLTIPS_ENABLED : 0 ) |
|
( $this->conflictsWithRefTooltipsGadget( $user ) ? self::REF_TOOLTIPS_ENABLED : 0 ) |
|
||||||
( $this->isReferencePreviewsEnabled( $user ) ? self::REFERENCE_PREVIEWS_ENABLED : 0 ) |
|
( $this->isReferencePreviewsEnabled( $user ) ? self::REFERENCE_PREVIEWS_ENABLED : 0 );
|
||||||
( $this->isReferencePreviewsInBeta() ? self::REFERENCE_PREVIEWS_BETA : 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -93,9 +93,7 @@ class PopupsHooks implements
|
||||||
$readingOptions = self::getPagePreviewPrefToggle( $user, $context );
|
$readingOptions = self::getPagePreviewPrefToggle( $user, $context );
|
||||||
|
|
||||||
$config = MediaWikiServices::getInstance()->getService( 'Popups.Config' );
|
$config = MediaWikiServices::getInstance()->getService( 'Popups.Config' );
|
||||||
if ( $config->get( 'PopupsReferencePreviews' ) &&
|
if ( $config->get( 'PopupsReferencePreviews' ) ) {
|
||||||
!$config->get( 'PopupsReferencePreviewsBetaFeature' )
|
|
||||||
) {
|
|
||||||
$readingOptions = array_merge(
|
$readingOptions = array_merge(
|
||||||
$readingOptions,
|
$readingOptions,
|
||||||
self::getReferencePreviewPrefToggle( $user, $context )
|
self::getReferencePreviewPrefToggle( $user, $context )
|
||||||
|
@ -230,9 +228,7 @@ class PopupsHooks implements
|
||||||
*
|
*
|
||||||
* Variables added:
|
* Variables added:
|
||||||
* * `wgPopupsReferencePreviews' - The server's notion of whether or not the reference
|
* * `wgPopupsReferencePreviews' - The server's notion of whether or not the reference
|
||||||
* previews should be enabled. Depending on the general setting done on the wiki and
|
* previews should be enabled. Depending on the general setting done on the wiki.
|
||||||
* - in cases where the feature is used as BetaFeature - of the user's BetaFeature
|
|
||||||
* setting.
|
|
||||||
* * `wgPopupsConflictsWithNavPopupGadget' - The server's notion of whether or not the
|
* * `wgPopupsConflictsWithNavPopupGadget' - The server's notion of whether or not the
|
||||||
* user has enabled conflicting Navigational Popups Gadget.
|
* user has enabled conflicting Navigational Popups Gadget.
|
||||||
* * `wgPopupsConflictsWithRefTooltipsGadget' - The server's notion of whether or not the
|
* * `wgPopupsConflictsWithRefTooltipsGadget' - The server's notion of whether or not the
|
||||||
|
@ -258,11 +254,7 @@ class PopupsHooks implements
|
||||||
$default = $config->get( 'PopupsOptInDefaultState' );
|
$default = $config->get( 'PopupsOptInDefaultState' );
|
||||||
$defaultOptions[PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME] = $default;
|
$defaultOptions[PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME] = $default;
|
||||||
|
|
||||||
// As long as in Beta, don't set a default for Reference Previews. Rely on it either being
|
if ( $config->get( 'PopupsReferencePreviews' ) ) {
|
||||||
// null (= disabled), or follow what the "betafeatures-auto-enroll" flag says.
|
|
||||||
if ( $config->get( 'PopupsReferencePreviews' ) &&
|
|
||||||
!$config->get( 'PopupsReferencePreviewsBetaFeature' )
|
|
||||||
) {
|
|
||||||
$defaultOptions[PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME] = '1';
|
$defaultOptions[PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME] = '1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,11 +275,7 @@ class PopupsHooks implements
|
||||||
$default
|
$default
|
||||||
);
|
);
|
||||||
|
|
||||||
// As long as in Beta, don't set a default for Reference Previews. Rely on it either being
|
if ( $config->get( 'PopupsReferencePreviews' ) ) {
|
||||||
// null (= disabled), or follow what the "betafeatures-auto-enroll" flag says.
|
|
||||||
if ( $config->get( 'PopupsReferencePreviews' ) &&
|
|
||||||
!$config->get( 'PopupsReferencePreviewsBetaFeature' )
|
|
||||||
) {
|
|
||||||
$this->userOptionsManager->setOption(
|
$this->userOptionsManager->setOption(
|
||||||
$user,
|
$user,
|
||||||
PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME,
|
PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME,
|
||||||
|
@ -296,33 +284,6 @@ class PopupsHooks implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Register preferences that enable experimental features.
|
|
||||||
*
|
|
||||||
* @param User $user User whose preferences are being modified
|
|
||||||
* @param array[] &$prefs Array of beta features
|
|
||||||
*/
|
|
||||||
public function onGetBetaFeaturePreferences( User $user, array &$prefs ) {
|
|
||||||
/** @var Config $config */
|
|
||||||
$config = MediaWikiServices::getInstance()->getService( 'Popups.Config' );
|
|
||||||
$extensionAssetsPath = $config->get( 'ExtensionAssetsPath' );
|
|
||||||
|
|
||||||
if ( $config->get( 'PopupsReferencePreviewsBetaFeature' ) &&
|
|
||||||
$config->get( 'PopupsReferencePreviews' )
|
|
||||||
) {
|
|
||||||
$prefs[PopupsContext::REFERENCE_PREVIEWS_BETA_PREFERENCE_NAME] = [
|
|
||||||
'label-message' => 'popups-refpreview-beta-feature-message',
|
|
||||||
'desc-message' => 'popups-refpreview-beta-feature-description',
|
|
||||||
'screenshot' => [
|
|
||||||
'ltr' => "$extensionAssetsPath/Popups/resources/ext.popups.images/refpreview-beta-ltr.svg",
|
|
||||||
'rtl' => "$extensionAssetsPath/Popups/resources/ext.popups.images/refpreview-beta-rtl.svg",
|
|
||||||
],
|
|
||||||
'info-link' => 'https://mediawiki.org/wiki/Help:Reference_Previews',
|
|
||||||
'discussion-link' => 'https://mediawiki.org/wiki/Help_Talk:Reference_Previews',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ResourceLoaderRegisterModules hook handler.
|
* ResourceLoaderRegisterModules hook handler.
|
||||||
*
|
*
|
||||||
|
|
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.
|
@ -1,30 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="2560" height="1571" viewBox="0 0 2560 1571">
|
|
||||||
<defs>
|
|
||||||
<path id="a" d="M0 0v1474.025L116.364 1571l116.363-96.975L349.091 1571l116.364-96.975L581.818 1571l116.364-96.975L814.545 1571l116.364-96.975L1047.273 1571l116.363-96.975L1280 1571l116.364-96.975L1512.727 1571l116.364-96.975L1745.455 1571l116.363-96.975L1978.182 1571l116.363-96.975L2210.91 1571l116.364-96.975L2443.636 1571 2560 1474.025V0z"/>
|
|
||||||
</defs>
|
|
||||||
<g fill="none" fill-rule="evenodd">
|
|
||||||
<mask id="b" fill="#fff">
|
|
||||||
<use xlink:href="#a"/>
|
|
||||||
</mask>
|
|
||||||
<g mask="url(#b)">
|
|
||||||
<path fill="#FFF" d="M0 0h2560v1571H0"/>
|
|
||||||
<path fill="#EAECF0" d="M106.667 213.346c0-77.58 58.181-135.766 135.757-135.766 77.576 0 135.758 58.185 135.758 135.766 0 77.58-58.182 135.765-135.758 135.765-77.576 0-135.757-58.185-135.757-135.765zm261.818 223.043V387.9H126.06v48.488h242.424zm0 1144.309V562.457H126.06v1027.938h242.424v-9.697zM2259.394 48.488h252.121v58.185h-252.121V48.488zm-232.727 0H2240v58.185h-213.333V48.488zm-232.728 0h213.334v58.185h-213.334V48.488zm-223.03 0h126.06v58.185h-126.06V48.488zm145.455 0h58.181v58.185h-58.181V48.488zm-223.03 0h58.181v58.185h-58.182V48.488z"/>
|
|
||||||
<g fill="#EAECF0">
|
|
||||||
<path d="M2501.818 155.161v38.79h-892.121v-38.79h892.121zm9.697-9.698H1600v58.185h911.515v-58.185z"/>
|
|
||||||
<path d="M1629.09 164.858h19.395v19.395h-19.395z"/>
|
|
||||||
</g>
|
|
||||||
<path fill="#EAECF0" d="M0 0v1571h2560V0H0zm9.697 9.698h2540.606v1459.769l-106.667 88.926-116.363-96.975-116.364 96.975-116.364-96.975-116.363 96.975-116.364-96.975-116.363 96.975-116.364-96.975-116.364 96.975-116.363-96.975L1280 1558.393l-116.364-96.975-116.363 96.975-116.364-96.975-116.364 96.975-116.363-96.975-116.364 96.975-116.363-96.975-116.364 96.975-116.364-96.975-116.363 96.975-106.667-87.278V9.698z"/>
|
|
||||||
</g>
|
|
||||||
<path fill="#EAECF0" d="M2067 281h387v1290h-387V281zm-1602 0h1516v1344H465V281z" mask="url(#b)"/>
|
|
||||||
<path fill="#C8CCD1" d="M614 416h1105v78.774H614V416zm0 377.613h1105v78.774H614v-78.774zm0-188.806h1240v78.773H614v-78.773zm0 566.42h1240V1250H614v-78.774zm0-188.807h553v78.773H614V982.42zm651 0h504v78.773h-504V982.42z" mask="url(#b)"/>
|
|
||||||
<path fill="#36C" d="M1190 982h50v47h-50z" mask="url(#b)"/>
|
|
||||||
<g mask="url(#b)">
|
|
||||||
<g transform="translate(1173.13 580.297)">
|
|
||||||
<path fill="#FFF" d="M0 0h684v368.861H0z"/>
|
|
||||||
<ellipse cx="97.477" cy="79.511" fill="#36C" rx="37.5"/>
|
|
||||||
<path fill="#36C" d="M60 161h441.92v25.007H60zm0 48h560v25.007H60zm0 81h245.164v25.007H60z"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 2.5 KiB |
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="2560" height="1571" viewBox="0 0 2560 1571">
|
|
||||||
<defs>
|
|
||||||
<path id="a" d="M0 0v1474.025L116.364 1571l116.363-96.975L349.091 1571l116.364-96.975L581.818 1571l116.364-96.975L814.545 1571l116.364-96.975L1047.273 1571l116.363-96.975L1280 1571l116.364-96.975L1512.727 1571l116.364-96.975L1745.455 1571l116.363-96.975L1978.182 1571l116.363-96.975L2210.91 1571l116.364-96.975L2443.636 1571 2560 1474.025V0z"/>
|
|
||||||
</defs>
|
|
||||||
<g fill="none" fill-rule="evenodd">
|
|
||||||
<mask id="b" fill="#fff">
|
|
||||||
<use xlink:href="#a"/>
|
|
||||||
</mask>
|
|
||||||
<g mask="url(#b)">
|
|
||||||
<path fill="#FFF" d="M2560 0H0v1571h2560"/>
|
|
||||||
<path fill="#EAECF0" d="M2453.333 213.346c0-77.58-58.181-135.766-135.757-135.766-77.576 0-135.758 58.185-135.758 135.766 0 77.58 58.182 135.765 135.758 135.765 77.576 0 135.757-58.185 135.757-135.765zm-261.818 223.043V387.9h242.425v48.488h-242.424zm0 1144.309V562.457h242.425v1027.938h-242.424v-9.697zM300.606 48.488H48.485v58.185h252.121V48.488zm232.727 0H320v58.185h213.333V48.488zm232.728 0H552.727v58.185h213.334V48.488zm223.03 0h-126.06v58.185h126.06V48.488zm-145.455 0h-58.181v58.185h58.181V48.488zm223.03 0h-58.181v58.185h58.182V48.488z"/>
|
|
||||||
<g fill="#EAECF0">
|
|
||||||
<path d="M58.182 155.161v38.79h892.121v-38.79H58.182zm-9.697-9.698H960v58.185H48.485v-58.185z"/>
|
|
||||||
<path d="M930.91 164.858h-19.395v19.395h19.395z"/>
|
|
||||||
</g>
|
|
||||||
<path fill="#EAECF0" d="M493 281H106v1344h387V281zm1602 0H579v1344h1516V281z"/>
|
|
||||||
<path fill="#C8CCD1" d="M1946 416H841v78.774h1105V416zm0 377.613H841v78.774h1105v-78.774zm0-188.806H706v78.773h1240v-78.773zm0 566.42H706V1250h1240v-78.774zm0-188.807h-553v78.773h553V982.42zm-651 0H791v78.773h504V982.42z"/>
|
|
||||||
<path fill="#36C" d="M1370 982h-50v47h50z"/>
|
|
||||||
<g transform="matrix(-1 0 0 1 1386.87 580.297)">
|
|
||||||
<path fill="#FFF" d="M0 0h684v368.861H0z"/>
|
|
||||||
<ellipse cx="97.477" cy="79.511" fill="#36C" rx="37.5"/>
|
|
||||||
<path fill="#36C" d="M60 161h441.92v25.007H60zm0 48h560v25.007H60zm0 81h245.164v25.007H60z"/>
|
|
||||||
</g>
|
|
||||||
<path fill="#EAECF0" d="M2560 0v1571H0V0h2560zm-9.697 9.698H9.697v1459.769l106.667 88.926 116.363-96.975 116.364 96.975 116.364-96.975 116.363 96.975 116.364-96.975 116.363 96.975 116.364-96.975 116.364 96.975 116.363-96.975L1280 1558.393l116.364-96.975 116.363 96.975 116.364-96.975 116.364 96.975 116.363-96.975 116.364 96.975 116.363-96.975 116.364 96.975 116.364-96.975 116.363 96.975 106.667-87.278V9.698z"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 2.4 KiB |
|
@ -15,7 +15,7 @@ const canSaveToUserPreferences = require( './canSaveToUserPreferences.js' );
|
||||||
*/
|
*/
|
||||||
export default function isReferencePreviewsEnabled( user, userSettings, config ) {
|
export default function isReferencePreviewsEnabled( user, userSettings, config ) {
|
||||||
// TODO: This and the final `mw.user.options` check are currently redundant. Only this here
|
// TODO: This and the final `mw.user.options` check are currently redundant. Only this here
|
||||||
// should be removed when the feature flag is not needed any more.
|
// should be removed when the wgPopupsReferencePreviews feature flag is not needed any more.
|
||||||
if ( !config.get( 'wgPopupsReferencePreviews' ) ) {
|
if ( !config.get( 'wgPopupsReferencePreviews' ) ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,6 @@ export default function isReferencePreviewsEnabled( user, userSettings, config )
|
||||||
return userSettings.isReferencePreviewsEnabled();
|
return userSettings.isReferencePreviewsEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove when not in Beta any more
|
|
||||||
if ( config.get( 'wgPopupsReferencePreviews' ) ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Registered users never can enable popup types at run-time.
|
// Registered users never can enable popup types at run-time.
|
||||||
return mw.user.options.get( 'popups-reference-previews' ) === '1' ? true : null;
|
return mw.user.options.get( 'popups-reference-previews' ) === '1' ? true : null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
*/
|
*/
|
||||||
const NAV_POPUPS_ENABLED = 1,
|
const NAV_POPUPS_ENABLED = 1,
|
||||||
REF_TOOLTIPS_ENABLED = 2,
|
REF_TOOLTIPS_ENABLED = 2,
|
||||||
REFERENCE_PREVIEWS_ENABLED = 4,
|
REFERENCE_PREVIEWS_ENABLED = 4;
|
||||||
REFERENCE_PREVIEWS_BETA = 8;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes the bitmask that represents preferences to the related config options.
|
* Decodes the bitmask that represents preferences to the related config options.
|
||||||
|
@ -31,9 +30,5 @@ export default function setUserConfigFlags( config ) {
|
||||||
'wgPopupsReferencePreviews',
|
'wgPopupsReferencePreviews',
|
||||||
!!( popupsFlags & REFERENCE_PREVIEWS_ENABLED )
|
!!( popupsFlags & REFERENCE_PREVIEWS_ENABLED )
|
||||||
);
|
);
|
||||||
config.set(
|
|
||||||
'wgPopupsReferencePreviewsBetaFeature',
|
|
||||||
!!( popupsFlags & REFERENCE_PREVIEWS_BETA )
|
|
||||||
);
|
|
||||||
/* eslint-enable no-bitwise */
|
/* eslint-enable no-bitwise */
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@ export function createSettingsDialog( referencePreviewsAvaliable ) {
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
// TODO: Remove when not in Beta any more
|
|
||||||
if ( !referencePreviewsAvaliable ) {
|
if ( !referencePreviewsAvaliable ) {
|
||||||
// Anonymous users can't access reference previews as long as they are in beta
|
// Anonymous users can't access reference previews when they're disabled
|
||||||
|
// TODO: Remove when the wgPopupsReferencePreviews feature flag is not needed any more
|
||||||
choices.splice( 1, 1 );
|
choices.splice( 1, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,21 +167,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove when not in Beta any more (T276200)
|
|
||||||
.mwe-popups-container.footer-empty .mwe-popups-extract {
|
|
||||||
margin-bottom: @popupPadding;
|
|
||||||
|
|
||||||
.mwe-popups-scroll {
|
|
||||||
max-height: 403px - 2 * @popupPadding + @previewPointerHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Remove when not in Beta any more (T276200)
|
|
||||||
&.flipped-y .mwe-popups-container.footer-empty .mwe-popups-extract,
|
|
||||||
&.flipped-x-y .mwe-popups-container.footer-empty .mwe-popups-extract {
|
|
||||||
margin-bottom: @popupPadding + @previewPointerHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Triangles/Pointers */
|
/* Triangles/Pointers */
|
||||||
&.mwe-popups-no-image-pointer {
|
&.mwe-popups-no-image-pointer {
|
||||||
&::before {
|
&::before {
|
||||||
|
|
|
@ -103,22 +103,16 @@ export function renderReferencePreview(
|
||||||
Array.prototype.forEach.call( node.querySelectorAll( '.headerSort' ), undoHeaderSort );
|
Array.prototype.forEach.call( node.querySelectorAll( '.headerSort' ), undoHeaderSort );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// TODO: Remove when not in Beta any more
|
// TODO: Do not remove this but move it up into the templateHTML constant!
|
||||||
if ( !mw.config.get( 'wgPopupsReferencePreviewsBetaFeature' ) ) {
|
const settingsButton = document.createElement( 'a' );
|
||||||
// TODO: Do not remove this but move it up into the templateHTML constant!
|
settingsButton.classList.add( 'cdx-button', 'cdx-button--fake-button', 'cdx-button--fake-button--enabled', 'cdx-button--weight-quiet', 'cdx-button--icon-only', 'mwe-popups-settings-button' );
|
||||||
const settingsButton = document.createElement( 'a' );
|
const settingsIcon = document.createElement( 'span' );
|
||||||
settingsButton.classList.add( 'cdx-button', 'cdx-button--fake-button', 'cdx-button--fake-button--enabled', 'cdx-button--weight-quiet', 'cdx-button--icon-only', 'mwe-popups-settings-button' );
|
settingsIcon.classList.add( 'popups-icon', 'popups-icon--size-small', 'popups-icon--settings' );
|
||||||
const settingsIcon = document.createElement( 'span' );
|
const settingsButtonLabel = document.createElement( 'span' );
|
||||||
settingsIcon.classList.add( 'popups-icon', 'popups-icon--size-small', 'popups-icon--settings' );
|
settingsButtonLabel.textContent = mw.msg( 'popups-settings-icon-gear-title' );
|
||||||
const settingsButtonLabel = document.createElement( 'span' );
|
settingsButton.append( settingsIcon );
|
||||||
settingsButtonLabel.textContent = mw.msg( 'popups-settings-icon-gear-title' );
|
settingsButton.append( settingsButtonLabel );
|
||||||
settingsButton.append( settingsIcon );
|
el.querySelector( '.mwe-popups-settings' ).appendChild( settingsButton );
|
||||||
settingsButton.append( settingsButtonLabel );
|
|
||||||
el.querySelector( '.mwe-popups-settings' ).appendChild( settingsButton );
|
|
||||||
} else {
|
|
||||||
// Change the styling when there is no content in the footer (to prevent empty space)
|
|
||||||
el.querySelector( '.mwe-popups-container' ).classList.add( 'footer-empty' );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( isTrackingEnabled() ) {
|
if ( isTrackingEnabled() ) {
|
||||||
el.querySelector( '.mw-parser-output' ).addEventListener( 'click', ( ev ) => {
|
el.querySelector( '.mw-parser-output' ).addEventListener( 'click', ( ev ) => {
|
||||||
|
|
|
@ -5,30 +5,28 @@ QUnit.module( 'ext.popups#setUserConfigFlags' );
|
||||||
QUnit.test( 'config settings are successfully set from bitmask', ( assert ) => {
|
QUnit.test( 'config settings are successfully set from bitmask', ( assert ) => {
|
||||||
const config = new Map();
|
const config = new Map();
|
||||||
|
|
||||||
config.set( 'wgPopupsFlags', '15' );
|
config.set( 'wgPopupsFlags', '7' );
|
||||||
setUserConfigFlags( config );
|
setUserConfigFlags( config );
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
[
|
[
|
||||||
config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
|
config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
|
||||||
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
|
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
|
||||||
config.get( 'wgPopupsReferencePreviews' ),
|
config.get( 'wgPopupsReferencePreviews' )
|
||||||
config.get( 'wgPopupsReferencePreviewsBetaFeature' )
|
|
||||||
],
|
],
|
||||||
[ true, true, true, true ]
|
[ true, true, true ]
|
||||||
);
|
);
|
||||||
|
|
||||||
config.set( 'wgPopupsFlags', '10' );
|
config.set( 'wgPopupsFlags', '2' );
|
||||||
setUserConfigFlags( config );
|
setUserConfigFlags( config );
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
[
|
[
|
||||||
config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
|
config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
|
||||||
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
|
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
|
||||||
config.get( 'wgPopupsReferencePreviews' ),
|
config.get( 'wgPopupsReferencePreviews' )
|
||||||
config.get( 'wgPopupsReferencePreviewsBetaFeature' )
|
|
||||||
],
|
],
|
||||||
[ false, true, false, true ]
|
[ false, true, false ]
|
||||||
);
|
);
|
||||||
|
|
||||||
config.set( 'wgPopupsFlags', '5' );
|
config.set( 'wgPopupsFlags', '5' );
|
||||||
|
@ -38,10 +36,9 @@ QUnit.test( 'config settings are successfully set from bitmask', ( assert ) => {
|
||||||
[
|
[
|
||||||
config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
|
config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
|
||||||
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
|
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
|
||||||
config.get( 'wgPopupsReferencePreviews' ),
|
config.get( 'wgPopupsReferencePreviews' )
|
||||||
config.get( 'wgPopupsReferencePreviewsBetaFeature' )
|
|
||||||
],
|
],
|
||||||
[ true, false, true, false ]
|
[ true, false, true ]
|
||||||
);
|
);
|
||||||
|
|
||||||
config.set( 'wgPopupsFlags', '0' );
|
config.set( 'wgPopupsFlags', '0' );
|
||||||
|
@ -51,9 +48,8 @@ QUnit.test( 'config settings are successfully set from bitmask', ( assert ) => {
|
||||||
[
|
[
|
||||||
config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
|
config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
|
||||||
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
|
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
|
||||||
config.get( 'wgPopupsReferencePreviews' ),
|
config.get( 'wgPopupsReferencePreviews' )
|
||||||
config.get( 'wgPopupsReferencePreviewsBetaFeature' )
|
|
||||||
],
|
],
|
||||||
[ false, false, false, false ]
|
[ false, false, false ]
|
||||||
);
|
);
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -278,14 +278,12 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
|
||||||
* @param bool $navPops
|
* @param bool $navPops
|
||||||
* @param bool $refTooltips
|
* @param bool $refTooltips
|
||||||
* @param bool $refEnabled
|
* @param bool $refEnabled
|
||||||
* @param bool $refInBeta
|
|
||||||
* @param int $expected
|
* @param int $expected
|
||||||
*/
|
*/
|
||||||
public function testGetConfigBitmaskFromUser(
|
public function testGetConfigBitmaskFromUser(
|
||||||
$navPops,
|
$navPops,
|
||||||
$refTooltips,
|
$refTooltips,
|
||||||
$refEnabled,
|
$refEnabled,
|
||||||
$refInBeta,
|
|
||||||
$expected
|
$expected
|
||||||
) {
|
) {
|
||||||
$contextMock = $this->createPartialMock(
|
$contextMock = $this->createPartialMock(
|
||||||
|
@ -294,7 +292,6 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
|
||||||
'conflictsWithNavPopupsGadget',
|
'conflictsWithNavPopupsGadget',
|
||||||
'conflictsWithRefTooltipsGadget',
|
'conflictsWithRefTooltipsGadget',
|
||||||
'isReferencePreviewsEnabled',
|
'isReferencePreviewsEnabled',
|
||||||
'isReferencePreviewsInBeta',
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$contextMock->method( 'conflictsWithNavPopupsGadget' )
|
$contextMock->method( 'conflictsWithNavPopupsGadget' )
|
||||||
|
@ -303,8 +300,6 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
|
||||||
->willReturn( $refTooltips );
|
->willReturn( $refTooltips );
|
||||||
$contextMock->method( 'isReferencePreviewsEnabled' )
|
$contextMock->method( 'isReferencePreviewsEnabled' )
|
||||||
->willReturn( $refEnabled );
|
->willReturn( $refEnabled );
|
||||||
$contextMock->method( 'isReferencePreviewsInBeta' )
|
|
||||||
->willReturn( $refInBeta );
|
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$expected,
|
$expected,
|
||||||
|
@ -318,28 +313,24 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
true,
|
7,
|
||||||
15,
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
true,
|
2,
|
||||||
10,
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
false,
|
|
||||||
5,
|
5,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
|
||||||
0,
|
0,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
|
@ -55,15 +55,16 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::onGetPreferences
|
* @covers ::onGetPreferences
|
||||||
|
* @dataProvider provideReferencePreviewsFlag
|
||||||
*/
|
*/
|
||||||
public function testOnGetPreferencesNavPopupGadgetIsOn() {
|
public function testOnGetPreferencesNavPopupGadgetIsOn( bool $enabled ) {
|
||||||
$userMock = $this->createMock( User::class );
|
$userMock = $this->createMock( User::class );
|
||||||
|
|
||||||
$contextMock = $this->createMock( PopupsContext::class );
|
$contextMock = $this->createMock( PopupsContext::class );
|
||||||
$contextMock->expects( $this->once() )
|
$contextMock->expects( $this->once() )
|
||||||
->method( 'showPreviewsOptInOnPreferencesPage' )
|
->method( 'showPreviewsOptInOnPreferencesPage' )
|
||||||
->willReturn( true );
|
->willReturn( true );
|
||||||
$contextMock->expects( $this->once() )
|
$contextMock->expects( $this->exactly( $enabled ? 2 : 1 ) )
|
||||||
->method( 'conflictsWithNavPopupsGadget' )
|
->method( 'conflictsWithNavPopupsGadget' )
|
||||||
->with( $userMock )
|
->with( $userMock )
|
||||||
->willReturn( true );
|
->willReturn( true );
|
||||||
|
@ -71,6 +72,8 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
|
||||||
$this->setService( 'Popups.Context', $contextMock );
|
$this->setService( 'Popups.Context', $contextMock );
|
||||||
$prefs = [];
|
$prefs = [];
|
||||||
|
|
||||||
|
$this->setMwGlobals( 'wgPopupsReferencePreviews', $enabled );
|
||||||
|
|
||||||
$userOptionsManager = $this->getServiceContainer()->getUserOptionsManager();
|
$userOptionsManager = $this->getServiceContainer()->getUserOptionsManager();
|
||||||
( new PopupsHooks( $userOptionsManager ) )
|
( new PopupsHooks( $userOptionsManager ) )
|
||||||
->onGetPreferences( $userMock, $prefs );
|
->onGetPreferences( $userMock, $prefs );
|
||||||
|
@ -89,13 +92,14 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::onGetPreferences
|
* @covers ::onGetPreferences
|
||||||
|
* @dataProvider provideReferencePreviewsFlag
|
||||||
*/
|
*/
|
||||||
public function testOnGetPreferencesPreviewsEnabled() {
|
public function testOnGetPreferencesPreviewsEnabled( bool $enabled ) {
|
||||||
$contextMock = $this->createMock( PopupsContext::class );
|
$contextMock = $this->createMock( PopupsContext::class );
|
||||||
$contextMock->expects( $this->once() )
|
$contextMock->expects( $this->once() )
|
||||||
->method( 'showPreviewsOptInOnPreferencesPage' )
|
->method( 'showPreviewsOptInOnPreferencesPage' )
|
||||||
->willReturn( true );
|
->willReturn( true );
|
||||||
$contextMock->expects( $this->once() )
|
$contextMock->expects( $this->exactly( $enabled ? 2 : 1 ) )
|
||||||
->method( 'conflictsWithNavPopupsGadget' )
|
->method( 'conflictsWithNavPopupsGadget' )
|
||||||
->willReturn( false );
|
->willReturn( false );
|
||||||
|
|
||||||
|
@ -106,6 +110,8 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
|
||||||
'other' => 'notEmpty'
|
'other' => 'notEmpty'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$this->setMwGlobals( 'wgPopupsReferencePreviews', $enabled );
|
||||||
|
|
||||||
$userOptionsManager = $this->getServiceContainer()->getUserOptionsManager();
|
$userOptionsManager = $this->getServiceContainer()->getUserOptionsManager();
|
||||||
( new PopupsHooks( $userOptionsManager ) )
|
( new PopupsHooks( $userOptionsManager ) )
|
||||||
->onGetPreferences( $this->createMock( User::class ), $prefs );
|
->onGetPreferences( $this->createMock( User::class ), $prefs );
|
||||||
|
@ -124,13 +130,14 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::onGetPreferences
|
* @covers ::onGetPreferences
|
||||||
|
* @dataProvider provideReferencePreviewsFlag
|
||||||
*/
|
*/
|
||||||
public function testOnGetPreferencesPreviewsEnabledWhenSkinIsNotAvailable() {
|
public function testOnGetPreferencesPreviewsEnabledWhenSkinIsNotAvailable( bool $enabled ) {
|
||||||
$contextMock = $this->createMock( PopupsContext::class );
|
$contextMock = $this->createMock( PopupsContext::class );
|
||||||
$contextMock->expects( $this->once() )
|
$contextMock->expects( $this->once() )
|
||||||
->method( 'showPreviewsOptInOnPreferencesPage' )
|
->method( 'showPreviewsOptInOnPreferencesPage' )
|
||||||
->willReturn( true );
|
->willReturn( true );
|
||||||
$contextMock->expects( $this->once() )
|
$contextMock->expects( $this->exactly( $enabled ? 2 : 1 ) )
|
||||||
->method( 'conflictsWithNavPopupsGadget' )
|
->method( 'conflictsWithNavPopupsGadget' )
|
||||||
->willReturn( false );
|
->willReturn( false );
|
||||||
|
|
||||||
|
@ -140,6 +147,8 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
|
||||||
'other' => 'notEmpty'
|
'other' => 'notEmpty'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$this->setMwGlobals( 'wgPopupsReferencePreviews', $enabled );
|
||||||
|
|
||||||
$userOptionsManager = $this->getServiceContainer()->getUserOptionsManager();
|
$userOptionsManager = $this->getServiceContainer()->getUserOptionsManager();
|
||||||
( new PopupsHooks( $userOptionsManager ) )
|
( new PopupsHooks( $userOptionsManager ) )
|
||||||
->onGetPreferences( $this->createMock( User::class ), $prefs );
|
->onGetPreferences( $this->createMock( User::class ), $prefs );
|
||||||
|
@ -285,40 +294,39 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::onUserGetDefaultOptions
|
* @covers ::onUserGetDefaultOptions
|
||||||
* @dataProvider provideReferencePreviewsBetaFlag
|
* @dataProvider provideReferencePreviewsFlag
|
||||||
*/
|
*/
|
||||||
public function testOnUserGetDefaultOptions( $beta ) {
|
public function testOnUserGetDefaultOptions( bool $enabled ) {
|
||||||
$userOptions = [
|
$userOptions = [
|
||||||
'test' => 'not_empty'
|
'test' => 'not_empty'
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->setMwGlobals( [
|
$this->setMwGlobals( [
|
||||||
'wgPopupsOptInDefaultState' => '1',
|
'wgPopupsOptInDefaultState' => '1',
|
||||||
'wgPopupsReferencePreviews' => true,
|
'wgPopupsReferencePreviews' => $enabled,
|
||||||
'wgPopupsReferencePreviewsBetaFeature' => $beta,
|
|
||||||
] );
|
] );
|
||||||
|
|
||||||
$userOptionsManager = $this->getServiceContainer()->getUserOptionsManager();
|
$userOptionsManager = $this->getServiceContainer()->getUserOptionsManager();
|
||||||
( new PopupsHooks( $userOptionsManager ) )
|
( new PopupsHooks( $userOptionsManager ) )
|
||||||
->onUserGetDefaultOptions( $userOptions );
|
->onUserGetDefaultOptions( $userOptions );
|
||||||
$this->assertCount( 3 - $beta, $userOptions );
|
$this->assertCount( $enabled ? 3 : 2, $userOptions );
|
||||||
$this->assertSame( '1', $userOptions[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME ] );
|
$this->assertSame( '1', $userOptions[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME ] );
|
||||||
if ( $beta === false ) {
|
if ( $enabled ) {
|
||||||
$this->assertSame( '1', $userOptions[ PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME ] );
|
$this->assertSame( '1', $userOptions[ PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::onUserGetDefaultOptions
|
* @covers ::onUserGetDefaultOptions
|
||||||
* @dataProvider provideReferencePreviewsBetaFlag
|
* @dataProvider provideReferencePreviewsFlag
|
||||||
*/
|
*/
|
||||||
public function testOnLocalUserCreatedForNewlyCreatedUser( $beta ) {
|
public function testOnLocalUserCreatedForNewlyCreatedUser( bool $enabled ) {
|
||||||
$expectedState = '1';
|
$expectedState = '1';
|
||||||
|
|
||||||
$userMock = $this->createMock( User::class );
|
$userMock = $this->createMock( User::class );
|
||||||
|
|
||||||
$userOptionsManagerMock = $this->createMock( UserOptionsManager::class );
|
$userOptionsManagerMock = $this->createMock( UserOptionsManager::class );
|
||||||
$userOptionsManagerMock->expects( $this->exactly( 2 - $beta ) )
|
$userOptionsManagerMock->expects( $this->exactly( $enabled ? 2 : 1 ) )
|
||||||
->method( 'setOption' )
|
->method( 'setOption' )
|
||||||
->withConsecutive(
|
->withConsecutive(
|
||||||
[ $userMock, 'popups', $expectedState ],
|
[ $userMock, 'popups', $expectedState ],
|
||||||
|
@ -327,14 +335,13 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
|
||||||
|
|
||||||
$this->setMwGlobals( [
|
$this->setMwGlobals( [
|
||||||
'wgPopupsOptInStateForNewAccounts' => $expectedState,
|
'wgPopupsOptInStateForNewAccounts' => $expectedState,
|
||||||
'wgPopupsReferencePreviews' => true,
|
'wgPopupsReferencePreviews' => $enabled,
|
||||||
'wgPopupsReferencePreviewsBetaFeature' => $beta,
|
|
||||||
] );
|
] );
|
||||||
( new PopupsHooks( $userOptionsManagerMock ) )
|
( new PopupsHooks( $userOptionsManagerMock ) )
|
||||||
->onLocalUserCreated( $userMock, false );
|
->onLocalUserCreated( $userMock, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideReferencePreviewsBetaFlag() {
|
public static function provideReferencePreviewsFlag() {
|
||||||
return [
|
return [
|
||||||
[ false ],
|
[ false ],
|
||||||
[ true ],
|
[ true ],
|
||||||
|
|
|
@ -41,24 +41,6 @@ class PopupsPage extends Page {
|
||||||
await Util.waitForModuleState( POPUPS_MODULE_NAME );
|
await Util.waitForModuleState( POPUPS_MODULE_NAME );
|
||||||
}
|
}
|
||||||
|
|
||||||
async shouldUseReferencePopupsBetaFeature() {
|
|
||||||
await Util.waitForModuleState( 'mediawiki.base' );
|
|
||||||
await browser.execute( function () {
|
|
||||||
return mw.loader.using( 'mediawiki.api' ).then( function () {
|
|
||||||
return new mw.Api().saveOptions( {
|
|
||||||
// TODO: Remove the first option when all Beta code is gone
|
|
||||||
popupsreferencepreviews: '1',
|
|
||||||
'popups-reference-previews': '1'
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
async hasReferencePopupsEnabled() {
|
|
||||||
// TODO Remove or adjust when not in Beta any more
|
|
||||||
return browser.execute( () => mw.config.get( 'wgPopupsReferencePreviews' ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
async abandonLink() {
|
async abandonLink() {
|
||||||
return $( '#content h1' ).moveTo();
|
return $( '#content h1' ).moveTo();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const assert = require( 'assert' ),
|
const assert = require( 'assert' ),
|
||||||
page = require( '../pageobjects/popups.page' ),
|
page = require( '../pageobjects/popups.page' );
|
||||||
UserLoginPage = require( 'wdio-mediawiki/LoginPage' );
|
|
||||||
|
|
||||||
describe( 'Dwelling on a valid reference link', function () {
|
describe( 'Dwelling on a valid reference link', function () {
|
||||||
before( async function () {
|
before( async function () {
|
||||||
await page.setupReferencePreviews();
|
await page.setupReferencePreviews();
|
||||||
// TODO Remove or adjust when not in Beta any more
|
|
||||||
await UserLoginPage.loginAdmin();
|
|
||||||
await page.shouldUseReferencePopupsBetaFeature();
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
beforeEach( async function () {
|
beforeEach( async function () {
|
||||||
|
@ -18,9 +14,6 @@ describe( 'Dwelling on a valid reference link', function () {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
it( 'I should see a reference preview', async function () {
|
it( 'I should see a reference preview', async function () {
|
||||||
if ( !( await page.hasReferencePopupsEnabled() ) ) {
|
|
||||||
this.skip();
|
|
||||||
}
|
|
||||||
await page.dwellReferenceLink( 'cite_ref-1' );
|
await page.dwellReferenceLink( 'cite_ref-1' );
|
||||||
assert( await page.seeReferencePreview(), 'Reference preview is shown.' );
|
assert( await page.seeReferencePreview(), 'Reference preview is shown.' );
|
||||||
assert( !( await page.seeScrollableReferencePreview() ), 'Reference preview is not scrollable.' );
|
assert( !( await page.seeScrollableReferencePreview() ), 'Reference preview is not scrollable.' );
|
||||||
|
@ -28,9 +21,6 @@ describe( 'Dwelling on a valid reference link', function () {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
it( 'Abandoning link hides reference preview', async function () {
|
it( 'Abandoning link hides reference preview', async function () {
|
||||||
if ( !( await page.hasReferencePopupsEnabled() ) ) {
|
|
||||||
this.skip();
|
|
||||||
}
|
|
||||||
await page.dwellReferenceLink( 'cite_ref-1' );
|
await page.dwellReferenceLink( 'cite_ref-1' );
|
||||||
await page.abandonLink();
|
await page.abandonLink();
|
||||||
assert( await page.doNotSeeReferencePreview(), 'Reference preview is kept hidden.' );
|
assert( await page.doNotSeeReferencePreview(), 'Reference preview is kept hidden.' );
|
||||||
|
@ -38,18 +28,12 @@ describe( 'Dwelling on a valid reference link', function () {
|
||||||
|
|
||||||
// Skipped due to T341763
|
// Skipped due to T341763
|
||||||
it.skip( 'References with lots of text are scrollable and fades', async function () {
|
it.skip( 'References with lots of text are scrollable and fades', async function () {
|
||||||
if ( !( await page.hasReferencePopupsEnabled() ) ) {
|
|
||||||
this.skip();
|
|
||||||
}
|
|
||||||
await page.dwellReferenceLink( 'cite_ref-2' );
|
await page.dwellReferenceLink( 'cite_ref-2' );
|
||||||
assert( await page.seeScrollableReferencePreview(), 'Reference preview is scrollable' );
|
assert( await page.seeScrollableReferencePreview(), 'Reference preview is scrollable' );
|
||||||
assert( await page.seeFadeoutOnReferenceText(), 'Reference preview has a fading effect' );
|
assert( await page.seeFadeoutOnReferenceText(), 'Reference preview has a fading effect' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
it.skip( 'Dwelling references links inside reference previews does not close the popup ', async function () {
|
it.skip( 'Dwelling references links inside reference previews does not close the popup ', async function () {
|
||||||
if ( !( await page.hasReferencePopupsEnabled() ) ) {
|
|
||||||
this.skip();
|
|
||||||
}
|
|
||||||
await page.dwellReferenceLink( 'cite_ref-3' );
|
await page.dwellReferenceLink( 'cite_ref-3' );
|
||||||
await page.dwellReferenceInceptionLink();
|
await page.dwellReferenceInceptionLink();
|
||||||
assert( await page.seeReferenceInceptionPreview(), 'The reference preview is still showing.' );
|
assert( await page.seeReferenceInceptionPreview(), 'The reference preview is still showing.' );
|
||||||
|
|
|
@ -119,8 +119,8 @@ module.exports = ( env, argv ) => ( {
|
||||||
// Minified uncompressed size limits for chunks / assets and entrypoints. Keep these numbers
|
// Minified uncompressed size limits for chunks / assets and entrypoints. Keep these numbers
|
||||||
// up-to-date and rounded to the nearest 10th of a kibibyte so that code sizing costs are
|
// up-to-date and rounded to the nearest 10th of a kibibyte so that code sizing costs are
|
||||||
// well understood. Related to bundlesize minified, gzipped compressed file size tests.
|
// well understood. Related to bundlesize minified, gzipped compressed file size tests.
|
||||||
maxAssetSize: 47.1 * 1024,
|
maxAssetSize: 46.8 * 1024,
|
||||||
maxEntrypointSize: 47.1 * 1024,
|
maxEntrypointSize: 46.8 * 1024,
|
||||||
|
|
||||||
// The default filter excludes map files but we rename ours.
|
// The default filter excludes map files but we rename ours.
|
||||||
assetFilter: ( filename ) => !filename.endsWith( srcMapExt )
|
assetFilter: ( filename ) => !filename.endsWith( srcMapExt )
|
||||||
|
|
Loading…
Reference in a new issue