Commit graph

3026 commits

Author SHA1 Message Date
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 51059828bf Do not search for elements if no previews have been registered
The findNearestEligibleTarget method is now being called with an
empty array and thus an empty string as a selector

Follow up to
I5f293a134521f086c9f62babb9d06cd9c51d7d47

Bug: T355933
Bug: T356186
Bug: T356193
Change-Id: I3af44ae65d5097fc44744838a4edb07552568b17
2024-01-30 16:42:14 +00:00
Jon Robson 8e4996485f Add new @stable event.Popups.SettingChange event
Extensions may want to log metrics relating to settings being enabled
or disabled. This is currently the case with reference previews.

This is a follow up to
I1c434f0098ae23bd62256686a658e3d5ef7f70b9

Additional change: Add FIXME clarifying migrateOldPreferences is temporary
and setting a date it can be removed.

Bug: T353798
Change-Id: If9bac123d731e7da7429ba3a0ea92e80263df6a6
2024-01-29 14:42:11 -08:00
jenkins-bot 8fc7222b26 Merge "Don't bail out early when there are no selectors configured" 2024-01-29 22:28:22 +00:00
Translation updater bot dd0b924cb8 Localisation updates from https://translatewiki.net.
Change-Id: I1b306f378fa69fd87dd3d2a2529f466d5d4bc8e0
2024-01-28 16:07:51 +01:00
WMDE-Fisch bf10902f23 Don't bail out early when there are no selectors configured
It seems to me, that at this point 3rd parties might not have been
loaded that want to add custom preview types. So the list of
selectors is empty.

We still might want to initialze though for 3rd parties that load
later.

Bug: T355933
Change-Id: I5f293a134521f086c9f62babb9d06cd9c51d7d47
2024-01-26 12:38:47 +01:00
WMDE-Fisch 694b96a19f Set a global when reference previews are visible.
Used for tracking baseline stats in the Cite extension.

Also fixed the wireing of the Reference Preview type constant so
that the settings can be tracked. Not sure where this should go
best in the new code.

Bug: T353798
Change-Id: I1c434f0098ae23bd62256686a658e3d5ef7f70b9
2024-01-17 16:19:09 -08:00
WMDE-Fisch e15e2c4d14 Increase test coverage
More of a random thing done to increase the coverage a bit because
there are upcomming features that seem to be hard to test.

- Found one test case in reference previews that was configured
  wrongly

- Adding some sanity checks to the settingsDialogRender test

Change-Id: I95d3c6f30388b2dcc76b018d5dc0f958d06aad91
2024-01-16 10:44:53 +00:00
Jon Robson 381f8f5f7d Reduce bundlesize of reference previews by making it use stable APIs
This is a precursor to moving the code out to the Cite extension.

This can be squashed into parent commit or merged at same time.

I've kept the two patches separate to make them easier to review.

Bug: T326692
Change-Id: I50dbf28a1078df6c73fd0fbf77480488dd82c7b3
2024-01-16 11:44:07 +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
Volker E 31ef381e90 build: Update 'svgo' to latest v3.2.0 and re-minify SVGs
The latest update of 'svgo' dependency includes three optimizations on
converting path commands, which
- improves closing paths and how we determine if to use absolute or
  relative commands.
- round arc or convert to lines based on the geometric sagitta
- convert cubic Bézier curves to quadratic Bézier curves where possible

Bug: T354875
Change-Id: Ibd611396c48ff6f971ee251b59f13e350e0f812f
2024-01-16 00:13:08 +01:00
James D. Forrester 2ef5278784 extension.json: Drop 'es6' flag, always true since MediaWiki 1.41
Change-Id: I6f8b1ce80138a98037ac245b2dc551c5e9167349
2024-01-12 19:04:39 -05:00
WMDE-Fisch a3f3cf9e3f build: Update eslint 0.26.0 and apply fixes
Mainly auto fixes but also getting rid of some straight forward lint
warnings to reduce the wall of issues a bit when running the tests.

Also removing some rule exceptions that seem to got more relaxed
upstream.

Change-Id: Icb4d73374583675be74517e6df6508314d61e8c2
2024-01-12 13:50:19 -05:00
James D. Forrester 863c442c32 .nvmrc: Update now we're using Node 18, and make CI pass
* Babel upgraded to a version that works with new Node's OpenSSL.
* Various loaders upgraded to match
* Babel config changed as plugin-proposal-private-property-in-object is now official
* Webpack config updated as noEmitOnErrors was renamed to not be a negation
* Webpack config updated as namedModules was renamed to the wider moduleIds
* Ignore the built Webpack output from eslint

Bug: T354943
Change-Id: I449f601b8218925d96bfb423fc0f349214d08385
2024-01-12 13:50:19 -05:00
jenkins-bot 93d9c88c26 Merge "Generalize settings code (attempt 2)" 2024-01-10 11:36:38 +00:00
Translation updater bot 9bde69f9bd Localisation updates from https://translatewiki.net.
Change-Id: Ibb5261f6dbbf03acb5a7b598e46a4a829d746d58
2024-01-10 08:33:17 +01:00
Jon Robson 2c09fd1d1c Generalize settings code (attempt 2)
This reverts commit a6a65204c6.
to restore custom preview types.

-- Changes since revert
The previous patch accidentally removed the syncUserSettings
changeListener. This has now been restored with several modifications:
* We have a migrate script which rewrites existing localStorage settings
to the new system
* The existing save functions are generalized.

The changes since this patch are captured in
Ia73467799a9b535f7a3cf7268727c9fab7af0d7e

-- More information

A new REGISTER_SETTING action replaces the BOOT action for
registering settings. This allows custom preview types to be
associated with a setting. They do this by adding the enabled
property to the module they provide to mw.popups.register

Every time the new action is called, we refresh the settings
dialog UI with the new settings.

Previously the settings dialog was hardcoded, but now it is generated
from the registered preview types by deriving associated messages
and checking they exist, so by default custom types will not show
up in the settings.

Benefits:
* This change empowers us to add a setting for Math previews to allow
them to be enabled or disabled.
* Allows us to separate references as its own module

Additional notes:
* The syncUserSettings.js changeListener is no longer needed as the logic
for this is handled inside the "userSettings" change listener in response to
the "settings" reducer which is responding to
SETTINGS_CHANGE and REGISTER_SETTING actions.

Upon merging:
* https://www.mediawiki.org/wiki/Extension:Popups#Extensibility will be
updated to detail how a setting can be registered.

Bug: T334261
Bug: T326692

Change-Id: Ie17d622870511ac9730fc9fa525698fc3aa0d5b6
2024-01-09 17:24:09 -08:00
James D. Forrester e74d335904 .browerslistrc: Update reference to upstream
Change-Id: I4d0ef1cc0b543a9ba85d9972efcb9d6ee7aa5c67
2024-01-09 10:44:18 -05:00
Translation updater bot a529de8140 Localisation updates from https://translatewiki.net.
Change-Id: I9253cee6cfda89ba84f48bcc60da89c380d7c87e
2024-01-08 11:31:34 +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
Translation updater bot 4a2238e460 Localisation updates from https://translatewiki.net.
Change-Id: Ifd554386ba214135fc615803c23031da8f8ea2ab
2023-12-26 14:43:25 +01:00
Translation updater bot a6b7122003 Localisation updates from https://translatewiki.net.
Change-Id: I2dbf7774d25246a8c05eb72fc260c306b94033c3
2023-12-18 18:18:42 +01:00
Translation updater bot 2e6e6d778c Localisation updates from https://translatewiki.net.
Change-Id: I20868e08439bae7742dac06075a8e1d2f2394034
2023-12-11 10:43:46 +01:00
Translation updater bot 177f00bf2f Localisation updates from https://translatewiki.net.
Change-Id: I59b63195cc36ab89343a1b7bb2121971762c3d13
2023-12-07 10:02:56 +01:00
jenkins-bot 029992b971 Merge "Localisation updates from https://translatewiki.net." 2023-12-04 08:43:29 +00:00
Translation updater bot 4a93494046 Localisation updates from https://translatewiki.net.
Change-Id: I044247650db551310647940102d4e7b34176ee1b
2023-12-04 09:05:30 +01:00
Fomafix a333160955 Use namespaced ResourceLoader classes
The old class names are deprecated since 1.39.

Change-Id: I8a317a9fdb4ee0208e55e364e3e8c3817419d5b1
2023-12-03 19:56:28 +00:00
jenkins-bot cdfd8d2f37 Merge "Cleanup: Remove non-functional hook" 2023-12-01 17:06:11 +00:00
jenkins-bot cdede23c59 Merge "Update tests for PHPUnit 9.6" 2023-11-30 23:08:24 +00:00
Ed Sanders c0bf30fb58 Documentation fixes
* Element -> HTMLElement
* JQuery -> jQuery
* Remove `return {void}`

Change-Id: I887dfe98af77358ad4ef4e1c835ccf45c2c64400
2023-11-30 10:38:07 +00: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 6d642c38bd Merge "eslint: Enforce no-use-before-define" 2023-11-29 17:38:23 +00:00
jenkins-bot ea42009239 Merge "Update UserOptionsLookup's FQN" 2023-11-29 17:14:37 +00:00
Ed Sanders 2aadb01365 eslint: Enforce no-use-before-define
Only one issue to fix now that we don't error on functions.

Change-Id: Idaee60507557b2a73deaf03d93829b9dade5c1f0
2023-11-29 14:13:12 +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
Translation updater bot 65d5156e75 Localisation updates from https://translatewiki.net.
Change-Id: Ia0da83b099485cbf565a9ce1bf10715ac5af505a
2023-11-27 08:33:04 +01:00
Daimona Eaytoy d77b6e9992 Update tests for PHPUnit 9.6
- Avoid withConsecutive()

Bug: T342110
Change-Id: I3f07a2f071ddec3f9bbd147b8bfc0d32277203d6
2023-11-27 03:13:29 +01: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
Translation updater bot 0018e71804 Localisation updates from https://translatewiki.net.
Change-Id: Ia332c673e1362a1741db7fb5acc5e868a5b8c189
2023-11-22 08:20:29 +01:00
Translation updater bot b29fa65c83 Localisation updates from https://translatewiki.net.
Change-Id: Iaf76660a2e07eaa0bb824f4b4e0adf119f0f51d4
2023-11-21 08:29:42 +01:00
Translation updater bot d628a2a27f Localisation updates from https://translatewiki.net.
Change-Id: Ib8304901106e589f47afdac52e74e74dd2d8f85b
2023-11-20 08:52:04 +01:00
Translation updater bot 22b3e7e8e0 Localisation updates from https://translatewiki.net.
Change-Id: Ib273b5fadd4622974f98e42e10bb293573aca1f3
2023-11-16 09:09:51 +01:00
Translation updater bot 105288a0da Localisation updates from https://translatewiki.net.
Change-Id: Iebc9394150c97557d9e23c4741879fef22afc964
2023-11-15 15:44:01 +01:00
Translation updater bot 5f9430137b Localisation updates from https://translatewiki.net.
Change-Id: I8cf5a8e97109bcbba1dc3fb7c8ff1b01ada4e411
2023-11-13 08:42:07 +01:00
Jon Robson 31e416ba68 Allow disambiguation previews to render when no summary found
This allows preview types to override the default behaviour
which prohibits previews from rendering when the API finds no
extract. In the case of disambiguation pages the summary is not
required to render a preview.

Bug: T346686
Change-Id: Ifb8bbef943b02dfa971e2af96511ac708733bdd1
2023-11-09 13:02:51 -08:00
Ed Sanders bf3600f20a Convert nycrc from JSON to JS to allow comments
Change-Id: Ib3c3b8b2f5f87b5f00dcf8b718a0d1bf07948c56
2023-11-09 11:36:11 +00:00
Ed Sanders 461f949823 build: Update linters
Also restructure eslint config so that
* root files are linted with server rules
* src and tests share config

Change-Id: Ie4d0731ba9670af7f3e60cdfe3c4e331386b17c6
2023-11-09 11:36:08 +00:00
Translation updater bot 8cd688cb70 Localisation updates from https://translatewiki.net.
Change-Id: I3107389e206ae786a8e1abba9d6e030e51f37e3a
2023-11-06 08:57:18 +01:00