Commit Graph

84 Commits

Author SHA1 Message Date
jdlrobson 7d2d50873f Vector is split into 2 skins
A new vector-2022 skin is added. This will be the eventual home
of the new Vector skin when we are ready to migrate.

Please see SkinVector class for the migration plan to simulate this
as part of testing.

Bug: T291098
Change-Id: Ibaddf94a5bfb5e21bbbaf1e0aa1b343a3f566d2d
2022-01-06 15:52:10 -08:00
jdlrobson 64ee622c73 Validate the value of VectorWebABTestEnrollment
The generation of JavaScript will throw a RuntimeException
making it obvious when an invalid A/B test has been setup.

Bug: T297662
Change-Id: I75b0e923463bf52f8fc5b5c6b7f9baf586053154
2021-12-14 22:22:26 +00:00
jenkins-bot 1ceb673578 Merge "Move bundlesize test to MediaWikiIntegration test" 2021-12-10 19:55:16 +00:00
Kosta Harlan 6270246d44 Move bundlesize test to MediaWikiIntegration test
The main motivation is to reduce runtime by not invoking an unneeded
Selenium test phase in Quibble, which currently needs about 1 minute to
install npm dependencies.

Depends-On: Ieb7591f3c0ac843677a2a61b4ad47f920fc2ca2d
Bug: T255149
Change-Id: I0563421b3a3d3e6e81abec987c266ade275b47a1
2021-12-10 08:48:59 +01:00
vladshapik 262a520a2c Avoid using User::getOption
Remove using of User:getOption since this method
will be hard-deprecated. Now it is soft-deprecated.

Bug: T296083
Change-Id: I3194a9c1c5c70592f88bc4dbedc78846d1141768
2021-11-29 23:46:05 +00:00
jenkins-bot ed4ec0079a Merge "HTMLLegacySkinVersionField: accept string 'default' value" 2021-11-23 11:27:41 +00:00
MusikAnimal 5207a15b91 HTMLLegacySkinVersionField: accept string 'default' value
After I628435a4a, we were asserting a boolean was given because we're
extending HTMLFormField which requires a boolean value. This was safe
because GlobalPrefs would provide a boolean, but that changed with
I594f6297.

We could rework GlobalPrefs once again to ensure only a boolean is
passed in, but since HTMLLegacySkinVersionField already has special
handling around the data types, it seems to make sense to contain the
type transformation in this class.

Simply removing the Assertion is enough to prevent T296068, however
depending on when the global preference was saved (such as since MW
1.38.0-wmf.9 but before wmf.10), it's possible either a bool or a string
was saved, hence we check for both to ensure correct display.

Bug: T296068
Change-Id: If10b948617d2bb8346475f207fe425fb768cb987
2021-11-23 00:57:25 -05:00
Umherirrender 0c154bba36 build: Updating mediawiki/mediawiki-codesniffer to 38.0.0
Change-Id: Ic16a1f89fc5ccae3eddd31b1d566128e60592b90
2021-11-13 19:01:31 +01:00
Alexander Vorwerk e924b9b01c MediaWikiTestCase -> MediaWikiIntegrationTestCase
MediaWikiTestCase has been renamed to MediaWikiIntegrationTestCase in 1.34.

Bug: T293043
Change-Id: I9f8c1e134e9de9e7142ea18e2a9b903e6583cfdb
2021-10-12 01:10:33 +02:00
jdlrobson b88f2970f7 Simplify how we generate icons and button classes in Vector
- Separate icon classes from button classes in user links/language
- Upgrades the personal tools language button preference to
a mw-ui-button with icon
- Adds a generic selector for dropdown menus without an icon
- Cleans up user links CSS now mw-list-item class is available
- Removes icon hack CSS

Bug: T289630
Bug: T283757
Change-Id: Ib518858e06549f252d73d57fd4768f446cc561b9
2021-09-03 19:25:31 +00:00
Clare Ming 1efe0a4203 Remove user links feature flag
Update/remove config, constants, hooks, templates, styles, logic, tests, stories to check legacy vs modern Vector where applicable instead of the decommissioned user links feature flag.

Bug: T288852
Change-Id: I5c5831091a10711838a8a2877c782df4996d4596
2021-08-26 10:07:15 -06:00
jdlrobson c000fa9a2a Tests should use Universal hook
The existing hook does not allow modification of variants which
will soon change.

Bug: T287533
Change-Id: I8969296c64875d58e3c7ea95f6b567916f82d8a7
2021-07-28 11:07:42 -07:00
ZabeMath e7fbb01aca Avoid using User::setOption()
User::setOption() is deprecated and should be replaced with UserOptionsManager::setOption()

Bug: T277818
Change-Id: If867b4f97918db581d337a32b33cbca2315a71f6
2021-07-18 13:48:44 +02:00
Clare Ming cb3d5742da Add querystring parameter override for user links, language in header.
- 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
2021-07-15 16:51:48 +00:00
jdlrobson 3dffee277c Refactor the way we add classes to list items
Append mw-ui-icon classes to list item not list link
This allows us to apply a custom padding separate from the icon.

Note due to a bug in how core handles personal user items,
this will result in the icons temporarily disappearing for several
items until If399dfff9bbdd3b03b2ca702face3ec5164bef11 is resolved.
This is okay given the user menu is currently feature flagged.

Bug: T191021
Change-Id: I766aeb4d1bb36cebd0d80ad43ced940dbea96477
2021-07-01 14:25:46 -07:00
Jdlrobson 604e24f6be Partial Revert "Update tests for default Menu template value"
This partially reverts commit 0fc7be61c1.

Reason for revert: was temporary change

Change-Id: Iad87da825e44a7d3a64b85dc314d8eb27d95b7a6
2021-06-21 20:20:34 +00:00
bwang 0fc7be61c1 Update tests for default Menu template value
Change-Id: I32586a379cbacaad5cfb361facf79c01e982818a
2021-06-15 17:02:53 -05:00
Thiemo Kreuz 9213c514e6 Remove not needed $this->equalTo() from tests
This is the default anyway. I believe the tests are much more
readable without this.

Change-Id: I9f6c0d777ae5cd184acf40b1ef5b7b171dc3e675
2021-05-17 10:05:10 +02:00
jdlrobson 6998c536d4 Both UserMenu stylesheets should be shipped in modern
Since we have feature flagged the new user menu feature, it is
imperative we load both sets of styles until the feature has
shipped. This allows us to switch seamlessly between the two
without worrying about cached HTML being served with updated CSS.

To do this, we add a new class to both user menu's distinguishing
the legacy version from the modern version. The styles are then
scoped to these new selectors.

This also fixes some regressions with the legacy user menu in
modern Vector when wgVectorConsolidateUserLinks is disabled.

Notes:
* No caching selector is needed for #pt-userpage given it can only
ever be output for logged in users.
* ID selectors in general are bad, so scoping to mw-portlet-personal-user-menu-legacy
isolates the legacy component allowing it to be rendered alongside the modern UserMenu

Bug: T276561
Change-Id: I068c5233bb25a7b141e66a6726b5761841f83eb2
2021-05-14 10:13:09 -07:00
Nicholas Ray de5a640c0b Allow `languageinheader` query param to fully control treatment of languages
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
2021-05-13 12:04:12 -06:00
Nicholas Ray 49f2b25737 Create A/B test harness for Language in header feature
* 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
2021-05-04 14:41:53 -06:00
libraryupgrader 932c8d541e build: Updating composer dependencies
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

Change-Id: Ib71722afb42c300ec3d6a3cd3bfab7eddde18bdf
2021-05-04 12:41:27 +00:00
DannyS712 7dfec540ec Clean up VectorHooksTest
Fix order of parameters in assertions.
Remove unneeded "\".
Make constant a class constant.

Change-Id: If372dec96b54d466a066163420c6fd9da177c66c
2021-03-27 02:25:22 +00:00
jenkins-bot 991e4b0587 Merge "build: Updating eslint-config-wikimedia to 0.19.0" 2021-03-15 18:47:37 +00:00
libraryupgrader f01df6f803 build: Updating eslint-config-wikimedia to 0.19.0
The following rules are failing and were disabled:
* compat/compat

Additional changes:
* eslint: Renamed `wikimedia/client` profile to `client-es5` (T277085).

Change-Id: I12c1a88cef8e2c95bed496628d2fe74d031f8278
2021-03-15 04:57:07 +00:00
DannyS712 568dbebd47 tests: clean up requirements tests
Convert to unit tests, no integration needed
Use data providers

Change-Id: Ife758952b6bf8a046eddf4bdc478437564f0bc22
2021-03-10 14:45:24 +00:00
Nicholas Ray e3abac06a6 Add mw-interlanguage-selector class to language button & hide menu/arrow when appropriate
* We add the `.mw-interlanguage-selector` class to the
.vector-menu-heading in the server rendered HTML. `ext.uls.interface.js`
later attaches a click handler to this selector that loads the rest of
ULS.

* We hide the dropdown arrow for js users and only show it again if
ext.uls.interface module isn't installed or is not being loaded.

* When the `ext.uls.interface` module has been loaded, we hide the checkbox
and checkbox hack menu in favor of showing the ULS popover.

Additionally:

* Adds '.vector-menu-heading' class to menu headings.

* Change h3 selector to `.vector-menu-heading`.

Bug: T273232
Change-Id: I6f4572c16ca4096dcda3aac4d585003b93dcccfa
2021-02-05 15:03:07 -07:00
Nicholas Ray 8c76a17e43 Move Wvui Search A/B Logic to FeatureManager
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
2021-01-26 17:36:37 -07:00
jdlrobson 05dc15954d Allow more control over the max-width rules
Bug: T260091
Change-Id: Ie534b0c34e240c588a4cc330898531f1d12df1f0
2021-01-21 18:51:12 +00:00
mainframe98 12ef2258c3 Don't blindly overwrite contentnavigation
Caused a failure in Ia1451e3e802441162eecfc5b7f6a7ba2ae72f377.

Change-Id: Ib4112364c173952eb363e52756f03693a2e03512
2021-01-10 19:25:12 +01:00
jdlrobson 9f1a1fa829 Simplify menu code
SkinMustache in core provides most of what is required for Vector to
generate its menus.  In the interest of having a canonical source of
truth for menus across all skins, Vector should use this data.

To ensure the HTML generated is (mostly) the same after this patch to
prior, a few modifications are necessary:

* The data from core is decorated so that Vector can continue having its
  own custom class names on menus. This is done using the
  decoratePortletClass method.
* There is no support for a menu having a header representing the
  selected menu item, as is currently the case with variants. This is
  achieved via an extension to getPortletData. It's assumed that later
  when variants are merged with languages, this can be removed.
* Menus are agnostic to how they are displayed, so we must continue to
  add the is-dropdown template variable to drop down menus. In future we
  may want to rethink our Menu partial to make this unnecessary in PHP.
* The portal-first class is redundant in the modern Vector as we can
  use the first-child selector. Previously we introduced a class to
  service the legacy skin where this rule doesn't apply as #p-logo is
  the first child.  However, the legacy skin can do this using a special
  next sibling selector instead.

Bug: T268157
Change-Id: I5f7adc1840441b508ffee40139b85b64021789e6
2021-01-04 19:02:34 +00:00
James D. Forrester 5ef1ddb733 Use User->isRegistered(), not deprecated isLoggedIn()
Bug: T270450
Change-Id: If385757d64664eba148914063fbbe88f72b66fdc
2020-12-19 16:44:06 +00:00
jdlrobson eda19bd6e4 Remove SearchInHeader requirement/feature
Styles will be cleaned up further in a follow up.

Bug: T258116
Change-Id: I878239a85ffbecb5e78d73aed5568c56dbd7d659
2020-10-28 20:05:28 +00:00
jdlrobson 89fee04f0b Drop unsupported skin CSS classes
Drop support for vectorMenu, vectorTabs and
vectorMenuCheckbox, body, menu selectors in preference
for standard selectors.

This change will impact a large amount of user scripts/styles but should
not impact any gadgets.

These classes were kept around for user scripts and styles however are not
needed internally. As we transition to a more maintainable skin menu
system, it is time to lose these selectors even though this will cause
disruption.

Vector now will use the mw-portlet class rather than the vector-menu
class in its own CSS styling, however it keeps the other classes to
allow differentiation of the different types of menu.

Changes to test: Previously the tests assumed all portlets were empty
when checking the classes. This is very rare, so its better to check
the classes of non-empty portlets, so several tests are updated
accordingly to drop the emptyPortlet class.

Bug: T262092
Change-Id: I1824335eb47d613c2a4804ec1f1106c0f4c16101
2020-10-01 19:50:24 +00:00
jdlrobson 711a41812a Use newly available Skin::getPortletData method to get mw-portlet class
Kept as simple as possible for now. The new class is added but no classes
are removed. This will be done in a follow up.

Bug: T256897
Bug: T253938
Change-Id: Ib31a9d8f2ac14e63b63e82abd4a9aa1fcb956f45
2020-09-29 00:09:26 +00:00
jdlrobson dbf5d7084a Tests: `name` option is now required
Since SkinVector provides name via skin.json the name must be
passed in the test constructor.

This will be required as part of
I5772eb760e4fc56d2062a333ba4d7ca6995f3db2

Change-Id: I4087deb8b0726c9959ac15d77a0ed2442e4890f6
2020-09-18 08:55:45 -07:00
Nikki Nikkhoui da158807b6 Use setTemporaryHook() in SkinVectorTest
The MediaWikiIntegrationTestCase::setTemporaryHook() function was
recently updated in https://gerrit.wikimedia.org/r/c/mediawiki/core/+/622400
to work with the new hook system. Use the new function in Vector tests, as
some extensions that use the new Hooks system are failing to pass the Vector
tests that run in their Jenkins CI tests
(https://gerrit.wikimedia.org/r/c/mediawiki/extensions/examples/+/603569).

Bug: T254381
Change-Id: If8289b2bf47a35140e2fef72234ffad7aae37c90
2020-09-16 23:17:07 +00:00
jdlrobson 7449c7fdf6 A/B test of search in header for logged in users
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
2020-09-14 14:22:46 +01:00
DannyS712 837f529177 Fix order of expected/actual in SkinVectorTest
* expected is the first parameter not the second.

Change-Id: I825b10154ab59a754cdce400a4a0aa273747ae15
2020-09-11 16:29:08 +00:00
Sam Smith 4449235516 [Special:Preferences] [PHP] Add HTMLSkinVersionField form field
I177dad88 introduced the skin version user preference field and
associated configuration values. Per T242381, the field is to presented
as a checkbox with the implied storage type of a boolean where a string
is needed. A PreferencesFormPreSave hook handler was added to adapt
values of either data type to the other.  While this was a neat solution
to a minor nit, the adapter's implementation is incompatible with the
GlobalPreferences extension as the PreferencesFormPreSave hook isn't run
whilst saving global preferences.

Rather than adding an equivalent hook to the GlobalPreferences
extension, create a custom field based on a checkbox with the adapter
included. This allows us to:

- Separate the business logic concerned with preserving the user's
  VectorSkinVersion preference if they've simply disabled Vector from
  the adapter

- Simplify the adapter's implementation

- Forego adding hooks to the GlobalPreferences codebase

Additional changes:

- Replace repeated string literals with equivalent constants in
  tests/phpunit/integration/VectorHooksTest.php

Bug: T258493
Change-Id: I628435a4ad676f55534191b8c10147be28be5d73
2020-08-31 12:04:12 -07:00
jdlrobson e7df44a66d Favor SkinTemplateNavigation::Universal
This hook is run on every page. The SkinTemplateNavigation hook
counter intutively is run only on pages which can exist. I think
it's clearer if we only use SkinTemplateNavigation::Universal hook
and keep the logic for when it runs inside our own code.

Bug: T255319
Change-Id: I0835074a6cadf6e9bdcc45299de37dd9328bf9b2
2020-08-20 16:01:27 +00:00
Sam Smith b46751d4ed hooks: Don't use SkinVersionLookup directly
The feature manager abstracts away how a feature is enabled from the
consumer of that feature. Accordingly, replace direct instantiation of
SkinVersionLookup with usage of the Vector.FeatureManager service.

Supporting changes:

- Add Vector\VectorServices, a simple wrapper around
  MediaWiki\MediaWikiServices that allows us to both document and
  type-hint services specific to Vector

- Add Vector\Hooks::isSkinVersionLegacy to minimise repetition

Additional changes:

- Make the MakeGlobalVariablesScript hook handler return early if the
  user isn't using the Vector skin like the other hook handlers

Bug: T256100
Change-Id: I93b5ef39802323c7ac658af8fa7cc312fff68aa7
2020-08-18 11:40:48 +01:00
jdlrobson ed7fd252cd Refactor: Replace PHP complexity with JS simplicity
In PHP we add collapsible classes to all elements except watchstar
so that certain tabs can be collapsed under the more menu in JS.
This adds unnecessary complexity to our codebase and is not used
if JS is disabled.

To simplify this and bring Vector's PHP consistency with core this
logic is moved to JavaScript.

Bug: T259372
Change-Id: I2acbf7089198118626368ee8a37615d2de062f83
2020-07-31 22:15:08 +00:00
jdlrobson 2c74f08d3e Merge SkinVector and VectorTemplate (step 2/2)
Rename SkinTemplateVector to restore SkinVector

Bug: T251212
Change-Id: I7e06a4cc226f3434c0f655212a464b8b98bcc7f4
2020-07-30 12:20:13 -07:00
jdlrobson ee6974ad35 Merge SkinVector and VectorTemplate (step 1/2)
Please note I7e06a4cc226f3434c0f655212a464b8b98bcc7f4 should be
merged at the same time as this patch.

== The background ==
All extensions have been weaned of BaseTemplate hooks in
Wikimedia projects.

This change now means that Vector will no longer run
any BaseTemplate hooks. See the epic T253809 for the
implementation details.

== The change ==
BaseTemplate will now have nothing to do with the rendering of
Vector. The skin version is added to express the significance of
breaking compatibility with 3rd party extensions.

We TEMPORARILY remove SkinVector to retain git blame. SkinTemplateVector will
be renamed SkinVector in the follow up (see 2/2)
Update skin.json to use SkinTemplateVector for the skin (this will be fixed
in a follow up).

The isLegacy method is moved to SkinTemplateVector.

Changes of note:
* html-debuglog is no longer needed. SkinMustache includes this information on
the skins behalf
* html-printtail and html-headelement are now not needed in the master template
and added by SkinMustache
* Skin::getAfterPortlet does not provide the `after-portlet` wrapping element provided
by BaseTemplate::getAfterPortlet so this is added
* SkinTemplate::getFooterIcons does not support the options that BaseTemplate::getFooterIcons
does so any icons which do not have an image must be manually checked for and unset

Known changes to HTML output as a result of intentionally
delegating their output to the core SkinMustache class:
* A new line is removed between the body element and #mw-page-base
* #mw-html-debug-log now appears at the end of the body element
* #printfooter is now a child of #mw-content-text rather than sibling.

Bug: T251212
Change-Id: I4e89beb96f6401ed7e51bafdf0aac408f5a2c42f
2020-07-30 11:18:45 -07:00
Jan Drewniak 1fac82f895 Sidebar persistence for logged-in users in modern Vector.
- Creates a new user-preference called 'VectorSidebarVisible'
which stores the sidebar hidden/collapsed state for logged-in
users.
- Updates that user-preference on the client whenever the sidebar
is expanded or collapsed.
- Refactors the sidebar related javascript into a separate file.

Bug: T255727
Change-Id: Ib1ce934f3646cd8feebf0d3b15c38b5b969ec957
2020-07-09 00:28:52 +02:00
Ed Sanders 36e91dc04f build: Update devDependencies
Applies new ESLint documentation rules

Change-Id: I7fe458cf52e98baf92f3baec2d9ff54484326673
2020-07-01 14:43:39 -07:00
jenkins-bot b577f8b73c Merge "Add bundlesize test for ResourceLoader modules." 2020-06-11 20:14:48 +00:00
Jan Drewniak a3acacc1a4 Add bundlesize test for ResourceLoader modules.
Adds a bundlesize test that measures the bytesize of
individual ResourceLoader modules.
This test depends on a running mediawiki instance as well as
the $MW_SERVER and $MW_SCRIPT_PATH environment variables.

ResourceLoader modules are fetched from a URL and piped
into a bundlesize command based on a custom configuration file.

The test can be run with `npm run test:size`.

Bug: T244276
Change-Id: I4f4534921ccbc6bd4f99229c8dd36b1279dde640
2020-06-11 19:51:20 +02:00
jdlrobson 6022b032ea Avoid using `get` indirection in VectorTemplate
Begin our journey away from BaseTemplate by
moving VectorTemplate code to SkinVector. In future all
methods will live here but to lower risk, I've only targetted
the get method.

Bug: T251212
Change-Id: I58c2ff5edaacc2d5e45492c121cf0f87d08b623f
2020-06-03 17:53:13 +00:00