Commit graph

203 commits

Author SHA1 Message Date
jenkins-bot cbe69cbf53 Merge "Reference previews should no longer use Webpack" 2024-02-08 16:09:00 +00:00
James D. Forrester 608fa2b69d build: Upgrade browserslist-config-wikimedia from 0.5.1 to 0.6.0
Change-Id: I8d0a00efb0464149951af33b7d24e407035c8d08
2024-02-07 14:32:44 -05: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 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
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 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
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
WMDE-Fisch 62510a4fba [build] Bump wdio-mediawiki to v2.3.0
Change-Id: Id5ab1b832e48cc9c211278f32354ca97ca3b693f
2023-09-26 14:22:42 +00:00
James D. Forrester a8557a7042 tests: Raise jQuery requirement from v3.6.1 to v3.7.1
Matches MediaWiki change d3d0a363d1f8c70cfa2e880d24182c050ad9bf78.

Change-Id: I948042fb0c4e19d9162680a4fa3e5ae024393859
2023-09-07 16:14:29 +00:00
Umherirrender 97b9e453e2 build: Use quotes for paths in package.json
To make it working on Windows

Change-Id: I432091107356682f4d6bc8613922b908a6c2e6ea
2023-08-10 08:47:16 +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
WMDE-Fisch c2413c858b selenium: Refactor WebdriverIO tests from sync to async mode
I also removed the bool on the shouldUseReferencePopupsBetaFeature
method. It was always just used with `true`

Bug: T293072
Change-Id: I1a2d6f912fcac2ac77539581897e0feab489edf0
2023-07-18 09:34:47 +02: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
jenkins-bot 655f08aa8a Merge "Publish coverage file" 2023-06-15 16:38:24 +00:00
Jon Robson bf63e2bc6e Publish coverage file
Context [[mw:Topic:Xk10fxsoqth6scfz]]

Change-Id: Ic99cf9bdffdeb56a6182e650d3878902696c0df0
2023-06-15 08:53:39 -07:00
Volker E 4132ee96ab build: Update SVGO to v3.0.2
svgo         2.8.0  →   3.0.2

Amending to new `cleanupIds` plugin name.

Bug: T339162
Change-Id: I8ad37e46501c36883967827b4d622788ae9065f1
2023-06-14 12:32:01 -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
libraryupgrader faa3c63af8 build: Updating npm dependencies
* grunt-banana-checker: 0.10.0 → 0.11.0
* stylelint-config-wikimedia: 0.14.0 → 0.15.0

Change-Id: Ie2be62f89f01533a83982880a0ea7a2a71405b37
2023-06-02 01:01:00 +00:00
jenkins-bot a38f4c5336 Merge "Prefer native JavaScript to jQuery" 2023-05-26 03:22:52 +00:00
libraryupgrader 32778684af build: Updating npm dependencies
* @wikimedia/codex: 0.10.0 → 0.11.0
* @wikimedia/codex-icons: 0.10.0 → 0.11.0

Change-Id: Ic5218ad62e27900eb6a96461d9aa9126829f70e0
2023-05-24 00:54:43 +00:00
Jon Robson 7c592bc790 Prefer native JavaScript to jQuery
Bug: T315929
Change-Id: I949fd9551269a3cb9d9df7744149510949d3076c
2023-05-21 16:53:50 +00:00
libraryupgrader 3840382ba1 build: Updating npm dependencies
* @wikimedia/codex: 0.9.1 → 0.10.0
* @wikimedia/codex-icons: 0.9.1 → 0.10.0

Change-Id: I5e8d4af946ae8d679f9cedbe34eac9f221035bef
2023-05-17 00:51:30 +00:00
Umherirrender 7a6cac8a64 build: Updating eslint-config-wikimedia to 0.25.0
Change-Id: Ic511f54b58947a2694514e2d417e022bdeae219d
2023-05-16 00:22:03 +02:00
Jon Robson 428c32d027 Switch to native Promises and fetch
For fetch and AbortController we provide native polyfills (see
resources/src/skip-web2017-polyfills.js) so safe to use this here.
This will be empty for modern browsers.

Change-Id: Ic0f55eb0a0276be3587a4b866834bddff1124ad2
2023-05-12 21:34:42 +00:00
libraryupgrader 97855ef2f4 build: Updating npm dependencies
* @wikimedia/codex: 0.8.0 → 0.9.1
* @wikimedia/codex-icons: 0.8.0 → 0.9.1
* less: 3.8.1 → 3.13.1

Change-Id: Idb363fba64495430bbc97e044d2047dec450e7cf
2023-04-27 00:25:44 +00:00
Umherirrender 3573232c21 build: Updating npm dependencies
* eslint-config-wikimedia: 0.22.1 → 0.24.0
* @wikimedia/mw-node-qunit: 6.3.3 → 7.0.0

Change-Id: I348eb70bfc6c1d6c922c8290152926183712dee1
2023-04-03 23:14:47 +02:00
Jon Robson ec50f3f6ff Fix storybook integration
Broken by If2b4073115d9082829e4917c87c167d18f5431d9
Change import to directly hit the Codex library
This should also allow web team to respond to Codex upgrades
at their own pace (via package.json)

Render functions must now be registered in storybook for
them to display. Follow up to
Iefe98c1f0422dbf034e385b1a41a859d030a2cf4

Change-Id: Iac9dede15f4de3a4d584f1e505e379764af6dcbf
2023-03-30 15:36:05 -07:00
Umherirrender 5f18164beb build: Updating npm dependencies
* stylelint-config-wikimedia: 0.13.0 → 0.14.0

Run stylelint fix to fix the new stylelint rule

Change-Id: I98f17b481d4ba56a8cd87fcafb1fc2efdaa8abe7
2023-03-28 20:18:47 +00:00
libraryupgrader 7ccf2f0f3a build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 39.0.0 → 41.0.0
* mediawiki/mediawiki-phan-config: 0.11.1 → 0.12.0

npm:
* eslint: 8.9.0 → 8.31.0
* grunt-banana-checker: 0.9.0 → 0.10.0
* @wdio/mocha-framework: 7.4.6 → 7.30.2
* svg-inline-loader: 0.8.0 → 0.8.2
* decode-uri-component: 0.2.0 → 0.2.2
  * https://github.com/advisories/GHSA-w573-4hg7-7wgq
* deep-object-diff: 1.1.7 → 1.1.9
  * https://github.com/advisories/GHSA-653v-rqx9-j85p
* http-cache-semantics: 4.1.0 → 4.1.1
  * https://github.com/advisories/GHSA-rc47-6667-2j5j
* terser: 4.8.0 → 4.8.1
  * https://github.com/advisories/GHSA-4wf5-vphf-c2xc
  * https://github.com/advisories/GHSA-4wf5-vphf-c2xc
* ua-parser-js: 0.7.31 → 0.7.34
  * https://github.com/advisories/GHSA-fhg7-m89q-25r3

Change-Id: I11c9ba8212c9103e92baa5ebc09f9214b04851ff
2023-03-12 08:46:52 +00:00
Vaughn Walters a7dba1c602 selenium: Remove webdriverio npm package from the Popups extension
The `webdriverio` package does not need to be an explicit dependency.
It is a dependency of `@wdio/cli`.

Bug: T325059
Change-Id: I9d72d936e763dde9bc6d21708bf03fd39ee32ba0
2023-01-13 11:38:43 -06: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
James D. Forrester e1ea210f6f build: Upgrade jQuery test install to 3.6.1 to align with MediaWiki
Bug: T316516
Change-Id: I76a4aad525975e7fde7c70a2d0edb9801c1c939b
2022-08-31 09:22:27 -04:00
libraryupgrader f32d77c603 build: Updating dependencies
composer:
* php-parallel-lint/php-parallel-lint: 1.3.1 → 1.3.2
* mediawiki/mediawiki-codesniffer: 38.0.0 → 39.0.0
* php-parallel-lint/php-console-highlighter: 0.5.0 → 1.0.0

npm:
* stylelint-config-wikimedia: 0.12.2 → 0.13.0
* mocha: 8.4.0 → 8.4.0
  * https://github.com/advisories/GHSA-qrpm-p2h7-hrv2
* nanoid: 3.1.20 → 3.1.20
  * https://github.com/advisories/GHSA-qrpm-p2h7-hrv2

Change-Id: I972f0212957bb495238f072a5de64fdd72e8c856
2022-05-21 10:03:09 +00:00
libraryupgrader a5e2d17b45 build: Updating dependencies
composer:
* mediawiki/mediawiki-phan-config: 0.11.0 → 0.11.1

npm:
* eslint: 8.8.0 → 8.9.0
* wdio-mediawiki: 1.1.1 → 1.2.0
* @storybook/html: 6.2.9 → 6.4.22
* bundlesize: 0.18.0 → 0.18.1
* jquery: 3.4.1 → 3.6.0
* jsdoc: 3.6.3 → 3.6.10
* webpack-cli: 3.1.2 → 3.3.12
* ansi-regex: 5.0.1 → 5.0.1
  * https://github.com/advisories/GHSA-93q8-gq69-wqmw
* async: 0.9.2 → 0.9.2
  * https://github.com/advisories/GHSA-fwr7-v2mv-hh25
* ejs: 3.1.6 → 3.1.6
  * https://github.com/advisories/GHSA-fwr7-v2mv-hh25
* jake: 10.8.2 → 10.8.4
  * https://github.com/advisories/GHSA-fwr7-v2mv-hh25
* minimist: 1.2.5 → 1.2.6
  * https://github.com/advisories/GHSA-xvch-5gv4-984h
* mocha: 8.4.0 → 8.4.0
  * https://github.com/advisories/GHSA-qrpm-p2h7-hrv2
* nanoid: 3.1.20 → 3.1.20
  * https://github.com/advisories/GHSA-qrpm-p2h7-hrv2
* prismjs: 1.27.0 → 1.27.0
  * https://github.com/advisories/GHSA-3949-f494-cm99
* refractor: 3.5.0 → 3.6.0
  * https://github.com/advisories/GHSA-3949-f494-cm99

Additional changes:
* Set `name` in package.json.
* Also sorted "composer fix" command to run phpcbf last.
* Added the "composer phan" command to conveniently run phan.
* composer.json: Updated phpcs command in composer test (T280592).
* composer.json: Added phpcs command to scripts (T280592).

Change-Id: Ic9c742a3be5b22ccc1e8dff5b65ee779e2a02175
2022-04-15 19:01:33 +00:00
Ed Sanders 7cb024592b build: Update stylelint-config-wikimedia to 0.12.2
Change-Id: I5deff2e90e0bfa4e318094fe1962c2c66b5bd8f5
2022-02-28 13:18:39 +00:00
Ed Sanders 883c8c1aca build: Update eslint-config-wikimedia to 0.22.1
Change-Id: I055517998ed06fccdf50ec31251ea6aa9040abb5
2022-02-28 13:18:24 +00:00
Volker E 830ec1b56b build: Update 'svgo' to latest v2.8.0 & re-crush images
Updating 'svgo' to v2.8.0 and newest Wikimedia SVG guidelines –
mainly around new whitespace features of SVGO.

Change-Id: I37da089916d2efad696989427b0a06b392d1d89c
2022-02-27 23:58:05 +00:00
Umherirrender d6eddc9ca0 build: Updating stylelint-config-wikimedia to 0.11.1
Change-Id: Id770e10a4c37503eae2b6fb383f12b389d793f77
2021-09-12 16:11:01 +02:00
jdlrobson fa19ee0d4f Adjust previews to meet specifications
Apply max-heights and tweak some of the margin values

Bug: T284643
Change-Id: I0c8a77e10c36ae444e541bb52a8797594c77db63
2021-08-25 22:55:26 +00:00
sahil 7142676629 selenium: Upgrade WebdriverIO to v7
Update npm packages: @wdio/* and webdriverio.

Bug: T274579
Change-Id: Ie9bd50e36f0c888a19e73ab9b424a8b6a5bd67fd
2021-08-24 17:29:16 +00:00
Timo Tijhof 06ab2d7676 build: Fix gaps in lint coverage and update old patterns
eslint:
* Remove hardcoded glob paths that are (relatively slow) to expand
  before linting could start, in favour of specifying directories
  which can be iterated while linting happens.
* JSON files in i18n/ were skipped, unlike other repos.
  JS code under .storybook/ was skipped.
  JS code under resources/ext.popups/ was skipped.
  Fix all these by doing what other repos do, which is to let
  ESLint iterate the repository and tell it which directories not to
  enter. This has the happy side-effect of making IDE integrations
  for ESLint work correctly (as customisation in package.json has the
  same problems as using Gruntfile, namely that invoking 'eslint'
  directly can't be aware of this), as well as allowing things like
  `eslint --fix` to be used.

```
/Popups/resources/ext.popups/index.js
  4:2  error  Unexpected var, use let or const instead  no-var
```

nyc:
* Remove SPAWN_WRAP_SHIM_ROOT.
  This was a hack for an early CI experiment that hasn't been
  needed for several years.

storybook:
* Remove gitignore entries for additional npm and build output in the
  storybook subdirectory, which appears to not exist anymore since
  189b386a13.

Doxygen:
* Sync with cookiecutter example from
  https://gerrit.wikimedia.org/g/mediawiki/tools/cookiecutter-library/+/HEAD/
  - remove redundant stuff,
  - enable quiet mode to hide verbose non-warning,
  - include CoC.

Change-Id: If8f6b833067192aea96a87f04c7978c9af11f996
2021-08-16 17:02:05 +00:00
Sam Smith 8f5000f346 Remove Popups instrumentation
Bug: T267211
Change-Id: I640ab367cd235ab8da7dd70dbef7ae9076712e84
2021-07-29 17:01:01 +00:00
sahil 1e1b8506ac selenium: Update wdio-mediawiki
wdio-mediawiki v1.1.1:
- Includes wdio-defaults.conf.js file that vastly simplifies wdio.conf.js.
- Replaces @wdio/spec-reporter with @wdio/dot-reporter.
- Introduces video recording.

Bug: T283597
Change-Id: I76edb3f16272fc6c1d70b0a796115cf5cc22d255
2021-07-28 16:35:31 +05:30