Commit graph

1000 commits

Author SHA1 Message Date
Jon Robson 7a9e8fd622 Stop using deprecated mediawiki.Uri module
Use native URI instead.

Bug: T380079
Change-Id: I7648562c0262076f6dc06f619ef39c106ea7b30f
2024-11-21 10:12:48 -08:00
jenkins-bot a5c01f6813 Merge "eslint: Enforce no-var" 2024-10-15 19:13:04 +00:00
Erik Bernhardson a3af7c91b5 Record canonical special page names in virtual pageviews
When analyzing event data special pages are a bit unique. They
are the same across all wikis, but the name is typically
localized to the wiki itself. The localization is relatively
constant, but can change in ways that the canonical special page
names do not. Simplify analyzing virtualpageviews from special
pages by recording the canonical name of the page, rather than
the localized name.

Changes the VirtualPageViews event submission to provide
wgCanonicalSpecialPageName when appropriate.

Bug: T375387
Change-Id: Ia344d8d60058082fdf0715281d732e5c1f90a38a
2024-09-30 12:18:53 -07:00
Ed Sanders 0fd18bb233 eslint: Enforce no-var
Change-Id: I9853fde20dcd316d43f28b906bc501ca6329d138
2024-09-26 13:55:46 +01:00
Bartosz Dziewoński 4ff08bd2fb instrumentation: Avoid user.sessionId() if possible, since it sets a cookie
Bug: T289780
Change-Id: I8d80f4e02c6b59087c88d42be671fa81b4d37ba8
2024-07-13 01:58:43 +02:00
Bartosz Dziewoński 0a3665e5f0 actions: Remove unused sessionToken: user.sessionId()
Follow-up to 8f5000f346.

Bug: T289780
Change-Id: Id01b1901428dada420296cd599058092834143a9
2024-07-13 01:36:07 +02:00
jenkins-bot b413501ab3 Merge "jsdoc: Restrict Popups documentation to public facing APIs" 2024-07-01 15:52:17 +00:00
Jon Robson 9aed7b95ee jsdoc: Restrict Popups documentation to public facing APIs
Most of page previews is private, and developers should rely
on text editors to explore the codebase.

For public documentation we only surface what is a stable API
for page previews.

Change-Id: I8536de1de3038de43e5108f7d877df2ba3a2175b
2024-06-28 12:04:48 -07:00
Jon Robson 79211c23ac Make generic preview icon display in night mode
Remove the ext.popups.images module, replacing it with
references to the SVG image.

- The footer image is the same in dark and light mode so use
background image
- Use mask image for sad face to make it work correctly in dark mode.
- Rely on CSS Janus for the ltr to rtl swap out

Change-Id: Idf041730549b834126d9631ac95611526ae5daa3
2024-06-14 00:55:53 +00:00
Ed Sanders 9b8b402cb1 Update jsdoc to 4 and use jsdoc-wmf-theme
Change-Id: Idb33efa5b714826550917397d4de1f2e5087f1bd
2024-04-29 19:17:17 +01:00
Ed Sanders b2904e36da Explicity disable popups on DiscussionTools' timestamp links
It currently doesn't trigger because the links lack a
title attribute, but if one were to be added the tool
would trigger as, although timestamp links are just hash
fragment links, we also include the canonical path
before the hash.

Change-Id: I156b1401f5173ba1727861adf1efa136b96d330f
2024-04-28 08:09:31 +01: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
Ed Sanders d4b0d10b13 Account for scroll offset when using non-mouse positioning
offsetTop includes the scroll offset, so when using it to
calculate clientTop (position relative to the viewport),
we need to substract that offset.

clientY comes from mouse events and is already relative
to the viewport so needs no adjustment.

Bug: T270215
Change-Id: I545b14059f416678fc0d35413a76334e57bfc495
2024-03-21 13:35:13 +00:00
Jon Robson 7172aae082 Reference previews should no longer use Webpack
As a precursor to moving this code to the Cite extension move it off
of webpack and switch to using require rather than import

Bug: T355194
Change-Id: Ib6486ad38b79a3b67a9744b716b1a2f5d3779795
2024-02-02 10:52:30 -08: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
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
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
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
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
Ed Sanders c0bf30fb58 Documentation fixes
* Element -> HTMLElement
* JQuery -> jQuery
* Remove `return {void}`

Change-Id: I887dfe98af77358ad4ef4e1c835ccf45c2c64400
2023-11-30 10:38:07 +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
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
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
Jdlrobson 46d9c97180 Removing mw.ui.checkbox dependency (take 2)
This reverts commit af90386c67.

Reason for revert: The codex-styles module is now only loaded when
the settings cog is clicked.

Bug: T348069
Change-Id: I1d3c3a7b5c74c3e2d64765274468e48c014a4047
2023-10-27 16:46:40 -07:00
Jdlrobson af90386c67 Revert "Removing mw.ui.checkbox dependency"
This reverts commit 85d9a7b0ed.

Reason for revert: Unexpected visual change flagged by Pixel.
We're now loading BOTH codex search and Codex
styles on page load (the latter via JavaScript). This results in
a visual regression in the sidebar as the message box for
languages switches from MediaWiki UI to Codex. I am not 100% sure
what the right approach is here, but we should pause to assess
given this new learning.

Possible options
1) Add checkbox styles to codex-search bundle
2) Load codex-styles on page load instead of codex-search
3) Delay the loading of the codex-styles until the overlay is
rendering
4) Wait until Codex has code splitting.

Change-Id: I633364fea54b048492c6bde10b4c4cc8ab99b9ae
2023-10-27 21:59:46 +00:00
Jan Drewniak 85d9a7b0ed Removing mw.ui.checkbox dependency
wRemoves deprecated mw.ui.checkbox dependency
in favour of the `codex-styles` module.

Replaced checkbox markup in setting dialog accordingly.

Bug: T348069
Change-Id: I456a1c35cfc16703648c849917157258df67b224
2023-10-25 15:08:36 -04:00
Jon Robson a6a65204c6 Revert "Generalize settings code"
This reverts commit 6924a89b07.

Reason for revert: Breaks persistence of setting
for anonymous users.

Change-Id: I3efc20f44281c1c68c4162584388e33bb38c4848
2023-10-19 14:13:15 -07:00
jwbth f504232535 Update excluded selector to its current name in OOUI
OO.ui.ButtonedElement has been renamed to OO.ui.ButtonElement 9 years
ago in I1abecd8aaf694799e4e46acb07afbdfb458a4882 together with its
classes. This change updates the class name in the list of selectors
that don't trigger a popup (EXCLUDED_LINK_SELECTORS) to its current
name.

Bug: T348893
Change-Id: I9b93ce62e0664ba06a14d71477afc0be4fae2fd4
2023-10-19 13:43:49 -07:00
Jon Robson 6924a89b07 Generalize settings code
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: Ie11057052fb9035944f2b79a17fb486f97102994
2023-10-17 15:08:15 +00:00
Jon Robson 614039b7df mw.popups.isEnabled should always return boolean
Mismatch between documentation and function signature

Bug: T346106
Change-Id: I43e0efc67b76496aab228b3f971db795662337cf
2023-10-16 10:44:43 -07:00
WMDE-Fisch 90a829179c Better support RTL direction extracts in ReferencePreviews
When the user sets a different language than the projects content
language, ReferencePreviews were rendered LTR. By using the bdi
tag this behavior is fixed.

Note that PagePreviews gets language and direction from the
TextExtracts response and use them to achive the same. The latter
is not straight forward available for ReferencePreviews so I'm
using bdi to achieve the same.

Bug: T345833
Change-Id: I6554e6e1db3aac06c04c9185500e05de238adde2
2023-10-04 15:28:00 +02:00
Jon Robson 6d0cdc9e45 Disable error logging
The rate is unexpected:  over 5 million in the last 7 days
I don't time to investigate this further so suggest disabling this
for now.

Change-Id: Ie55d1da1652239ad4f6ea94743d6efdd12de9974
2023-09-27 08:47:35 -07:00
WMDE-Fisch 26c0e592a5 Disable reference previews when the navigation popups gadget is used
Otherwise we will have two popups for references when hovering.

Bug: T347391
Change-Id: I8332e9fe6e214b2bd3491adb2bedcae2870f34c7
2023-09-26 14:44:05 +02:00
Jon Robson 961778b3c5 Disable error logging for missing settings cog on references beta feature
Bug: T346404
Change-Id: I36b1759f6d00ff6ce584a1bc1ac68dedd633fc6a
2023-09-15 09:49:30 -07:00
bwang 154912e5db Rename icon classes in Popups to use popups-icon prefix instead of mw-ui-icon, replace resource loader icons with codex
Bug: T345653
Change-Id: I19b9861850064df50d6b88cda748feff6231091c
2023-09-12 10:56:53 -05:00
thiemowmde 8c5120c2a6 Fix settings button not working on reference previews
Apparently caused by a mistake in I8697232, and the QA for T340256 not
covering the full functionality of what was changed in the patch.

Bug: T345829
Change-Id: I482d32183ef7f2226c7ad114be0fbaf97bc7b898
2023-09-08 23:45:29 +00:00
bwang b78cfe50c9 Replace mediawiki.ui.icon with Codex, update preview markup and styles to be more consistent
- Removes .mw-ui-icon and .mw-ui-icon-element
- Aligns markup/styles between generic and disambiguation previews
- Update padding for generic and disambiguation previews to be the same as other popups, results in minor visual changes

Bug: T341899
Change-Id: I9a58fc6a93160d07452ea6f903e1797dd9421d92
2023-08-21 19:53:51 +00:00
Jon Robson 9aa07d0809 Model: Make dwell delay part of model and registration
Dwell delay varies between popup type so should be part of the
definition. Since this is needed by reference tooltips we should
make this part of the Page preview model. This will allow us to
separate concerns of the architecture and reference  tooltips
for better maintenance between WMDE and web team.

Bug: T326692
Change-Id: Ia021c8b90fd69d70c4b33744520bb963a65db036
2023-07-26 17:42:56 -07:00
Jon Robson 5af31b5524 Don't log for documentElement (nodeType 9)
Follow up to Ia011aaf9f8b5b932695da3311f849682c0105cfe

Bug: T340081
Change-Id: Ibff26eb90fd650532a7e23ac16232366676c0d15
2023-07-18 20:34:47 +00:00
Jon Robson a80d2b1f56 Add additional debugging closest bug
Use the topic "error.web-team" - error prefix necessary
for it to be treated as an error, and 'web-team' moves
it off main channel.

Error logs tagName and nodeType which should be sufficient
for us to understand this issue. Can expand with other
information later if need be. Cannot add to stack trace
as any non-standard stack trace would be dropped by the intake
code.

Bug: T340081
Change-Id: Ia011aaf9f8b5b932695da3311f849682c0105cfe
2023-07-17 14:54:12 -07: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
Moh'd Khier Abualruz 67a718a5be TypeError: n.closest is not a function
- check if the element has the function in it before using it
- implementing a native code to get the same result based on polyfill examples
- fix Coverage Block

Bug: T340081
Change-Id: I1c2ce46a88cde6323ab862964062dd722ff5edcb
2023-07-10 11:48:40 -07:00
Jon Robson 9ee816a919 When extract is a string treat it as HTML
According to the docs:
The Element.append() method inserts a set of Node objects or string
objects after the last child of the Element.
String objects are inserted as equivalent Text nodes.

When given a string we want to treat these as HTML

Also fix the storybook which hinted at this being a problem
(incorrectly fixed in 504eefcc1)

Bug: T341318
Change-Id: I415c9821a6a37b45cf0f8a65f58a41bc7d0a042d
2023-07-07 10:09:28 -07:00
Jon Robson 049729626c IP masked users use localStorage for settings
Bug: T330517
Change-Id: Ib283e37f379e8cccc7f49ab0ce9aadd6535ea668
2023-06-14 08:16:50 -07:00
Jon Robson 580067b94e Discourage jQuery usage in Popups extension
Change-Id: Iff0c81e4c1d78cc52d1bd9d81e24d8fae228c9bc
2023-06-13 15:39:57 -07:00