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
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
Changes to the use statements done automatically via script
Addition of missing use statements done manually
Change-Id: I9b8f447ea4d715bc815cc782184bca288ee001a0
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
- 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
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
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
- ?vectorzebradesign=1 and ?VectorZebraDesign=1 now enable a feature
- Drops the parameter from OverrideableConfigRequirement which was leading
to the inconsistency
Change-Id: I4e124b6de2e5a0e46804036c6ac3f97fd2af4d81
Superseded by ABRequirement. Having this code here is confusing
and might lead to non-standard A/B tests being defined.
Change-Id: Ifd9d2b7249250a73e7f6e4f9d6b51c322ef2759d
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
- 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
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
* 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
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
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
The class vector-feature-table-of-contents-disabled is confusing as
it shows on pages with table of contents. What it actually means
is the A/B test is disabled. This change gives it a more meaningful name.
Use the class name vector-feature-table-of-contents-legacy-toc-enabled
to describe it better.
Bug: T310527
Change-Id: I17e7e6f7f553b8c06b118b5419c98c78ef26ad60
Throw a runtime exception if the TOC experiment is setup correctly.
Otherwise this leads to confusion.
There must be 3 buckets, with 0 unsampled and equally weighted
control and experiment.
Bug: T313435
Change-Id: I09da238ff17b77a053b4dc132624ea19a86253b9
- Include temporary feature requirement for TOC A/B test.
- Assumes 100% of logged-in users with even/odd user ids
being assigned to treatment/control buckets respectively.
- Sampling rates passed in by config are not considered
during bucketing.
- Update hook for adding needed TOC A/B test body classes.
- Add test for temp feature.
Note: the temporary feature requirement and associated hooks
should be removed once the 2nd TOC A/B test concludes.
Bug: T313435
Change-Id: If9c75235614af289cd50182baab29bec3155eb81
- `MediaWiki\Skins\Vector\Tests` is now the prefix for all tests in the skin
- we followed PSR conventions of following folder structure after the prefix
- Optimize imports/use order
- update namespace in skin.json
Bug: T303102
Change-Id: Ib76374d81d973c83adfd6c8e7863ff6d797e655d
Additional changes:
* Make the query string parameter optional and if not defined set it
to lowercase configuration name. I think this makes it more predictable
as some configuration flags are prefixed with vector and some without.
This has the following consequences:
languageinheader => vectorlanguageinheader
languageinmainpageheader => vectorlanguageinmainpageheader
languagealertinsidebar => vectorlanguagealertinsidebar
titleabovetabs => vectortitleabovetabs
Note since table of contents query string is used in the A/B test
I've kept that as tableofcontents for now.
Bug: T303484
Change-Id: Iaca026ef5f32836098dc3b6f0f18632fe84fa8d0
The LatestSkinVersionRequirement is problematic for various reasons:
1) It uses the "useskin" query string
parameter which may or may not refer to the correct
skin (in the case of a non-existent skin it will always come to the conclusion that
it is not modern Vector and thus must be legacy).
2) It uses the User object which may or may not be safeToLoad
depending on when called.
The feature seems redundant at this point, as we are separating code
into separate classes Vector and Vector22 and all the features only apply
to modern Vector. I suggest we remove it and use the features explicitly in the skin
intended.
Bug: T305232
Bug: T305262
Bug: T302627
Change-Id: I92fa33547bd601e05ddc8c1468e681892e47c16b
Can be merged when database rows have been updated to
no longer use skin version.
* Drop migration code
* Drop skin version preference
* Drop default skin version and existing accounts skin version
* Move skin definitions into skin.json
* Repurpose SkinVector as an abstract class
* Update READMEs
Bug: T301930
Bug: T294995
Bug: T302627
Change-Id: I7454d8f1cfdef81e7f3df476d8ce86736b46fff2
Given Wikidata is the only project using modern Vector,
and the only project where the search API is not applicable,
this will result in a loss of autocomplete on Wikidata.org
which will fall back to the non-JS mode.
Bug: T290688
Change-Id: Iece5a4efd43e09cd90c842c9c134ca115b35f2b2
This will currently remove table of contents in article body
for legacy and modern skin.
To prevent us deploying this in current form, a check is
added in generateHTML
This requires an adjustment of OverridableConfigRequirement to
support requirements which do not vary on whether the user is
logged in or not.
Bug: T297610
Change-Id: I847a284229e498b3aa04c16ea3f84c360e735052
- Add new OverridableConfigRequirement class.
- Add query parameter constant for user links.
- Update Feature Manager with new requirements.
- Use new class for LanguageInHeader requirement.
- Remove LanguageInHeaderTreatmentRequirement class and test.
- Add unit test to cover user links and language in header.
Bug: T285855
Change-Id: I56b729a9e245ed2ddc85625c0be39f5c26320ac4
Before this commit the `languageinheader` query param would only take
effect if the A/B test was enabled AND the query param was set. Per
T282543, we want the query param to take effect regardless of the state
of the language/AB test config.
To see new treatment, set `languageinheader=1`.
To see old treatment, set `languageinheader=0`.
Bug: T282543
Change-Id: I6a06e90b6e46a6fd7506a5ddeaf071b893ebfe8e
* Adds ab test config to enable/disable the ab test. Defaults to `false`
(ab test disabled).
* Adds a `languageinheader` query param which only takes effect when the
ab test is enabled. The query param is cast to a bool and determines
which treatment is shown. For example, set query param to
`languageinheader=1` to see the new treatment. Set query param to
`languageinheader=0` to see the old treatment. To bucket based on the
user's id or global user's id, don't set the query param.
* Moves the language in header config work that was previously in
ServiceWiring into a `LanguageInHeaderTreatmentRequirement` class so
that unit tests can be done on most of the logic that determines whether
the language in header will show.
* Adds logic to bucket user based on [global] user id.
Bug: T280825
Change-Id: Id538fe6e09002fae6c371109769f3b7d61e7ac6d
FeatureManager allows the logic to be centralized and allows clients to
ask about its state. For instance, SkinVector will make use of it in
I70277c1082a504fbd5f6023e9873e8071de7e35d.
Also:
* Adds WvuiSearchTreatmentRequirementTest to test A/B logic
WvuiSearchTreatmentRequirement/Test logic are adapted from
I878239a85ffbecb5e78d73aed5568c56dbd7d659.
Bug: T270202
Change-Id: Ia02349a7b41c7caf26fbd728e0be7d47488b97e5
A new config flag is added that buckets 50% of users into the old
header and the 50% into the new header.
Bug: T249363
Change-Id: I8b4fa475f9cd7e61ad2989e2a1485e7e64c8ab3f
This will allow us to add the A/B testing requirement for logged in
users.
In preparation for the new A/B test requirement, a custom requirement
is added as the feature management system does not
support OR operations and the desired effect is the case where:
* the SearchInHeader feature flag has been enabled
* OR the SearchInHeaderABTest feature flag has been enabled and the user is bucketed
Bug: T259250
Change-Id: If948603bd598e1b5597345f4268736417f4c3a24
Following on from I9445d5c, align the @package annotations in
the Vector\FeatureManagement namespace and subnamespaces.
Bug: T248399
Change-Id: Icd287a52d149123bca5d9f0c55154f932f55148e
de76ab5 added the config,
`$wgVectorDefaultSkinVersionForExistingAccounts`. Its usage in
`Hooks::onUserGetDefaultOptions()` was invoked not only for existing
accounts but anonymous users _as well._ This is a bug, due to my own
misconceptions about the hook, that went against both the config's name
and its documentation.
Unfortunately, user sessions are unavailable in
`Hooks::onUserGetDefaultOptions()` so it does not seem to be possible to
determine whether the active user is an anonymous or existing account.
This patch drops the hook and centralizes all version determination
logic in SkinVersionLookup::getVersion(). SkinVersionLookup requires a
the active User object and can make the anonymous / existing account
determination by checking login state.
The issued was identified while responding to review feedback given by
@polishdeveloper / @pmiazga in
I52d80942b4270c008d4e45050589ed9220255a50.
Bug: T251415
Change-Id: I7982b4c34283ba81d0232ee6f501c44cf0a74b98
Changes:
- Add the LatestSkinVersionRequirement requirement class, which lazily
evaluates the application state to get the version of the skin for the
request.
This majority of this class is taken from Stephen Niedzielski's
Vector\SkinVersionLookup class, which was introduced in d1072d0fdf.
- Register an instance of LatestSkinVersionRequirement and register the
'LatestSkin' feature that requires that requirement
- Re-introduce SkinVector::isLegacy and make it defer to the Feature
Manager
Bug: T244481
Change-Id: If6b82a514aa5afce73e571abdd8de60b16a62fa8
Address some feedback from I7a2cdc2dfdf20d78e4548f07cf53994563b234b3:
- Miscellaneous documentation improvements.
- Add a false case test to `DynamicConfigRequirement->isMet()`.
Bug: T244481
Change-Id: Ic5637f42da755f871c5a6d545e14effd3ac8c670
We expect the vast majority of requirements and features to be defined
in services as possible. However, there are some "complex" requirements
that require additional application/HTTP request state. Unfortunately,
service wiring is done before some of that state is available.
I65702426 attempted to work around this by requiring clients of the
Feature Manager to pass that additional state on every interaction with
the system. Those complex requirements would then select the parts of
the state that they required when it was required. However
implementations of \IContextSource are God objects and their use should
be limited.
Whilst reviewing I65702426, Stephen Niedzielski mentioned that the
application state being available is a requirement. This remarkably
simple solution:
- Keeps the Requirement interface and FeatureManager API free of God
objects;
- Is true to the nature of the Feature Manager - it makes clear and
centralizes the various checks for application state being available
across the codebase; and
- Inject a Requirement implementations' dependencies at construction
time
It just so happens that the $wgFullyInitialised variable flags whether
the application state is available...
Changes:
- Add the the FeatureManager\Requirements\DynamicConfigRequirement class
and tests. The DynamicConfigRequirement lazily evaluates a single
configuration value whenever ::isMet is invoked
- Register an DynamicConfigRequirement instance, configured to evaluate
$wgFullyInitialised while constructing the Vector.FeatureManager
service
Bug: T244481
Change-Id: I7a2cdc2dfdf20d78e4548f07cf53994563b234b3