Commit graph

81 commits

Author SHA1 Message Date
Jon Robson 3fbf5b49f0 Drop unused code relating to old limited width toggle.
Follow up to Ie2617e2fa83b6a888a7a2799cc39f048731dc60d

Bug: T367591
Change-Id: I270f1902f40946f31de29777735dee2e10ebfebe
2024-09-11 00:12:59 +00:00
ksarabia ae6f0d5486 Remove old limited width toggle
* Removes js
* Updates bottomDock style rules
* skin mustache updated
* Remove appearance feature flag - show appearance menu
to all users.

Bug: T367591
Change-Id: Ie2617e2fa83b6a888a7a2799cc39f048731dc60d
2024-09-03 11:25:23 -07:00
Jon Robson acb79c5e1b Improve documentation for how feature manager classes work.
This changes nothing about the existing classes, it just improves
how they are documented.

The FIXME comment was making things confusing.

Make sure every feature class is accounted for and audited and
throw a RuntimeException if we forget to document it.

Change-Id: I9d8f6553fe6b8c2ae80d8b2490c8895a8334a537
2024-08-08 20:19:48 +00:00
Jdrewniak 607e6b39c5 Revert "Add exclusion behaviour for "width" option in Appearance menu"
This reverts commit ff5a61e9c6.

Reason for revert: The behaviour introduced in this patch needs some more consideration.

Bug: T364015
Change-Id: Ieab4ca4084df4f1b5c942fe81c7fb99b058e0623
2024-05-23 23:51:46 +00:00
Jan Drewniak ff5a61e9c6 Add exclusion behaviour for "width" option in Appearance menu
- Adds the notice "This page is always wide" and disables
  the inputs for the "width" options in the Appearance menu
  when pages are excluded via configuration ( `$wgVectorMaxWidthOptions`).
- Changes layout behaviour so that pages in the
  $wgVectorMaxWidthOptions['exlcude'] configuration
  stretch the entire viewport width.
- Stops the width settings in the Appearance menu from
  being hidden on smaller resolutions.

Bug: T364015
Change-Id: Idee294adf3b309e03834276ea75e4ae43b0cffcb
2024-05-17 17:58:19 +00:00
Moh'd Khier Abualruz 37e8e4c929 feature(Vector): Add configurable font size exclusions
This patch introduces the ability to configure font size exclusions
for specific pages within the Vector skin, ensuring certain pages
always use a small font size. This change is part of ongoing improvements
to the Vector skin's customizability features.

Changes:
- Updated `skin.json` to include `VectorFontSizeConfigurableOptions`
- Added new i18n string `vector-feature-custom-font-size-exclusion-notice`
- Modified logic for font size exclusion handling in `FeatureManager.php`

Additional Notes:
- Affects testing and beta deployment environments, ensure relevant
  settings are updated in `LocalSettings.php`.
For testing and on beta deployment, these settings should be set in
the LocalSettings.php of the environment, example:

$wgVectorAppearance = [
    "logged_in" => true,
    "logged_out" => true,
    "beta" => true
];
$wgVectorFontSizeConfigurableOptions = [
	"exclude" => [
	"namespaces" => [ -1, 2, 6, 8, 10, 14, 100, 710, 828 ],
		"querystring" => [
			"action" => "edit|submit|diff|info|protect|delete|undelete|diff|history",
			"diff" => ".+"
		]
	]
];

Bug: T364887
Change-Id: I23b9c4fb63f35c7d27544197fead3ad7619c67f1
2024-05-15 19:19:38 +00:00
Jdlrobson b7743a1dbe Revert "Add exclusion notice for "width" option in Appearance menu"
This reverts commit 89c250c18e.

Reason for revert: We need some more time to test this one and
the resulting behaviour. After discussing this morning we decided
to remove from the next train release.

Bug: T364015
Change-Id: I0dfc17d9c8a8697b8b4f590acdbc2d2c54de9429
2024-05-13 21:33:49 +00:00
Fomafix ca5c48052f Replace WebRequest::getText by WebRequest::getRawVal
The Unicode and line break normalizations of getText are not needed
here.

Change-Id: I53974627aec4b1b6724abb128a10c2a8d64059a9
2024-05-11 08:41:45 +00:00
Jan Drewniak 89c250c18e Add exclusion notice for "width" option in Appearance menu
Adds the notice "This page is always wide" and disables
the inputs for the "width" options in the Appearance menu
when pages are excluded via configuration ( `$wgVectorMaxWidthOptions`).

Bug: T364015
Change-Id: Ie99b41c9130f496ab23b60c95e551a9ea602d5a0
2024-05-09 16:47:07 -04:00
Fomafix d7735c8d57 Use context of FeatureManagerFactory in FeatureManager
Change-Id: I5e77b6ce2df1245e8a5c710b7e84813f04a77ae2
2024-05-07 18:49:06 +00:00
Fomafix 6320921bd4 Inject service UserOptionsLookup into FeatureManager
Change-Id: I3a056731c4a4e970cae0b974dab574bdbb0401f5
2024-05-06 20:07:58 +00:00
Jon Robson 55e6dfd81c Fixes: exclusion logic for anonymous users
Bug: T364159
Change-Id: I7c7e9cff7b99f8e37f3f1ffb93464fd3f31c799b
2024-05-06 12:20:40 -04:00
bwang 0109218ab9 Rename client preference menu to appearance menu
Bug: T362808
Change-Id: Id6800d38eebf433cf0c9e3f179dd83df2eefd1fb
2024-04-29 15:38:20 +00:00
jenkins-bot f6c0071bd7 Merge "Add exclusion notice for night mode feature" 2024-04-17 16:44:03 +00:00
Jan Drewniak a3801497b9 Add exclusion notice for night mode feature
If night-mode is disabled on a certain page via the
exclude list in skin.json, then the following class:
".skin-theme-clientpref-excluded" will be added to the HTML element.

In this scenario, the related client-preferences
menu options are visible, but disabled, and a notice
is rendered below the options informing users of this state.

Bug: T361158
Change-Id: I46d335d079a2d27c7a4122e23ac7e479c286b886
2024-04-16 22:38:35 -04:00
bwang c69a53a16c Use client preferences for appearances menu
Bug: T361586
Change-Id: I636a557e724f23ea18da135bac59cb304ba81091
2024-04-15 22:36:48 +00:00
Moh'd Khier Abualruz 1fbdc0828a Accessibility settings menu should default to open for all users
Refine Feature Management in Vector Skin, in this patch we simplify the feature management criteria within the Vector skin by adjusting the requirements for the Constants::FEATURE_CLIENT_PREFS_PINNED feature. By removing the Constants::REQUIREMENT_LOGGED_IN constraint, we aim to enhance and unify the user experience by making certain preferences more accessible to users, regardless of their login status.

Changes:
- Updated FeatureManagerFactory.php by removing the Constants::REQUIREMENT_LOGGED_IN from the list of requirements for Constants::FEATURE_CLIENT_PREFS_PINNED. This modification aligns with our goal of making the Vector skin more user-friendly and accommodating to both logged-in and anonymous users, ensuring a broader range of users can benefit from customized features and settings.

Rationale:
The decision to remove the login requirement for accessing certain client preferences stems from an ongoing evaluation of user engagement and feedback, as detailed in Phabricator task T360099. This change is part of a series of improvements aimed at enhancing the accessibility and usability of the Vector skin, making it more adaptable to the diverse needs of our user base. By enabling more features for anonymous users, we anticipate an increase in engagement and a more personalized browsing experience for all users.

Bug: T360099
Change-Id: Ic477cd66df34c1caeb822d8d2162a7299cd648a0
2024-04-01 05:49:36 +02:00
Steph Toyofuku feb8cc90dc Allow disabling of night mode on certain pages via config
* Using the new ConfigHelper, support disabling night mode on certain
pages via configuration options
* In addition, adds test coverage for this case and the query parameter
case (in a new integration test file as we now require accessing the
service container for request context)
* Finally, supply a default configuration in skin.json with all the
values set to null

For the easiest possible approach while we evaulate our general feature
management system, this logic is handled inside of getFeatureBodyClass
using the new shouldDisable general function.  In the future, it may
make sense to break this out into its own requirement class, but for now
that feels premature

Bug: T359606
Change-Id: I3e7a4720ec3cc2afd9777e36f59aa56b682258f0
2024-03-28 16:37:30 -07:00
Moh'd Khier Abualruz b3ab84f9e5 Vector - Rename the skin night mode classes to more readable classes
The classes:
- skin-night-mode-clientpref-0
- skin-night-mode-clientpref-1
- skin-night-mode-clientpref-2
is being replaced with
- skin-theme-clientpref-day
- skin-theme-clientpref-night
- skin-theme-clientpref-os

Other Changes:
- Change vector-night-mode preference to vector-theme
- Add skin-theme-os-label and other messages to skins.vector.clientPreferences
- Remove skin-night-mode-* messages from skins.vector.clientPreferences

Bug: T359983
Change-Id: I31eb086e623a97df9fbd004425559e05b0cae170
2024-03-20 23:54:47 +00:00
Jon Robson f28f5850c5 Separate generic ConfigHelper class from LimitedWidthContentRequirement
In preparation for a decision around how we share code, the generic code in
LimitedWidthContentrequirement is moved to ConfigHelper class. A fix
recently applied to Minerva (Ied3ed927202dd9356ebeb7e404230f571a1d910d)
is also incorporated into the new class.

The expectation is this code will be either:
1) be replaced by a submodule
OR
2) Used directly by Vector
after a decision tomorrow.

Bug: T359607
in I3967803bd75cf78d27c1a7c08e62730e46678a68 or removed

Change-Id: I04066acc86594e721e071e9096e1b12e1255b54b
2024-03-20 00:23:51 +00:00
Umherirrender 558359c06d Type hint UserIdentity in Requirements/Components
Only id or registered state is needed.

Change-Id: I184db486ed2763e0402fe75ed9afb0e71a0d57c6
2024-03-13 21:59:40 +01:00
Umherirrender ea4fd5d182 Create a FeatureManagerFactory
Some feature requirements needs access to the request user or title.
Currently the context is given in the ServiceWiring callback,
access to RequestContext::getMain() should be avoided during service
wiring (T218555).
Create a factory to hold the code from the service wiring and call the
factory with the request context from the skin to get a feature manager.

Bug: T359665
Change-Id: I57515ec02ed454620f729a109d0ace43b447b6ce
2024-03-08 20:28:31 +01:00
bwang 14a40c0be6 Override night mode pref with night mode query string
Bug: T357329
Change-Id: I30766bced218208ddfe5c2990d7dac290441a1d0
2024-02-15 13:59:12 -06:00
jenkins-bot 8dff67dc05 Merge "Refactor and clean up FeatureManagement classes" 2024-02-06 01:08:37 +00:00
Doğu Abaris 348e6f6cc8 Refactor and clean up FeatureManagement classes
This commit introduces several changes to improve the structure and
readability of the FeatureManagement code in the Vector skin. Key
changes include:

- In ABRequirementTest.php, improved test method names for clarity.
- In ABRequirement.php, simplified property declarations and cleaned up
  code structure.
- In DynamicConfigRequirement.php, cleaned up property declarations.
- In LimitedWidthContentRequirement.php, cleaned up property
  declarations and added type hints.
- In LoggedInRequirement.php, cleaned up property declarations.
- In OverridableConfigRequirement.php, cleaned up property declarations.
- In OverrideableRequirementHelper.php, cleaned up property declarations.
- In SimpleRequirement.php, cleaned up property declarations.
- In UserPreferenceRequirement.php, cleaned up property declarations.

Each change aims to enhance the codebase's maintainability and
understandability. No functional changes were introduced.

Change-Id: I23283c5a6799b1f03a6a9b5832c34c7dbbcca527
2024-02-06 00:37:14 +00:00
bwang e964cbb785 Add Vector night mode feature flag
Bug: T355065
Change-Id: Ica63eb61ee042e8684168f6787b27a5e58e38bee
2024-02-05 11:33:37 -08:00
Umherirrender 4fcd95bcb4 FeatureManager: Avoid $this assignment
Just make the callback non-static

Change-Id: I409857dffdbcdd80dfbbe2fb8c64858e9a8f80ef
2024-01-11 22:36:03 +01:00
Umherirrender f8ffcd20d2 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statements done manually

Change-Id: I9b8f447ea4d715bc815cc782184bca288ee001a0
2024-01-02 20:54:08 +01:00
gerritbot febf3e635e 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: I084e01a29884f338fae22d7239d068823a2657c3
2023-11-29 12:42:02 +00:00
Moh'd Khier Abualruz 173c91a0f5 Make Vector feature flags compatible with beta features
- Added Key 'beta' to features config in skin.json. As usual this also supported by global configs.
- Added feature management logic to check for beta feature enabled status and the user's selection of utilising the vector beta features.
- Added VECTOR_BETA_FEATURES to Constants.php which is an array that holds features names that would be enabled.
- Removed final from class declaration of OverridableConfigRequirement class, as it does interfere with the mocking in the current setup

Remaining Work:
- Missing images to be added in the hook to show in beta features under Special:Preferences -- this will be added in a followup

Bug: T347772
Change-Id: I7bf8284e328c66c019c392f57207cab21ce0d4f6
2023-10-19 18:22:57 +02:00
Moh'd Khier Abualruz 22e97fe383 Add multiple font size to logged-in users
Read Value from user preference for logged-in users.

Depends-On: I041a0cb21e872700ceeeddd3a39922e456aa7bb8
Bug: T346954
Change-Id: I6afa39624c3cadd31632d63a36b919d641983ae6
2023-10-17 19:42:30 +02:00
Jon Robson 004b4c96f3 Add multiple font size to frontend
Use integer value going forward as it will be easier
to manage.

Bug: T346954
Change-Id: I041a0cb21e872700ceeeddd3a39922e456aa7bb8
2023-10-17 12:43:02 +00:00
Jon Robson 411f9ce69a Allow user preferences to be overriden by query string parameter
Currently only features that are associated with LocalSettings configuration
can be overriden by query string. Going forward we'd like to expand this to apply
to user preference too.

A generic OverrideableRequirement is created.
The existing OverridableConfigRequirement is refactored to extend OverrideableRequirement
The /UserPreferenceRequirement now extends it

This allows http://localhost:8888/wiki/Spain?vectortypographysurvey=1
to work

Bug: T347900
Change-Id: I11efd6b07192d5d2333f4506e9d87a8c0638d657
2023-10-12 19:05:10 +00:00
Jon Robson 735dad995b Preferences set to "disabled" return false when isEnabled is called
The font size preference sets a preference to disabled rather than 0.

Rather than save this as 0, it would be useful to store this as a string
given in future it will evolve to have values small, medium, large

Change logic in UserPreferenceRequirement to support non-binary options.

Bug: T346987
Change-Id: I399aa1b1be4a45cab0aa3b8addb482e5af6c5bf3
2023-10-04 00:34:16 +00:00
Jon Robson d35db97615 It should be possible to persist Vector font size for registered users
Bug: T346987
Change-Id: I01e0fac5ba781480ee32a8b32f6ef7fafb8d1ca5
2023-09-27 20:04:22 +00:00
Moh'd Khier Abualruz c88d72f1d7 [anon prefs] TOC pinned / unpinned
- Status should persist across page views for anonymous users
- Added 'toc-pinned' as a persistable feature in features.js and FeatureManager.php.
- Handling for cached HTML supporting both new and old class names for pinned/unpinned TOC

Based-On: I0fbe0ab458c5bd55d659d3c35a8fbaa6cd6ec0e1

Bug: T316060
Change-Id: Iad8523037ed364f09962b2d6ca0a3d50d7bd2266
2023-09-14 21:37:50 +00:00
gerritbot b5c38e7158 Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I7283b3a22bedf6d05d0959cd6edb40b0b15c57b0
2023-08-19 04:23:07 +00:00
Jon Robson e5bf8adad7 Limited width uses new client preferences system
* Update classes to use clientpref-1 and clientpref-0 suffix for limited width
I've limited this to the only client preference for now to reduce
risk.
* For cached HTML retain existing CSS rules, and continue saving
a cookie
* Migrate cookie if found for newly generated pages. This will be
to ensure the old cookie and new cookie are in sync (this should be
a one time operation)

Depends-On: I1e635f843ac9b2f248b1f7618134598e80291b38
Bug: T341641
Change-Id: I120f8f7114b33d2cfbd1c3c57ebf41f8b2d7fec4
2023-08-04 21:31:21 +00:00
ksarabia 9fbed3eb7f Remove centraluserid dependency in ABRequirement.php
Removes centraluserid and replaces it with local user id.

Bug: T336969
Change-Id: I5abedf62fb92cb08fbcaf09f6d19ab45fcfc9819
2023-05-23 15:03:59 +00:00
Jon Robson dbf3931515 Query string override should support camel case as well as lowercase
- ?vectorzebradesign=1 and ?VectorZebraDesign=1 now enable a feature
- Drops the parameter from OverrideableConfigRequirement which was leading
to the inconsistency

Change-Id: I4e124b6de2e5a0e46804036c6ac3f97fd2af4d81
2023-05-03 16:56:42 +00:00
ksarabia f2dbf8508e Follow up service wiring update
This modifies the ABRequirement.php and ServiceWiring.php file.

Bug: T333493
Change-Id: I3e5cb7499b36cd5c894e8b5527f77a9cc94b5165
2023-04-19 23:04:53 +00:00
Jon Robson a76e198523 Remove A/B testing element from OverridableConfigRequirement
Superseded by ABRequirement. Having this code here is confusing
and might lead to non-standard A/B tests being defined.

Change-Id: Ifd9d2b7249250a73e7f6e4f9d6b51c322ef2759d
2023-04-19 01:41:53 +00:00
ksarabia 8cdb773026 Add Vector Zebra Design A/B Test
Adds Zebra A/B test configuration

Bug: T333493
Change-Id: I56f66e19dd3fab2007de50d665f077a4ee01a6e4
2023-04-18 18:14:58 -07:00
thiemowmde 98a83a42c2 Fix outdated ConfigRequirement class documentations
The methods have been renamed in I612af95. Updating the documentation
was forgotten.

I'm not sure how the @see tags are useful. The two methods are right
next to each other. I suggest to remove the outdated tags.

Bug: T244481
Change-Id: Ic8c1d8cc1a4f7ab221643ad1905e2145e56076aa
2023-03-03 10:43:36 +01:00
bwang 6c817e932f Use features.js for main menu pinning functionality
- Register new feature for main menu pinned
- Update UserPreferenceRequirement to optionally handle default config values
- Add nav landmarks for the main menu

Bug: T317900
Change-Id: I8fc6e0a79a1155d68afb9e33e5101a2a160dc4e5
2022-12-16 12:56:54 -06:00
bwang 97de09dcba Refactor page tools, main menu, and TOC components
- getTocData is moved into VectorComponentTableOfContents and it's test file
The following changes were made to the main menu, toc and page tools PHP components
- Avoid passing in $skin to the constructor
- Handle isPinned logic inside the component
- Add a public ID constant to the components
- Dropdown data for each feature use the same naming convention

Bug: T317900
Change-Id: I77a617a6c1d93bccd3b6e59353299f5534624e53
2022-12-15 14:23:25 -08:00
bwang 81348a659c Remove TOC AB test code
While removing this we also noticed that we check the value of
isMainPage. This doesn't seem like a good idea as most main pages
do not have a table of contents, so it seems like adding
unnecessary complexity for a state that doesn't exist in practice.
The existing code path also doesn't work as it adds a table of contents
unstyled to the page.

Bug: T324874
Change-Id: Idaeff6ace5912ea74ed9d335526027c4690ac8fa
2022-12-09 16:07:52 -08:00
Nicholas Ray 24055a6752 Set default pinnable state for page tools
* Leverage the infrastructure around feature management to handle the page tools
pinning and persistence

* Make pinnableHeader.js leverage features.js if the data-feature-name attribute
is set

* Sets tests/.eslintrc.json ecmaVersion to 2018 to enable destructuring in test
files.

* Adds a isPinned helper method to pinnableElement

* Add a logged in requirement so that the pinned feature is disabled for
anon users.

Bug: T322051
Change-Id: Ib86282216882fa94e37b7088a3f4bd0c1bcf6cd4
2022-12-08 14:44:07 -07:00
Nicholas Ray 7e0dd79d5a Convert LimitedWidthRequirement to UserPreferenceRequirement
Generalize LimitedWidthRequirement into a more reusable
UserPreferenceRequirement that can be used by both the limited width feature and
the persistent pinning feature (and possibly others in the future).

* Removes existing logic that checks whether the option is not null. Given that
skin.json sets the default [1], presumably this isn't needed.

* Adds unit test

[1] 65af26a258/skin.json (L163)

Bug: T322051
Change-Id: I7f228cf81a65b2eb22dbe94d2384b6c9f6da91f2
2022-12-01 16:31:47 -07:00
Jon Robson 614da1dc5e Features: Make max width a feature
Making this a feature part of the feature management system is integral
to making this a toggle and will allow us to explore making this
persistent in future.

Bug: T319447
Bug: T319449
Change-Id: I80c7b892a6891094854b4154db90917b67986102
2022-10-24 13:12:06 -07:00