Commit Graph

684 Commits

Author SHA1 Message Date
jenkins-bot dafe3c8fd4 Merge "Handle accessible labels differently for dropdown and portal menus" 2022-05-24 15:09:04 +00:00
Mo Abualruz e46eef19d0 Normalise PHP namespaces used in Vector
- `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
2022-05-23 09:32:40 +02:00
Jon Robson d74890df63 [Grid preparation] Add feature flag for grid
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
2022-05-13 15:21:52 +00:00
bwang 9e665f9034 Handle accessible labels differently for dropdown and portal menus
An issue was found in QA where certain browser/screenreader combos could not read `aria-labelledby`+`aria-label`. Instead, we avoid using `aria-labelledby` and the `label` element entirely and apply the accessible label directly to the `input`. This great simplifies our labelling and improves screenreader support, while also allowing us to hide the `label` element to reduce verbosity.
Because the `label` element is used differently in the portal menu, we use the `is-portal` variable to maintain the old markup for portal menus

Bug: T301051
Change-Id: I5a0f7d5d78838fabe561095b33176e7162b31aea
2022-05-12 22:11:22 +00:00
Jon Robson 78369c51d3 Omit ArticleToolbar in Navigation when title above tabs
Change-Id: Ib3d9c28e4dbbf1deb85adccec84f208f086c1a04
2022-05-12 11:04:10 -07:00
jenkins-bot ef42ef7e66 Merge "Create feature flag for VectorTitleAboveTabs feature" 2022-05-11 19:53:11 +00:00
jenkins-bot 8d1dbab356 Merge "Simplify TOC spacing styles/logic by reusing the visible sticky header class" 2022-05-10 22:18:26 +00:00
bwang 2f32d1378c Fix personal tools navigation landmark label
Bug: T291304
Change-Id: I62c24cf739048b794cc33045cbe2333ecb51efdb
2022-05-10 17:12:46 +00:00
Jan Drewniak 29d938b0f9 Create feature flag for VectorTitleAboveTabs feature
Adds a feature called VectorTitleAboveTabs that will be used to
toggle a forthcoming feature that moves the page title above the
tabs (the ones that link to talk/history etc).

Bug: T303549
Change-Id: Ibadb4293eca16a83e5e7a9f90ddcf51fab0a0e41
2022-05-10 12:53:31 -04:00
bwang 91e2e55a10 Simplify TOC spacing styles/logic by reusing the visible sticky header class
- Remove the 'vector-scrolled-below-table-of-contents' class, reducing the number of classes added with JS and simplifying the scrollObserver logic
- Move the 'vector-sticky-header-visible' class from the sticky header element to the body element. Hopefully, this is where other feature specific classes can go in the future
- This approach means the TOC will not need JS to update it's spacing when the sticky header is not enabled

Bug: T307345
Change-Id: I1084defc7025f5c946e22a36d373224fae6f8bd6
2022-05-10 11:39:05 -05:00
jenkins-bot b6847038f8 Merge "[HTML] Refactor Content header templates" 2022-05-06 18:43:34 +00:00
Jan Drewniak 1288c97179 [HTML] Refactor Content header templates
Creates two new templates:
- ContentHeader.mustache containing the site header and indicators or languages
- ContentSubheader.mustache containing site tagline and conditionally indicators

This changes DOM order.
- It adds the `<header class="mw-body-header">` to all pages,
  including special pages & edit pages, not just pages with the language button.
- It moves the #siteSub element (tagline) outside of the
  `<div id="bodyContent">` element.
- Adds a clearfix (or margin-collapse fix) to `.vector-body`.

This changes causes a minor difference (perhaps improvement) where on special pages,
the beginning of the content, starting with the `mw-specialpage-summary` element,
was positioned closer to the page title than on regular pages.

The clearfix ensures that the height between the page title and content is consistent across all pages.

Bug: T303549
Change-Id: I29ba337dbd6f9b0cf58c9a0ca517a9ba59cef414
2022-05-06 15:37:04 +00:00
Jon Robson 305fbdacf8 [Grid preparation] ArticleToolbar component
Structural change to prepare for CSS grid usage.
ArticleToolbar component is defined and self contained with
all layout rules relating to toolbar

UI regression testing suite shows 6 failures due to pixel alignment
changes to tabs. When comparing to the current release, you should
see 34 failures before /and/ after this change.

Notable changes:
- #mw-head element is no longer present in modern Vector skin
to allow us to distinguish between cached HTML and modern HTML

Bug: T303484
Change-Id: Ia261ea53931217f32a21b33c2ab3d4ec64efa48a
2022-05-05 21:13:01 +00:00
Jon Robson 9a2b3d6275 [Grid preparation] Structure the header
Restructure the header to have two child elements

Change-Id: Ib5b7f31419ae6b62f62878947651b8ab843a3955
2022-05-05 17:54:28 +00:00
jenkins-bot ff3d879ee2 Merge "Remove nav element from Vector menus and only render label elements in Vector menus when needed. Add new nav landmarks corresponding to user links, main site nav, and article editing tools. Split out legacy Menu template." 2022-05-03 15:42:02 +00:00
Jon Robson a1e5fd5fcc On special page do not show empty more menu to low resolutions
This is a follow up to I34ace0aeb3e23d8f6a8c5a8680bb492f37e343ad
On Special:Userlogin a "more" menu appears that's visible but empty
that should not

 Bug: T306229
Change-Id: I9384b3015de9991db41bde8ccc8f404ac533f198
2022-05-02 20:22:44 +00:00
Tim Starling 8d0659b1e6 Updates for core temp user autocreation feature
* Use pt-tmpuserpage for the temp user name.
* Use the userAnonymous icon for the temp user personal tools menu.
* Suppress the logout menu item for temp users.

Depends-On: Ib14a352490fc42039106523118e8d021844e3dfb
Bug: T300263
Change-Id: I8ac5de82f76a9ec58b0fbef85546bc7fd5b793d2
2022-04-28 20:32:53 +00:00
Jon Robson 64df4fde20 Remove dancing tabs with CSS only solution
Remove JavaScript that collapses tabs and replace with an easier
to maintain breakpoint based solution.

Tabs will now collapse below the tablet breakpoint

Note: In the case of mw.util.addPortletLink, to add items to the
`views` menu, these will not be collapsed into the more menu and
must now be explicitly added to both menus, ie. if the window is
resized these will hide and not appear in the more menu.

However, when mw.util.addPortletLink attempts to add to `views` menu
when there is not available space, we will redirect those links to
the more (`cactions`) dropdown menu.

Bug: T306229
Change-Id: I34ace0aeb3e23d8f6a8c5a8680bb492f37e343ad
2022-04-28 17:57:10 +00:00
bwang d54029a523 Remove nav element from Vector menus and only render label elements in Vector menus when needed. Add new nav landmarks corresponding to user links, main site nav, and article editing tools. Split out legacy Menu template.
Bug: T291304
Bug: T301051
Change-Id: I35c20103e4b45139ef1d3f73c23f6a744aa87a3c
2022-04-27 16:52:20 +00:00
Derick A 80b60c153a
Hooks: Migrate Vector skin hooks to the new MediaWiki hook system
Per https://www.mediawiki.org/wiki/Manual:Hooks#Handling_hooks_in_MediaWiki_1.35_and_later,
MediaWiki provides a new hook system. Vector is able to utilize this new
hook system because it requires a MW version >= 1.35, hence the migration.

Bug: T271009
Change-Id: I6e01b151751485339a0d6a6dc6a843f7141d54bb
2022-04-26 23:58:13 +01:00
jenkins-bot cdc2df8e66 Merge "Always collapse Echo alert on "wide" headers" 2022-04-20 16:39:12 +00:00
jenkins-bot ff4a1ba89c Merge "Replace h2 in TOC with p and remove aria-hidden" 2022-04-19 21:04:20 +00:00
Jon Robson 5ef40f2f73 Always collapse Echo alert on "wide" headers
Bug: T301583
Change-Id: Ib4baab3ab814a79f45d8d19cfe4e499307852d52
2022-04-19 21:02:54 +00:00
jenkins-bot 065f3409b5 Merge "Replace Action::getActionName by IContextSource::getActionName" 2022-04-19 18:11:25 +00:00
bwang 9473758efd Replace h2 in TOC with p and remove aria-hidden
Ideally the TOC has an h2 after the article title h1, but because of the TOC sticky positioning and its placement in the grid, we cant use an h2 without messing up the heading order.

Bug: T301051
Change-Id: I462ddfb618ddd422c9f71293280d1790c4846f50
2022-04-19 17:51:36 +00:00
Umherirrender d0ac534749 Replace Action::getActionName by IContextSource::getActionName
Change-Id: I41bb15527e5ff9296a53205608c596291d485876
2022-04-19 10:46:48 +02:00
jenkins-bot 7565486e09 Merge "Restore persistent sidebar" 2022-04-18 21:47:34 +00:00
Mortal303 8b51041003 Move Vector menu class logic into Menu mustache template
Replaced “vector-menu-heading” with ‘’(empty string) in “$portletData['heading-class'] = '';”
in includes/SkinVector.php and updated accordingly the includes/templates/Menu.mustache file.
Updated “vector-menu-heading” with ‘’(empty string) in stories/LanguageButton.stories.data.js,
stories/UserLinks.stories.data.js, and tests/phpunit/integration/SkinVectorTest.php respectively
SkinVector and Storybook are cleaned up.

Bug: T290281
Change-Id: I4ca16953799b3dc52e45674bb398c78f14cfc842
2022-04-18 15:18:53 -05:00
Jon Robson f38a2afbf6 Restore persistent sidebar
Bug: T305989
Change-Id: I1304c777ad9581cd8b9153ad1e4483e31660857e
2022-04-18 19:44:11 +00:00
bwang 282fe1aa51 Fix missing create account link follow up
Follow up to 58b6831

Bug: T306116
Change-Id: I2989657f871b0a312e68c4af7757029b0c9c9f24
2022-04-15 18:57:14 +00:00
bwang 58b6831e4d Rely on core to provide accesskey/title attributes, update search toggle location in DOM
Bug: T299980
Depends-on: Ide214de5f246b38689799e20db9e8a4671d9b7ac
Change-Id: I43eb04ec095cc9c1d683df9da05887595c2eddfb
2022-04-14 13:53:07 -07:00
bwang 21f124dad5 Fix missing create account link icon and ensure icon attributes aren't showing up in rendered HTML
Bug: T306116
Depends-on: I509dd153ea2c1e04cb89415f185b7abbe0403773
Change-Id: Iaea83098fda7d77fda6629722dcef3e17e21fe06
2022-04-14 11:03:56 -05:00
Clare Ming 28a3c06cdf Replace TOC arrow icon
Bug: T304166
Change-Id: I182c9e5399d95ecea58dcdabb563a98b4e34e47e
2022-04-11 14:56:42 -06:00
Jon Robson 9f6295426f Prepare for grid layout
Add a legacy class to allow us to transition out certain CSS
with new grid system

Bug: T303484
Change-Id: Ie85451b721b64aee42eb4b356f38c3621ce40b5e
2022-04-11 18:12:43 +00:00
jenkins-bot 107abe79a0 Merge "Scope ULS styles to when language button is in header" 2022-04-09 00:07:09 +00:00
Jon Robson 3432cf2c80 Only consider article ID if A/B test enabled
The article ID shouldn't matter for display of table of contents
unless the A/B test is enabled.

This also has the added benefit of making the content provider
work with table of contents on articles again (content provider articles
always have a page id of 0)

Change-Id: I6af5e1476827828d0974ecbb110476ac1e5dc0c9
2022-04-08 20:04:24 +00:00
bwang 40045c6e0e Scope ULS styles to when language button is in header
Bug: T304468
Change-Id: Iebacb6a7bf3412a6ee76eb5c9fdb9471c02dd16c
2022-04-07 14:47:44 -05:00
jenkins-bot 1e75d6f373 Merge "Clean up unused constants and outdated comments" 2022-04-07 18:19:28 +00:00
jenkins-bot 125a8641e5 Merge "Prepare Vector for temporary user accounts" 2022-04-07 17:35:15 +00:00
jenkins-bot 6fc95b72ba Merge "Drop the Vector.Config service" 2022-04-07 16:54:01 +00:00
Func 12c7d6a0ca Clean up unused constants and outdated comments
Change-Id: If6462e3a67726234abe62fd4d02a5d19ff4f02e0
2022-04-07 16:10:52 +00:00
Func b61a92f052 Drop the Vector.Config service
It didn't vary by the skin version as documented in the Constants class,
and merely another instance of GlobalVarConfig.

Change-Id: I0acd0366a241e04bb79f6aae5dc52284dfa578df
2022-04-07 04:30:20 +00:00
bwang f1c70e99b7 Update sticky header to use ARIA attributes for section collapsing and add accessible label to toggle buttons
Bug: T303766
Change-Id: Idda4f286a42152af1d233588a1839ada5491ce95
2022-04-06 17:24:34 -05:00
bwang aa8ec1a878 Revert unnecessary TOC section id change
Change-Id: I62736b47557b79929b8ad984d6709e762b3db549
2022-04-05 15:38:00 -05:00
Nicholas Ray 6fbf08a198 Build A/B test bucketing infrastructure for the table of contents.
* Bucket and sample on server by using the
  `WikimediaEvents.WebABTestArticleIdFactory` service from
  WikimediaEvents (soft dependency)
* Add linkHijack.js so that users bucketed in one group have the
  possibility of remaining in that group if they click a link to another
  page.

Bug: T302046
Depends-On: Ie6627de98effb3d37a3bedda5023d08af319837f
Change-Id: Iff231a976c473217b0fa4da1aa9a8d1c2a1a19f2
2022-04-04 17:06:29 -06:00
jenkins-bot 19f114281a Merge "Drop the LatestSkinVersionRequirement" 2022-04-04 20:18:35 +00:00
Jon Robson 7e3d0828d5 Prepare Vector for temporary user accounts
Bug: T300263
Change-Id: I603b232da338655e54f372bec5df68dd96adfb2e
2022-04-04 19:45:14 +00:00
Jon Robson eca9fcbf79 Drop the LatestSkinVersionRequirement
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
2022-04-04 19:22:38 +00:00
bwang 733990f881 Small clean up and TOC update
Change-Id: Ic093888cb2b06d8eef95a1317d791e7e1627d0f6
2022-04-01 13:14:02 -05:00
Tim Starling 254ffbb55a Don't set a user preference on new accounts by default
Make it possible for Vector to be a non-default skin. Only set a user
preference on newly created accounts if that has been explicitly
requested in config.

This should have no effect on WMF production.

Change-Id: I52f62cf7eb78d2be4c59821a3cf29da9619602d9
2022-03-31 14:52:20 +11:00
jenkins-bot 530658f160 Merge "Enable table of contents on all namespaces" 2022-03-29 21:34:18 +00:00
Reedy 0d5e2d184e Drop SkinVector global class alias
Change-Id: I0e35a3c88aced671ef23318bf3970f7f3f261f6a
2022-03-29 17:32:39 +01:00
Clare Ming 1d574b86f1 Add fade to indicate scrollability in TOC
Bug: T302076
Change-Id: Ib803239602333e2a8232a26a10477a0f9933b819
2022-03-28 15:58:26 -06:00
jenkins-bot cd04b72058 Merge "Table of contents links to beginning of article" 2022-03-24 23:51:52 +00:00
Jon Robson dfdf72140c Table of contents links to beginning of article
Bug: T301254
Change-Id: Icb0b0646f81c1070c8f47dd3297225a074f74773
2022-03-24 20:46:35 +00:00
Jon Robson 56164a4275 Enable table of contents on all namespaces
Bug: T304168
Change-Id: Ib61f801640e77c34573c166072f0fb302687e8b1
2022-03-24 08:56:13 -07:00
jenkins-bot 1b8ee10357 Merge "Add data-event-name attributes to legacy and sidebar TOC" 2022-03-23 22:00:45 +00:00
Jon Robson b109e10cf3 End migration mode
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
2022-03-23 16:46:42 +00:00
bwang ac54984d75 Add data-event-name attributes to legacy and sidebar TOC
Bug: T302934
Depends-on: I5ef98d5f5713d3d99bc5f7f8112ba2d1e0f62e22
Change-Id: I5806c346abf0375c85248659c636ae3b2d73f661
2022-03-21 22:32:56 +00:00
jenkins-bot eb0e05dff1 Merge "Address some code FIXMEs" 2022-03-21 21:15:49 +00:00
jenkins-bot 1a2197f27d Merge "Make sure label text is not selectable" 2022-03-21 21:06:29 +00:00
Jon Robson b86dbc756c Address some code FIXMEs
- Remove references to the removed wgVectorUseWvuiSearch
configuration
- Remove mw-body qualifier on Indicators component.
- Drops some cache related FIXMEs

Change-Id: I6823b9c5bf19a067b56badf29f874a7127867a09
2022-03-21 20:29:58 +00:00
jenkins-bot 08efa139be Merge "Remove custom handling of aria-expanded in Vector checkbox hack buttons" 2022-03-21 18:03:14 +00:00
Mortal303 ae50914d4e Remove custom handling of aria-expanded in Vector checkbox hack buttons
Removed class "vector-menu-checkbox-expanded" and "vector-menu-checkbox-collapsed" in
includes/templates/Menu.mustache and deleted the necessary lines in
resources/common/components/MenuDropdown.less, tests/jest/stickyHeader.test.js,
includes/templates/skin.mustache, skin.json, i18n/en.json and i18n/qqq.json.

Bug: T299173
Change-Id: Ibf8a08e6e5d1a6c607abf170c030a0285e84ad74
2022-03-21 23:14:51 +05:30
dylsss 78fcf8e1ea Make sure label text is not selectable
The label text must be enclosed in a span tag in order for it to inherit the rules here: https://gerrit.wikimedia.org/g/mediawiki/core/+/master/resources/src/mediawiki.ui.button/button.less#36

Bug: T296129
Change-Id: I8782a4745704d07fad7ba44c56c476973be90f60
2022-03-21 00:01:06 +00:00
Jon Robson f3f777818c Never show an empty table of contents
This doesn't seem to have got updated when we revised the data format
in T299065.

Bug: T303860
Change-Id: Ib955950e014668fe434da4a1654e977eb43f7dd8
2022-03-17 22:24:24 +00:00
jenkins-bot 1d2e4dda6c Merge "[i18n] Table of contents heading" 2022-03-16 23:40:43 +00:00
bwang 2567e48f64 Fix updateUserLinksDropdownItems not being called
Bug: T304002
Change-Id: Idc9cd3a324f48d2c48243b5011d1559839789539
2022-03-16 22:07:57 +00:00
Jon Robson 6855979a92 [i18n] Table of contents heading
Should be translateable

Change-Id: I3c4515f16b5300a44f89ebdcd426a9d8ac6ad138
2022-03-16 17:18:51 +00:00
bwang 2511e35837 Refactor user links functions in Hooks.php to increase test coverage
Change-Id: I8fbf5cdf111dbb1ec06e5e74056ffdef77f77f22
2022-03-11 21:53:06 +00:00
jenkins-bot 61e2e0fbd8 Merge "Add support for icons not prefixed with `wikimedia-`." 2022-03-08 16:26:06 +00:00
bwang a1afa7ccb3 Ensure watchlist in user menu dropdown has the collapsible class
Bug: T302084
Change-Id: I27d7c0e46ee809185133fd787fc0c6fa5fcdac2e
2022-03-07 23:12:49 +00:00
Jon Robson 35721398b2 Add support for icons not prefixed with `wikimedia-`.
Needed for I0226892b2047e55d336c085c173e04a6fb4ecfa5

Bug: T257143
Change-Id: Ia24ac074aea329293c443c772229a0d5ac7246f9
2022-03-07 21:56:53 +00:00
Reedy 1dcfe80ac3 Namespace SkinVector* PHP classes
Namespaceless class aliases are left behind for migration purposes.

They can be removed at a later date when dependant extensions
and skins are fully updated.

Bug: T301204
Change-Id: I2b37c1889ff862ec8bb41325fc9f654c673cd115
2022-03-04 13:30:21 +00:00
Jon Robson a0d399b1e2 Unset data-toc in SkinVector
Bug: T302461
Change-Id: I61cf5d3c9016d5997ae56ba18c5eb877e9f68d91
2022-03-03 11:00:10 -08:00
jenkins-bot 288c8b95b2 Merge "Update Vector menu CSS to use `vector-menu-heading` instead of `h3`" 2022-03-02 19:21:10 +00:00
Mortal303 ab11cc9adb Update Vector menu CSS to use `vector-menu-heading` instead of `h3`
Replaced h3 tag in includes/templates/Menu.mustache with label tag.
Replaced h3 elements in .storybook/icons.less, resources/common/components/Menu.less,
resources/common/components/MenuDropdown.less, resources/common/components/MenuPortal.less,
resources/common/components/MenuTabs.less,resources/skins.vector.styles.legacy/components/MenuDropdown.less,
resources/skins.vector.styles/components/UserLinks.less, resources/skins.vector.styles.legacy/components/Sidebar.less
and resources/skins.vector.styles.legacy/layouts/screen.less
by vector-menu-heading.

Bug: T290280
Change-Id: I6eee7d6bc47c74a62166d4579fd4d3da3dc88e88
2022-03-02 20:05:36 +05:30
Clare Ming 338e0e72ac Fix language alert regression
- Add test for SkinVector::shouldLanguageAlertBeInSidebar() method.
- Change some methods to protected status -- acknowledging this is not
an optimal change. Until we can pull out some of the language checks
into its own class with injected dependencies (title, feature manager,
languages), this is an interim solution to try to catch regressions
since the conditional states for showing the alert are complex and
ultimately temporary. Extracting the language checks into their own
class can be done in a follow up ticket to help optimize testing
language checks in isolation.

Bug: T302018
Change-Id: I99b7df3029e0af86e4d67b3f446d4ce99260d33e
2022-03-01 15:37:43 -07:00
jenkins-bot 98bc2ee412 Merge "Switch order of sidebar menu and article toolbar in DOM" 2022-02-23 16:39:20 +00:00
bwang 5f0c0cb294 Use TOC template data for showing collapsible section arrows
Bug: T299361
Depends-on: I8ab5c0543b898d1df9399a1cb39672c45daf2acd
Change-Id: Ib68de8cd97cc1111a5a33e100e688d6832fc7e6e
2022-02-22 15:47:23 -06:00
bwang e9d2f5e37f Switch order of sidebar menu and article toolbar in DOM
In order to make the TOC go below the sidebar menu, we must reorder the sidebar menu to be directly before the sticky TOC element.
This change involves cached HTML, so this change is separated out from the rest of the CSS changes to be merged first.

Bug: T300875
Change-Id: I8c0924f6de28b15602969de873a843b4cd69548b
2022-02-22 17:21:10 +00:00
jenkins-bot a47f14658c Merge "Move table of contents code to SkinVector22" 2022-02-21 23:53:50 +00:00
Jon Robson ed4b45f44a Move table of contents code to SkinVector22
This avoids the RuntimeException in old Vector, and means
we can safely enable this on the beta cluster

Note, for any users that are in migration mode e.g. skin is
set to 'vector' and the skin version is set to 2 they will
not see a table of contents in the sidebar or article.

This won't be a problem in production provided T299104
is resolved before we enable.

Change-Id: I942a1cb933e7364600fe1af7491aca20546545e5
2022-02-21 23:36:15 +00:00
Nicholas Ray 6e9506dcad Dynamically expand/collapse sub-sections in ToC based on # of headings
Server render the table of contents in a collapsed state when the total
number of headings is equal or greater than the value of
`$wgVectorTableOfContentsCollapseAtCount`. Otherwise, the table of
contents will be server rendered in its "expanded" state.

In addition:

* Revise table of contents tests to call one `assertion` per element so
  that it is easier to see the exact element that may fail an assertion.
* Revise table of contents tests to call a mount function that can merge
  props to allow for a more flexible set of tests.
* Revise table of contents tests by wrapping a `describe` around tests
  that expect the same prop state.
* Adds typedef for table of sections props

Bug: T300973
Depends-On: Ifaee451e1903f2accd0ada2f2ed6dfa3f83037b6
Change-Id: I382200bc603b6abf757a91f14a8a55a6581969bd
2022-02-21 14:58:51 -07:00
Nicholas Ray 29e40714bc Offset the TableOfContents `top` property only when the sticky header is shown
This uses the sticky header's `.mw-sticky-header-element` utility class
to conditionally offset the table of contents to the height of the
sticky header only when the sticky header is enabled.

Bug: T300077
Change-Id: Ibad97a11e708ba19acf27ca82320f7c3e5f80447
2022-02-17 12:20:15 -06:00
bwang 301e09916d Toggle ToC sections when clicking toggle button
Bug: T300167
Change-Id: If1150a9e018b232da900187383aaee9c9cf331a1
2022-02-16 15:48:28 -06:00
Jan Drewniak 7d32ec80d3 Collapse ToC by default & expand sections when clicking section headings
Collapses sub-sections in the new table of contents by default
(except for non-js and reduced-motion users) and expands the
sections when the top-level section link has been clicked.

Refactors the `activateSection` TableOfContents methods into separate
`activateSection` and `deactivateSection` functions.
Adds `expandSection` and `collapseSection` methods.

Adds triangle icon as a visual expand/collapsed indicator
next to all ToC section headings and are hidden via CSS based on
whether or not the section contains subsections.

Adds test for tableOfContents.

Bug: T299361
Change-Id: I36b3ae7f9f633877683bc17a9444c970d7fa7293
2022-02-15 00:09:50 -05:00
jenkins-bot d94c685f02 Merge "Use bodyClasses option to register static classes on skin" 2022-02-08 16:25:02 +00:00
Reedy ee76b72905 SkinVector: Minor cleanup
Change-Id: I788710e17ebed933cc70b0cd88138b0a1051d72c
2022-02-06 22:48:51 +00:00
Jon Robson 6f7a6bb24b Use bodyClasses option to register static classes on skin
Bug: T298734
Change-Id: Ia2ae8e1c655aff8783c2602da992632cd5877bf8
2022-02-04 18:44:43 +00:00
jenkins-bot 3ea4800c40 Merge "Add recursive template for toc" 2022-02-03 20:55:15 +00:00
Jon Robson ddcf51a9ec Drop skin override
This is often used by gadgets/scripts to request
information from the API. Given `vector` means old Vector
now that leads to styling issues.

The unfortunate side effect of this is that any code
checking mw.config('skin') === 'vector' will no longer work
and we'll likely need to patch various gadgets accordingly.

Bug: T300814
Change-Id: Ic920e91960cf81790096395256b75f8ed0dc4173
2022-02-03 19:00:24 +00:00
jenkins-bot 59c89b2db7 Merge "Overriding getPortletData will soon be deprecated" 2022-02-03 16:28:27 +00:00
jenkins-bot c03a5974cb Merge "Pass skin name to Hooks::isSkinLegacy" 2022-02-02 22:52:54 +00:00
Jon Robson 9b8d1b64cb Overriding getPortletData will soon be deprecated
See Ib8fc4cd183df3ed059a2d7000c56ab0a11d34f47

Bug: T299456
Change-Id: I743088e2665f8b304fb6273e912f9a6e5ff92e66
2022-02-02 14:37:36 -08:00
Jon Robson 2a2ee9b4d4 Pass skin name to Hooks::isSkinLegacy
Hooks::isSkinLegacy is only checking the skin version
but not the skin name. This is likely why we are seeing
errors due a mismatch between the result of Hooks::isSkinLegacy
and SkinVector::isLegacy

The parameter is made optional as it is not
always needed. For example in the onGetPreferences
method the skin hasn't been set at this point so all
we need to do is check the skin version.

Bug: T299971
Change-Id: I98465d5f6429f0a57dd0a95efcda71f380f3e842
2022-02-02 13:55:16 -08:00
Jon Robson c59a3b756f Fix the opt in URl
Hash fragment is wrong

Bug: T300097
Change-Id: I9e63606b66195a3b3db95e519514019dbd7d1bdb
2022-02-02 18:54:13 +00:00
jdlrobson d8382ec96b Drop search related feature flags
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
2022-01-31 21:00:22 +00:00
jenkins-bot fa3c528bef Merge "Don't show language alert on main page if it has no languages" 2022-01-31 18:15:49 +00:00
jenkins-bot af39ad98ea Merge "Language alert box should use Html::noticeBox" 2022-01-31 17:05:57 +00:00
Clare Ming 5d2bc68da1 Don't show language alert on main page if it has no languages
Bug: T299581
Change-Id: Idc5b702626249ebec5d627e7b88fd6adf3e3750a
2022-01-31 09:43:15 -07:00
Clare Ming 588d273360 Fix issues with language alert in sidebar:
- Don't show language alert if:
  - language button is not in header
  - on main page
  - on special page
- Update message with sitename.

Bug: T299581
Bug: T295555
Change-Id: I6290ea440e6b4673f29939376ac47ab53a882001
2022-01-28 13:58:31 -07:00
Jon Robson e1f1899dae Add recursive template for toc
Depends-On: I5ceec7f7bdea8b16ba0b300486ec0c4f2202b602
Bug: T299065
Change-Id: I0205596f0f7c0f452e80bd6a1f49e59e8388b4b8
2022-01-28 19:58:57 +00:00
Jon Robson 029110810e Language alert box should use Html::noticeBox
Html::noticeBox doesn't output any deprecated classes so
will not conflict with any user gadgets now.

Bug: T299625
Change-Id: Ic9aef5c8ff3fae6a79c7cf82cc3c97714cf40b3d
2022-01-27 15:35:38 -08:00
jenkins-bot 0e08ae8c17 Merge "Rely on core TOC data to show the TOC in Vector" 2022-01-27 20:10:29 +00:00
bwang d244f43e39 Rely on core TOC data to show the TOC in Vector
Bug: T298796
Depends-on: I406acf333d28b3898e3bc4968d05224febd09b3c
Change-Id: Iebb9c86b409a49d211c320f540b9af409b604b5b
2022-01-26 16:14:17 -06:00
Nicholas Ray 3c433a5315 Add sectionObserver and tableOfContents component JS to respond to intersection changes
This commits sets up the Table of Contents to bold the active section
when the section is scrolled.

Unfortunately, because our content does not have actual sections but
instead has a flat list of headings and paragraphs, we can't use
IntersectionObserver in the conventional way as it is optimized to find
intersections of elements that are *within* the viewport and the
callback will not reliably fire during certain scenarios (e.g. with fast
scrolling or when the headings are not currently within the viewport).
Furthermore, iterating through a list of elements and calling
`getBoundingClientRect()` can be expensive and can also cause
significant forced synchronous layouts that block the main thread.

The best compromise in terms of performance and function that I've found
is to use a combination of a throttled scroll event listener and
IntersectionObserver's ability to asyncronously find the
boundingClientRect of all elements off the main thread when `.observe`
is called which is the approach this patch takes. Although this is an
unorthodox way to use IntersectionObserver, performance profiles
recorded while holding the "down" arrow and scrolling for 10 seconds
with a 6x CPU throttle are comparable between master and this patch:

master: https://phabricator.wikimedia.org/F34930737
this patch:  https://phabricator.wikimedia.org/F34930738

Bug: T297614
Change-Id: I4077d86a1786cc1f4a7d85b20b7cf402960940e7
2022-01-26 14:11:43 -07:00
Jon Robson 9fba9b6b9e Do not load common.js twice
An error in both of these modules. This module is additive (it doesn't
replace the existing user module) so only needs to add new pages, not
append to existing pages.

Bug: T300070
Change-Id: I3ba2ce82ba924972d0f9fea763328510aef41f8e
2022-01-25 20:10:31 +00:00
Jon Robson b1cdf4acae Opt in link should be different in migration mode
In migration mode the control for opting out is different

Bug: T299927
Change-Id: Ie824c9051c929641e5ebab7a7b4a062e469ed6a0
2022-01-25 00:54:51 +00:00
Jon Robson 435c903523 Fix bug in SkinVersionLookup
Bug: T299971
Change-Id: Icd8874315bf3c5846b00e8c34eb1a739c4a0feba
2022-01-24 13:34:06 -08:00
jenkins-bot 92e5d4fd46 Merge "Avoid escaping TOC section titles" 2022-01-21 16:30:47 +00:00
jenkins-bot efb6b4d152 Merge "Respect useskin when operating in MigrationMode" 2022-01-20 22:20:33 +00:00
bwang 3abd70392b Avoid escaping TOC section titles
Change-Id: I81f92627642c20d0770b2bc3223e056fc646365a
2022-01-20 12:31:11 -06:00
jenkins-bot 555db12047 Merge "Use 'toc' skin option and render with new TableOfContents mustache template" 2022-01-20 18:09:34 +00:00
Jon Robson 6cd9cc5be0 Do not try to make watchlist collapsible on wikis where watchlist is disabled
Bug: T299671
Change-Id: I9b44401ad753881ca986157dc06bb4402edc1017
2022-01-20 09:42:58 -08:00
Jon Robson 94bab9f45f Respect useskin when operating in MigrationMode
Bug: T299171
Change-Id: I7c183949c358a5eb07c273044f63ac6474a62ad2
2022-01-19 22:33:28 +00:00
bwang 8a957c0163 Use 'toc' skin option and render with new TableOfContents mustache template
Bug: T297611
Change-Id: I8332f7b9c9574d8dece4f7111b299b95533cf386
2022-01-19 14:38:51 -06:00
Jon Robson 1149d3d611 Drop watchlist in user menu feature flag
Working correctly. No longer needed.

Additional change:
* add tooltip to menu

Depends-On: I418ce75bda8015520d1f1742ddcdfefbc8b9a162
Bug: T289619
Change-Id: I42f21ca8836e5042d07102e1516ca386478dfabc
2022-01-19 16:10:32 +00:00
Jon Robson 37ee126a85 Restore icons to user links dropdown
Follow up to
I62562969a00eb96c83af4519e0e34e4a77ed8b19

Bug: T289619
Change-Id: I88a2d4af97227bb69dc9a11ea7ceac54895d2376
2022-01-18 11:14:44 -08:00
Jon Robson 55bcce3cc0 Don't run Vector hook when menu absent from page
While editing I was seeing a fatal due to this error being null
Err on side of caution and check for existence of menu
Follow up to I8309492881142d47eec4da5cc4aa5c6febbd1b35

Bug: T289619
Bug: T299352
Change-Id: I62562969a00eb96c83af4519e0e34e4a77ed8b19
2022-01-18 02:05:37 +00:00
Func 0bd3a30343 Use field name for the hide-if statement
Field name without 'wp' prefix (which is used as the key in html descriptor) is required.
After I58f9df384df8ecc5ebae8cac68ec2251351bc984, values of fields that are supposed to be disabled would be loaded from default, use a miss-matched field name would be treated as disabled.
It works in UI now, but it's not a good idea to strip the 'wp' prefix on the server-side.

Bug: T298819
Change-Id: If98368ad400986afaef3187867f201044ebf0efb
2022-01-17 03:24:10 +00:00
Jon Robson 591e1d296c [Refactor] simplify watchlist link generation and adopt new icon
Bug: T289619
Change-Id: I8309492881142d47eec4da5cc4aa5c6febbd1b35
2022-01-14 00:26:10 +00:00
Nicholas Ray 699579e646 Add clarifying comment for why scroll padding is applied to html tag.
Change-Id: I9f4b44536b1e8aace41c8699a0d1946a54aa0bfe
2022-01-13 11:59:59 -07:00
Clare Ming f4aafdd263 Update hook to check for new vector skin key.
Bug: T298916
Change-Id: I2946b773b8214cb277be61990df46b109a13748c
2022-01-11 16:44:20 -07:00
jenkins-bot 25bfcf4d00 Merge "Ensure sticky header language button only shows when there are multiple languages and when ULS is enabled" 2022-01-07 23:42:51 +00:00
bwang 3dda2dda5b Ensure sticky header language button only shows when there are multiple languages and when ULS is enabled
Bug: T298705
Bug: T297579
Change-Id: Iae5db6fd0ec6ae66bb16e8579f14d3e799bf3cbd
2022-01-07 15:42:57 -06:00
jenkins-bot 0488310612 Merge "Restore gadget support to new internal skins" 2022-01-07 20:41:44 +00:00
jenkins-bot 84ed8343c2 Merge "Vector is split into 2 skins" 2022-01-07 20:16:57 +00:00
jdlrobson 99cf6eb5be Restore gadget support to new internal skins
For vector-2022 skin:
* MediaWiki:Vector.css and MediaWiki:Vector.js are added via the
existing ResourceLoader hook.
* User:<name>/vector.js and User:<name>/vector.css are added via new
VectorResourceLoader modules

Bug: T297758
Change-Id: I37e9a9d353695502213c7a651530995252d9505f
2022-01-07 00:18:17 +00:00
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
Nicholas Ray 3028a4f9d8 Refactor search component expand behavior and add auto-expand-width prop to search component
In preparation for I30c670e3f195f77a27715c6b494a3088b7a55712, refactor
the search component expand behavior so that it can accomodate the new
changes in WVUI while maintaining backwards compatibility with the
status quo.

Additionally, pass/enable the `auto-expand-width` prop to the main
header's search. This will be inert until the new changes in WVUI have
landed.

Bug: T297531
Change-Id: Id8d3bd4aa74113b91ecaf66cb58cf5625db8a302
2022-01-04 15:14:49 -07:00
bwang bd799ecc2e Add watchstar to sticky header (alternative)
Bug: T294759
Depends-on: I88af8585e8fc75f77ebef867d267199aeb2c6592
Change-Id: I15c409830ef8970ff7319b4dd447904443949b8d
2021-12-21 09:40:48 -08:00
jdlrobson 9444bc3e86 DRY up mw-ui- class generation
Repeated in multiple places now, making it harder to change
button/icon classes.

Change-Id: I3799d065ac0c4ccdc900cbebe9140fb8ea657008
2021-12-17 10:06:46 -08:00
jenkins-bot c6691a191d Merge "Disable table of contents in article body" 2021-12-17 00:17:16 +00:00
jdlrobson ef59d7b973 Disable table of contents in article body
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
2021-12-16 16:11:05 -07:00
jenkins-bot 44ef14574f Merge "Drop language A/B test bucketing check" 2021-12-16 22:00:45 +00:00
jdlrobson 5a8a3d0d13 Drop language A/B test bucketing check
The existence of this code means we can't safely use this service
inside the skin's constructor.

We no longer need this, so that's fine.

Change-Id: Iffd82c00030c4cf1238a931dc971ffb4686d2620
2021-12-16 12:15:47 -08:00
bwang 321e6b19e1 Move watchlist button out of user menu dropdown and adds temporary feature flag
Bug: T289619
Change-Id: I57addbed2ea8ead5d98bce659f3db1f88f8a5094
2021-12-15 23:21:37 +00:00
jdlrobson 44aeee5d83 Vector uses html-title-heading
The H1 is available with the correct attributes in core now, so
we can use that instead of our own markup. This also means Vector
will benefit from updates to the heading in core such as main page
special handling.

Bug: T297728
Change-Id: I4d10370678fad6455d73994bf340891760543b71
2021-12-15 22:27:48 +00:00
jenkins-bot 9efaaf8afa Merge "Add feature flag for sticky table of contents" 2021-12-15 18:16:16 +00:00
Clare Ming 72fecd41f2 Add feature flag for sticky table of contents
- Add TOC feature requirement.
- Update data for SkinVector.
- Add TOC template.

Bug: T297610
Change-Id: I90bc5e21ba187ac9dd74d5e97763834795a0545b
2021-12-14 16:26:58 -07: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
jdlrobson 983437312b Don't add language button to sticky header on pages without languages in content
In Commons languages appear in sidebar.
The language button shouldn't show in the sticky header on these wikis

Bug: T297362
Change-Id: I17d283a7c0ad20bdcaf39b234a7fe766880ab28a
2021-12-13 20:04:50 +00:00
jenkins-bot dc6bd9af95 Merge "Remove need for html-class template property" 2021-12-10 18:03:22 +00:00
jenkins-bot 2e492515b3 Merge "Add language switching alert in sidebar for language in header" 2021-12-10 17:04:06 +00:00
jdlrobson ca501bb581 Remove need for html-class template property
Follow up to 9dcfc1f

This simplifies the template by removing the need for the html-class.
The font-size can be provided to the entire content area meaning we don't
need the link-only class

Change-Id: Id5c49358f6ec007b3205ee390cf68334a1e56de5
2021-12-10 08:40:01 -08:00
Clare Ming 9dcfc1ff27 Add language switching alert in sidebar for language in header
- Add i18n messages.
- Update relevant data methods in Vector.
- Update sidebar template + styles.
- Add new template partial for sidebar actions.
- Add feature flag to turn on/off alert.

Bug: T295555
Change-Id: I232ce13770917d51495391f4b8d8d1a3a8a7afb8
2021-12-09 16:37:36 -07:00
jenkins-bot d0116e07f9 Merge "Make ULS in header quiet progressive button" 2021-12-09 17:33:03 +00:00
bwang b79290f5c9 Make ULS in header quiet progressive button
Bug: T291286
Change-Id: Id1e056330606b87bafb8f43e7ff28d96290465b4
2021-12-09 15:27:04 +00:00
jenkins-bot a7c16c7f30 Merge "Feature flag language button in main page header" 2021-12-08 23:11:53 +00:00