Commit graph

150 commits

Author SHA1 Message Date
WMDE-Fisch 14aff8189c Remove obsolete ReferenceTooltips gadget checks
The checks are part of the Cite extension now and have no relevance
for page previews. The config is also obsolete by now due to the
copy in Cite and a mapping in mediawiki-config.

See Ie6e8bc706235724494036c7f0d873f5c996c46e6 and
Ia028c41f8aaa1c522dfc7c372e1ce51e40933a5e for reference.

Bug: T362771
Change-Id: I51311a099b21c3c1af39bbfbde1d2c2044958421
2024-10-07 20:03:03 +02:00
Jon Robson fef3740fa5 Clean up preferences code
- Reference preview preferences should be defined inside Cite
- Don't use constants for seldom used strings to make the code
more readable.
- The lightweght ext.popups module is now always sent to the user
This was a micro-optimization and not necessary to do

Bug: T365538
Depends-On: Ic479c0a381ee16d1abcecfdd5ee48f0afccc1d3f
Change-Id: Ie8fa1672b9fdbb1c6b840dde5c9060a20a625adb
2024-09-20 19:06:38 +00:00
Adam Wight 7a79602208 [cleanup] Remove unused configuration $wgPopupsReferencePreviews
This configuration is always enabled, so remaining conditions are dead
code.  Removing the flag in this code base simplifies moving the
remaining Reference Previews settings in a later patch.

Bug: T363162
Change-Id: I2b952f4203b6ffa040daad2aa288eb53d2ffd3b2
2024-09-05 20:26:31 +00:00
jenkins-bot a5ab05be4e Merge "Directly access the properties with non-static functions" 2024-07-21 09:38:02 +00:00
Fomafix 7e3a444a99 Use service 'GadgetsRepo' instead of deprecated GadgetRepo::singleton()
The service is optional to support with and without extension Gadgets.

Change-Id: I41d1516e185ceb5c49b38361360a3adad1a333de
2024-07-03 07:19:28 +00:00
Fomafix 1413279c26 Directly access the properties with non-static functions
Change-Id: Id9dbb20f39695f5d75839a2ae14003c6dde9c21e
2024-06-29 19:20:27 +00:00
jenkins-bot 058c772d52 Merge "Restore the original behaviour of Reference Previews" 2024-06-24 07:07:44 +00:00
Umherirrender 12a86a9e49 Use namespaced classes
Change-Id: Iaa28a15e8bc1ea29e302aa2180dec0bf67f5817e
2024-06-09 19:14:49 +02:00
Func ff30b0bc2b Restore the original behaviour of Reference Previews
Commit a75ddc41 and 33f9e9d3 effectively changed the default user
option value of popups-reference-previews for users created before
2017/08/16 without any justification.

Please see the task description for full analysis.

This partially reverts commit a75ddc41.

Bug: T366419
Change-Id: I68d6114384af6d259dbc4541522d52ae9a289e49
2024-06-08 04:26:40 +08:00
Moh'd Khier Abualruz a75ddc4173 feature(Popups): Conditional User Defaults Implementation
Implement conditional defaults for user preferences in the Popups
component.
This patch aims to simplify the preference management system by
leveraging conditional logic directly within the component rather
than relying on multiple hooks

Changes:
- Updated `extension.json` to reflect the removal of outdated hooks.
- Updated `extension.json` to reflect the conditional user defaults.
- Removed unused user option `popupsreferencepreviews` from
 `extension.json`
- Modified `PopupsHooks` to streamline the preferences management,
 and depend on conditional user defaults, and removing `onUserGetDefaultOptions` and `onLocalUserCreated` hooks.
- Removed unneeded test cases in `PopupsHooksTest`.

Bug: T364347
Change-Id: Iae454e4b4704a0289ca0a2b0794730562fda0dd1
2024-05-28 21:05:57 +00:00
jenkins-bot d8e4500700 Merge "Improve PHP code" 2024-04-16 16:23:40 +00:00
Fomafix 07888b12b2 Improve PHP code
* Remove lost comment.
* Improve order of calls.

Change-Id: I83a63dd08cd9b355afbfff4361ba2dfcc19c8a0c
2024-04-16 08:35:08 +00:00
Adam Wight da29c0299b Remove deprecated copy of referencePreviews module
This has been provided by the Cite extension since I0dc47abb59a4 .

Bug: T362332
Change-Id: Ic2594d0638685326fd08198c691e18371e132ffc
2024-04-15 10:44:48 +02:00
Fomafix 61c539d205 Get ResourceLoader from Context
Change-Id: I439266105ef18612da50a3d306b04a835c648eae
2024-03-23 08:38:13 +00:00
Fomafix 1ce8b38f9f Inject 'Popups.Logger' into PopupsHooks
The function PopupsContext::getLogger is not needed anymore.

Change-Id: Ib538372f1480d282857d827fedbe0ebe9abc0685
2024-03-19 20:26:53 +00:00
Fomafix a523b79232 Inject Popups services into PopupsHooks
Change-Id: I16ebb2aff9afab0449e3cc4b58a7ac6b3ed9870a
2024-03-19 20:10:36 +00:00
Umherirrender 407a1011e9 build: Upgrade mediawiki/mediawiki-codesniffer to v43.0.0
Change-Id: I6b1cae8b9cc7a99e839e86f2db3f8d9e9b3ee546
2024-03-11 20:43:15 +01:00
Jon Robson e9ac5dcf47 Allow Cite to define the reference preview module instead
This provides backwards compatibility with Cite, if Cite has register
its own preview module for reference tooltips.

Bug: T355194
Change-Id: Iec6f3d4d6c5f765c151ae0dbba258049530e6bc0
2024-02-02 10:59:04 -08:00
Umherirrender f5dd9a0bbf Add return type hint to functions in ServiceWiring.php
This is a common pattern for service wiring functions

Change-Id: I2c6a6b95ad5f9d69f90631ede39882e41e7c85df
2024-02-01 19:18:16 +01:00
Jon Robson 59c6b8e88f Reference previews should use Popups registration
* Adds a new webpack entry point for references previews
* Reference related code in src/index.js is moved to new
file resources/ext.popups.referencePreviews/index.js

The changes:
* References previews now in its own module ext.popups.referencePreviews
* Loaded via getCustomPopupTypes
* OWNERS.md files make clear which team owns which part of the code.

Bug: T326692
Change-Id: Iea8a5b9221c0b1fd41e40bff2cbe01e42124d53f
2024-01-16 11:38:08 +01:00
Umherirrender f3c4642fd5 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: Ib30da35841aadb558709dbbe6e30be2241048c87
2024-01-05 22:41:45 +01:00
Jon Robson 5abc2eed4c Cleanup: Remove non-functional hook
This doesn't work and Popups is not part of the
MediaWiki Language Extension Bundle

Change-Id: I66166ba964fba3a9ece865b701a95b66a924b9b6
2023-11-29 23:40:25 +00:00
jenkins-bot ea42009239 Merge "Update UserOptionsLookup's FQN" 2023-11-29 17:14:37 +00:00
gerritbot 96cea43fe1 Update UserOptionsManager's FQN
User-options related classes are being moved to
the MediaWiki\User\Options namespace in MediaWiki Core;
reflect that change here.

Bug: T352284
Depends-On: I9822eb1553870b876d0b8a927e4e86c27d83bd52
Change-Id: Icb39d3f73e120fd0d9dad5ae362787cd19d47bfb
2023-11-29 12:55:13 +00:00
gerritbot 031ace2dba Update UserOptionsLookup's FQN
User-options related classes are being moved to the MediaWiki\User\Options namespace in MediaWiki Core; reflect that change here.

Bug: T352284
Depends-On: I9822eb1553870b876d0b8a927e4e86c27d83bd52
Change-Id: I0c66220b0ba9501e8ef20a172d21d7e75a19d6cc
2023-11-29 12:39:47 +00:00
WMDE-Fisch b218a77ca4 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
2023-11-24 13:07:46 +01:00
thiemowmde 7596165a5d Fix confusing constant names in PHP
The …AFTER_BETA constant is the one we want to keep after we removed
all BetaFeature code. The naming scheme is just confusing.

Safe to rename. Not used anywhere else:
https://codesearch.wmcloud.org/search/?q=REFERENCE_PREVIEWS_PREFERENCE_NAME

We also decided to keep the $wgPopupsReferencePreviews feature flag.
Update the documentation accordingly.

This is split from I1556b2f to make it easier to review.

Bug: T351708
Change-Id: Ifbb41156f2a5a4d8a81e79f613754869c5c89690
2023-11-24 12:51:41 +01:00
gerritbot 2da869fa58 Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: Ia3b739ceacc035d64ec6d13de9d3e6de102dbb20
2023-08-19 12:22:49 +00:00
bwang 6b659443b5 Update popups to use codex buttons over mediawiki.ui.buttons
- Provides missing accessible label for the settings button

Bug: T340256
Change-Id: I86972322ae34f1d1df8d79c66daa9e34091f9dd3
2023-07-10 16:03:36 -05:00
AnaïsGueyte 1f5510bc2a Prevent Enabling Beta Preferences for temp users
Bug: T337776
Change-Id: I3e7c9524a405d62796dca42abe3d04fa5025dc81
2023-06-08 11:39:48 -02:30
Fomafix 76e2339cec Inject service UserOptionsManager in Hooks
Change-Id: I690699210c041f950a076904b863bc014833e5ad
2022-12-15 22:13:23 +00:00
jenkins-bot 94c251583e Merge "Extensible previews" 2022-12-02 17:02:04 +00:00
Jon Robson 0febc3f54d Extensible previews
Allow extensions to register new types of previews via
extension attributes.

Changes:

- The check for reference previews doesn't make sense
as $('a[ href*="#" ]' ) will match any elements with a hash
fragment, so the additional check to Title.getFragment
will not provide a different result. This was introduced in
I9ec57e0fbb0d21beaaa7b359c1c2bef64d2c14f5
- Links that point to themselves are marked with mw-selflink
in MediaWiki so this can use the not selector we already have.
- The new API is used internally and only available via extension
Attributes
- An example is provided in SkinJSON
(https://github.com/jdlrobson/mediawiki-skins-skinjson/pull/14)

Bug: T233099
Change-Id: Iefe98c1f0422dbf034e385b1a41a859d030a2cf4
2022-11-22 08:45:27 -08:00
Fomafix 56d8a8df55 Inject service SpecialPageFactory
Change-Id: Ia38b468741bdfd5bab5bb34df79bf01d549498a9
2022-11-05 09:28:08 +00:00
Fomafix 4874172242 Use short array destructuring instead of list()
Introduced in PHP 7.1. Because it's shorter and looks nice.

Change-Id: I68273c79e8d15ef7b69e2642087e425d8bf0dfa6
2022-11-05 09:08:33 +00:00
Reedy b6eb2627ff Use namespaced GadgetRepo
Change-Id: Ibaa24dc0bf02b0d1cbe4e66a8a4efc47896d0fb9
2022-03-06 01:33:08 +00:00
Fomafix cfa0f5419b Use HookHandlers and implement hook interfaces
This change requires MediaWiki 1.35+.

Bug: T263353
Change-Id: I4d3aa20c666799e6e693a6a4b7a3e835303e2fc5
2021-12-20 11:05:19 +00:00
Reedy 498f02e9bb Use namespaced BetaFeatures class
Depends-On: Ia0304f06788de9ac7fd46bd03292f52af70c3f2f
Change-Id: Id7e52ab2643d15e943d85c668647b3d73595c9de
2021-10-01 06:35:09 +00:00
Sam Smith 8f5000f346 Remove Popups instrumentation
Bug: T267211
Change-Id: I640ab367cd235ab8da7dd70dbef7ae9076712e84
2021-07-29 17:01:01 +00:00
Alexander Vorwerk 35462639c3 Avoid using User::getBoolOption()
User::getBoolOption() is deprecated and should be replaced with
UserOptionsLookup::getBoolOption()

Bug: T277600
Change-Id: I9a2118a6342bd5f145174428dcfb518cba4e439b
2021-06-06 16:44:20 +02:00
jenkins-bot 26ae1842c1 Merge "Avoid using User::setOption()" 2021-06-03 20:04:41 +00:00
anjali041 81bb920e2b Avoid using User::setOption()
User::setOption() is deprecated and should be replaced with UserOptionsManager::setOption()

Bug: T277818
Change-Id: I5698b4422755a921c9c9c01ce29084ebfe5f5385
2021-06-02 12:21:10 +00:00
jenkins-bot b84f12e76a Merge "Rearrange PopupContext code for readability" 2021-05-22 07:10:52 +00:00
Umherirrender 0f087ce5e9 build: Updating composer dependencies
* php-parallel-lint/php-parallel-lint: 1.0.0 → 1.3.0
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* mediawiki/minus-x: 1.1.0 → 1.1.1

Libup is broken on the build steps due to different node versions

Change-Id: I28aefe77365b9812f9cc0f9e5177f45e9f5c2cc2
2021-05-19 19:38:42 +02:00
Thiemo Kreuz 7c3f369019 Rearrange PopupContext code for readability
For example:
* Anonymous users are a critical exception. They must always
  load the module.
* Otherwise check if one preview type is active.
* Prefer isRegistered() over isAnon(), because isRegistered()
  is part of the UserIdentity interface.

Change-Id: Iea7e3bb7ef01bd72ccbd1fc5e574437f6dc42aa2
2021-05-06 16:44:41 +02:00
jenkins-bot e9fac7bcc5 Merge "Enable ReferencePreviews for old users by default" 2021-05-05 15:54:15 +00:00
Andrew Kostka 1fce62ca7b Enable reference previews for anonymous users when not in beta
Change-Id: I605bc79626999c2e65cdceaa47dd6c4479a3d249
2021-05-05 16:43:25 +02:00
Thiemo Kreuz 5b6ed0e580 Enable ReferencePreviews for old users by default
The behavior for PagePreviews – implemented years ago – was
different. For old users it was disabled by default. This
behavior is wrong for ReferencePreviews.

Bug: T271206
Change-Id: I28c43ab3348ffdc27b068fc1ac1d6a6a06ee90a6
2021-05-05 14:32:15 +02:00
Thiemo Kreuz 3a00223a36 Separate reference preview settings in beta & non-beta
This is the smallest possible patch for a backport.

While it seems there is zero technical reason to limit user
option keys to lowercase with dashes, it's best-practice.
Same as message keys.

Bug: T281235
Change-Id: Ia4a45cf4459543c81b23b757ae9c2cfaf9676894
2021-04-27 16:15:17 +02:00
Thiemo Kreuz c281bb9302 Clean up code enabling individual popup types
We still have 2 different mechanisms in place, maybe even 3:
* We simplify the CSS selector when we know a popup type is
  disabled, and it's impossible an anonymous user can enable it
  at run-time.
* We create that "initiallyEnabled" map that allows anonymous
  users to toggle the individual popup types at run-time.
* This map is also used to check if the footer link should be
  shown.
* There is also a wgPopupsReferencePreviews global that acts as
  a "kill switch". However, this is not a pure feature flag,
  but incorporates the user setting for registered users. This
  is currently partly redundant (checking
  `mw.user.options.get( 'popupsreferencepreviews' )` does the
  same) and can be removed later when the feature flag is not
  needed any more.

The footer link currently acts odd because anonymous users are
unable to enable ReferencePreviews, but get the footer link.

This patch introduces a 3-state model:
* `true` acts as before.
* `false` means a popup type is disabled, but anonymous users
  can enable it (i.e. this is the opt-out behavior for anonymous
  users).
* `null` means a popup type is not available at run-time, for
  nobody. Anonymous users can't do anything about this.
  Registered users must leave the page and change a setting.

Bug: T277640
Change-Id: Id8d1396c09cf0f706034a66f9cd3c880a8b33df8
2021-04-21 19:38:25 +02:00