Commit Graph

317 Commits

Author SHA1 Message Date
jdlrobson 406f211be1 Enable AMC styles if only one of the AMC properties is enabled
Bug: T229024
Change-Id: I46f4d6ef4529cea2953e3edde3a3e5eb579f24ec
2019-07-25 22:11:52 +00:00
jdlrobson f0503a52d0 Refresh the user, bell and search icon
* New module skins.minerva.icons.wikimedia provides icons
from Wikimedia UI in Minerva
* search selector in skins.minerva.content.styles.images is
retained for cached HTML
* skins.minerva.icons.loggedin now a
ResourceLoaderOOUIIconPackModule and bell removed from repo.
* userAvatar replaced with userAvatarOutline

Bug: T224070
Change-Id: Ibed609371060acc4b69e5cd4cd4f20edc871b3ba
2019-07-25 16:35:01 +00:00
Piotr Miazga ad04f31441 Follow-up: User menu improvements
Changes:
 - We should limit the interfaces we pass around,
  AdvancedUserMenuBuilder doesn't need whole IContextSource as it
  uses only msg() method. It's better to define that this methods
  needs only MessageLocalizer
 - move UserMenuDirector into ServiceWiring to be consistent with
 other Directors/Builders
 - pass PersonalTools as a dependency to UserMenuDirector, which
 will pass to each Builder. The personalTools is set of links
 that can/should be used when rendering user menu (which in the
 fact has almost same subset of tools as the personal toolbox)

Bug: T214540
Change-Id: I7f744651b0665452a5a9d1ce661f20547e80812d
2019-07-25 08:41:22 -06:00
Piotr Miazga e117ee433a Follow-up: clean up old Advanced Menu builder and add hook support
Old MainMenuAdvancedBulder doesn't require the personal section
any more as that section is handled by new UserMenu.

Additionally we should add hook support in the new UserMenu so
different extensions can add their own menu entries.

Bug: T214540
Change-Id: Ibbfbee9d13d58c92d90a22d2b6dcf124b1313c23
2019-07-25 13:50:01 +02:00
Stephen Niedzielski 0a4f5b6126 [UI] [new] add user menu
Add new user menu. The changes required include:

- Break up AuthMenuEntry into reusable components. They're now simple,
  independent, static functions in AuthUtil that are easy to reason
  about and compose.

  There's lots of verbose code because of the builder and director
  patterns. That is, most of the code is for building the thing we
  actually want to build instead of just building it. It's easy to write
  but no fun to read--even simple configurations are extremely verbose
  expressions that must be threaded through the system.

  These builders are also single purpose and unlikely to be reusable
  unlike a URI builder, for example. As objects, they're not especially
  composable either.

- Similarly, break up Menu/DefaultBuilder into BuilderUtil and ban
  inheritance. Inheritance has not worked well on the frontend of
  MobileFrontend. I don't think it's going to work well here. E.g., I
  could have made changes to the base class' getPersonalTools() method
  such that the client passes a parameter for the advanced config or
  maybe I just override it in the subclass. In either case, I think it
  makes the whole hierarchy nuanced and harder to reason about for
  something that should be simple.

- Add ProfileMenuEntry and LogOutMenuEntry for the user menu.

- Rename insertLogInOutMenuItem() to insertAuthMenuItem() which matches
  the entry name, AuthMenuEntry.

- Extension:SandboxLink is needed to display the sandbox link in the
  user menu.

- Performance note: the toolbar is now processed in MinervaTemplate,
  which corresponds to removing the buildPersonalUrls() override.

- To mimic the design of main menu, the following steps would be
  necessary:

  1. Create a user/Default and user/Advanced user menu builder and also
     a user/IBuilder interface.
  2. Create a user/Director.
  3. Create a service entry for Minerva.Menu.UserDirector in
     ServiceWiring. The Director is actually powerless and doesn't get
     to make any decisions--the appropriate builder is passed in from
     ServiceWiring which checks the mode.
  4. Access the service in SkinMinerva to set a userMenuHTML data member
     on the Minerva QuickTemplate.
  5. In MinervaTemplate, access the userMenuHTML QuickTemplate member
     and do the usual song and dance of inflating a Mustache template.

  This patch does everything except add a service, which was agreed to
  be unnecessary, so that logic is now in SkinMinerva.

- Wrap the existing echo user notifications button and new user menu
  button in a nav element. This seems like a semantic improvement.

- The existing styling and logic for the search bar and search overlay
  are pretty messy and delicate. Changes made to that LESS endeavored to
  be surgical. There's lots of room for improvement in the toolbar but
  it's out of scope.

- Rename logout icon to logOut.

Bug: T214540
Change-Id: Ib517864fcf4e4d611e05525a6358ee6662fe4e05
2019-07-24 18:24:07 +00:00
Stephen Niedzielski 933dc0e370 [dev] Replace menu entry inheritance with functions
Break up Menu/DefaultBuilder into functions that are reusable without
inheritance. The functions do not need much state to produce their
outputs and a weighty inheritance hierarchy makes the code difficult to
reason about. The functions are used in a following patch for the user
menu. They're now simple, independent, static functions in BuilderUtil
that are easy to reason about and compose.

Also, ban inheritance via `final` in a few places nearby. Inheritance
has not worked well in MobileFrontend and enabling it should be a
special deliberate case, not a default. E.g., in the user menu, the
changes could have been to the base class' getPersonalTools() method
such that the client passes a parameter for the advanced config or maybe
just override it in the subclass. In either case, it makes the whole
hierarchy nuanced and harder to reason about for something that should
be dead simple.

Bug: T214540
Change-Id: I6e9a2b36a1bff387eb3b33ea65b0a6806962810a
2019-07-23 18:07:02 -06:00
Stephen Niedzielski f068dc7af5 [dev] split AuthMenuEntry
- Separate AuthMenuEntry into reusable parts.

- Add some missed finals in nearby classes.

Bug: T214540
Change-Id: Icf285bf8d2b791dd1aa4ee37ae90d27afe42bd91
2019-07-23 18:07:00 -06:00
Stephen Niedzielski ff57ba7cd9 [dev] make interface for overriding menu profile URL
Make an interface for changing the URL of the menu profile item. This
functionality is needed by Growth and a subsequent patch will provide a
second profile implementation that should implement this interface.

Bug: T214540
Change-Id: Ie3647ac52a83b4cc34f3582a41c5d5524343965c
2019-07-23 12:23:45 -06:00
jdlrobson 6830ffcfea Disable the recent changes table-based layout on Minerva
See Ib68ff8fa782ac12479ef02247cdf78e405b64bad

Bug: T228280
Change-Id: I4169bcb93eb6680c0e9251873afb5637014c0e1b
2019-07-22 23:29:04 +00:00
Pmiazga de353c06c9 Revert "Remove all main_menu tracking related code."
This reverts commit d11c84d08b.

We decided to track both old MobileWebMainMenuClickTracking and new MobileWebUIActionsTracking for some time. Then once everything goes stable and it's proven to work correctly we will merge d11c84d08b.

Bug: T220016
Change-Id: Ib4d52e8b8c870774041284e575564a9933af6136
2019-07-22 18:31:55 +00:00
jenkins-bot 9352a70023 Merge "Remove all main_menu tracking related code." 2019-07-19 16:24:49 +00:00
Piotr Miazga d11c84d08b Remove all main_menu tracking related code.
This code should live in WikimediaEvents extension, not in
Minerva.

Bug: T220016
Depends-On: Ic2d6d1b21b0eb72ad68b0c447bc63f7d1bb021f4
Change-Id: Iaeb12704dcd257f0783f1ebec3def01cb2848228
2019-07-19 15:30:28 +00:00
jenkins-bot 2d9be80368 Merge "Use wikimedia.ui from core directly" 2019-07-17 15:15:12 +00:00
jdlrobson e27debc1dd Use wikimedia.ui from core directly
There's no reason to copy and paste all this here. These icons
can be imported directly from core using ResourceLoaderOOUIIconPackModule

Depends-On: I7800da87a6a10399f705b43e05c8592c766bae6f
Change-Id: I1f25aaca9b7313cd95cefc7f5629b8a7e65c887f
2019-07-16 22:20:25 +00:00
jenkins-bot 6076c61772 Merge "Embrace packageFiles" 2019-07-16 21:21:42 +00:00
jenkins-bot 297a2c3aeb Merge "Extract language/variants check to a service" 2019-07-16 21:16:51 +00:00
jenkins-bot 937d2b48ea Merge "On user pages, move language icon from Toolbar to Overflow menu" 2019-07-16 20:09:04 +00:00
Piotr Miazga d7f60a26db Extract language/variants check to a service
The $hasLangauges and $hasVariants checks were used in couple places,
which lead to the same code used in many places.
Following the DRY rule, let's implement a Service that can do that
check, and use that service everywhere in code.

Bug: T224735
Change-Id: I46d58758356e870c408a74b2c087a42d6ad0ddea
2019-07-16 19:53:57 +00:00
jdlrobson 502ab6051e Do not load main menu icons in critical path
The icons for the main menu are not needing for the first render,
they have thus always been loaded via JS. While this means the
menu icons do not load for non-JS users, Special:MobileMenu fulfils
that purpose. With AMC we'll need to reconsider this approach
but the 1.8kb added by this module is not acceptable.

Bug: T227929
Change-Id: Ic6a2490fbd3903c5d34ff8267d745fdd93c73fd2
2019-07-16 19:04:00 +00:00
jdlrobson 72df451bd3 Embrace packageFiles
Help with readability by using module.exports and require rather than the MobileFrontend
provided mw.mobileFrontend module manager (and avoid adopting webpack at this time)

Replace usages of mw.mobileFrontend.require with local require and module.exports
(compatible with RL or Node implementation)

Changes:
* Notifications modules are merged into skins.minerva.scripts and initialised
via a client side check.
* new file overlayManager for exporting an overlayManager singleton
rather than being hidden inside resources/skins.minerva.scripts/init.js
* All M.define/M.requires swapped out for require where possible
The `define` method is now forbidden in the repo.

Bug: T212944
Change-Id: I44790dd3fc6fe42bb502d79c39c4081c223bf2b1
2019-07-16 18:04:10 +00:00
Piotr Miazga dee1c197b9 On user pages, move language icon from Toolbar to Overflow menu
The Language icon is not useful on user pages as most probably there
are no translated user pages, thus there is no need to show all-time
disabled Language icon.

If overflow menu is available, don't show Language switcher icon in
toolbar, show it as first item in the overflow menu.

Bug: T224735
Follow-Up: I46d58758356e870c408a74b2c087a42d6ad0ddea
Change-Id: I05be9e6457257a1f2eb224ca9ec5808814bc9ed7
2019-07-16 17:51:11 +00:00
jenkins-bot e24c21555e Merge "Restrict AMC scripts and styles to AMC mode" 2019-07-15 19:50:49 +00:00
Daimona Eaytoy b5c6658813 Add phan
Bug: T133664
Change-Id: I26f8cfe8cb88ed7de88e765681d9334edd9f3ce4
2019-07-15 17:10:13 +00:00
jdlrobson a82ca2fcef Restrict AMC scripts and styles to AMC mode
These have leaked into all users experience.
The CSS appears to be unused outside AMC.

Also remove a reference to skins.minerva.share
which does not exist.

See I171831469a6733c458bc5c7ba249a5096ca975b8 which introduced these
styles.

Bug: T227929
Change-Id: I6af6b026e68e11327b7c4e3edfc4f812c7309e2e
2019-07-13 01:12:34 +00:00
jenkins-bot 122b57d98b Merge "Update page issues folder structure" 2019-07-09 14:29:10 +00:00
Piotr Miazga f190f7492a Hygiene: Do not insert Random menu entry if message do not exists
The `randompage-url` message might not be defined, or be set to
'-' which means - this text do not exist. Minerva should respect
that, instead of showing a link that points nowhere/to a '-' page

Bug: T188697
Change-Id: If97d29b0e25f3635e94bf3b80b051355ea49cf7d
2019-07-09 13:05:00 +02:00
jenkins-bot d2e723daf9 Merge "Random link in main menu can be customised" 2019-07-08 23:43:31 +00:00
jdlrobson 9b4c22f31f Update page issues folder structure
Tests are untouched as these will be moved to headless
node-qunit in a follow up.

Bug: T212944
Change-Id: I3d9b43387e34fd49827e3ab62420f3555ff4b3cd
2019-07-08 23:07:28 +00:00
Stephen Niedzielski 4c34cce9f3 Hygiene: move menu entries to subdirectory
The number of generic menu entry specific files is growing which is
cluttering the Menu/ directory. Move the entries to a new subfolder.

Bug: T214540
Change-Id: I807d6f6034ee1924e3a606f5e6782c3298896825
2019-07-05 21:32:44 +00:00
jenkins-bot 05de7b9387 Merge "Hygiene: extract ToggleList to a reusable component" 2019-07-05 00:27:11 +00:00
jenkins-bot c6b9bcb468 Merge "If the Overflow menu is visible, don't render user links" 2019-07-04 20:49:03 +00:00
jenkins-bot aacaa91f46 Merge "Add contributions link to toolbar on User pages" 2019-07-04 20:38:36 +00:00
Stephen Niedzielski edb4385345 Hygiene: extract ToggleList to a reusable component
A list that toggles visibility via the checkbox hack is needed in at
least two spots: the page actions overflow menu and the user menu. This
patch makes several refactors to turn what was previously hardcoded into
page actions a reusable component:

- Start a new components directory. Components are reusable and
  composable. The subdirectories are organized by function, not
  ResourceLoader module bundling which greatly improves the ability to
  see a component's full functionality in one directory instead of
  examining the entire codebase. See updates to README.

- Extract pageactions.less into:
  - ToggleList.less: LESS for any checkbox hack list.
  - DropDownList.less: LESS for lists that open downwards.
  - MenuListItem.less: LESS for list items of menus.
  The division makes it easier to see concerns, dependencies, and change
  code.

- Move pageActionMenu.mustache to a component and extract ToggleList
  template.

- Extract ToggleList.js from Toolbar.js.

Bug: T214540
Change-Id: I171831469a6733c458bc5c7ba249a5096ca975b8
2019-07-04 13:48:13 -06:00
Piotr Miazga 080049ffc5 Add contributions link to toolbar on User pages
We would like to hide the user links and show only toobar when
OverflowMenu is visible. The User contributions link is available
only in user_links section only, as we're going to hide this
section, we need to move that link to the Toolbar.

Bug: T224735
Change-Id: Ib4f297993213fcc8fc3dd998e282e5b39957485e
2019-07-04 21:46:45 +02:00
jdlrobson 6a8853ad25 Random link in main menu can be customised
Allow editors to define a different URL for random
by editing
/wiki/MediaWiki:Randompage-url
e.g. Special:RandomRootpage

Bug: T188697
Change-Id: I72bfbb9b02c99faa0c42c3212939f59b9b87149b
2019-07-04 10:47:18 -06:00
Kosta Harlan 9b7b10bbe9 Allow overriding text and CSS class for home menu entry
* Introduce a HomeMenuEntry class and use it for adding the home menu link
* Provide override methods for text and CSS class

Bug: T223210
Change-Id: I37160887478cba829a6e2f10a4d8f87d95167556
2019-07-03 16:42:47 -04:00
jenkins-bot a06df4ec9b Merge "Add DataAfterContent to footer (SkinAfterContent hook)" 2019-06-28 12:20:27 +00:00
jenkins-bot 93ca7f2eee Merge "Move hamburger icon generation into Director" 2019-06-26 19:13:55 +00:00
Piotr Miazga 686e116d60 If the Overflow menu is visible, don't render user links
User links bar has the items already rendered in toolbar/overflow
menus. There is no need to render user links if the overflow menu
is available.

Bug: T224735
Change-Id: I613fa68b6cd43acf07bcb85af77d0239dc6bba6b
2019-06-25 12:25:26 +00:00
jenkins-bot ab3fb1d148 Merge "MinervaPermissions must respect $wgHideInterlanguageLinks config" 2019-06-21 20:13:27 +00:00
jenkins-bot 0d9f6786e4 Merge "Hygiene: Drop isAuthenticatedUser method" 2019-06-21 19:56:44 +00:00
Piotr Miazga bb0071383a MinervaPermissions must respect $wgHideInterlanguageLinks config
MediaWiki Core defined $wgHideInterlanguageLinks that can be used to
disable the interwiki links. Minerva skin should respect this config,
furthermore, this config should take precedence over the Minerva's
$wgMinervaAlwaysShowLanguageButton config.

Bug: T214540
Bug: T221792
Change-Id: Id4fe8b67a17f9c28c00a8a3a207946e146502cde
2019-06-21 18:59:50 +00:00
Piotr Miazga 0e65adbf44 Move hamburger icon generation into Director
The MainMenu is built using Builder pattern. The hamburger icon
is always the same, and it should be defined in the Menu builder,
not as a separte UI element.
For better code organization, all things related to MainMenu
building should stay in the Menu Director/Builders, not in the
SkinMinerva class.

Changes:
 - moved hamburger icon build method into MainMenu/Director
 (as the menu icon is the same for all builders)
 - renamed stuff in BaseTemplate for better readability
 - use MediaWikiServices::getInstance()->getSpecialPageFactory()
 instead of deprecated SpecialPageFactory class.

Change-Id: Ie5b30c0dd1649d38a4023ccb40c99dee2a127a70
2019-06-21 20:57:32 +02:00
Piotr Miazga b8d5e3fac5 Hygiene: Drop isAuthenticatedUser method
Is used only in Minerva, and it's so simple, there is no need to
have a special function for that (no improvement no performance,
nor readability)

Change-Id: Id5a4edb077671dc12f58df31273f00a1a816f097
2019-06-21 19:18:27 +02:00
Piotr Miazga 8c7553935e Hygiene: Add return types for known services
We can define return types using `function(): TYPE` notation.
We should do that when it's possible.

For now, it's not possible to type nullable return type (PHP7.1
supports that, but PHP7.0 and most probably HVVM doesn't),

Change-Id: I6b58a882383832313ef47a296c726a4044a97954
2019-06-21 19:06:04 +02:00
Piotr Miazga 6352190684 Hygiene: Extract isAllowedPageAction into MinervaPagePermissions
The isAllowedPageAction is used in multiple places (SkinMinerva
and in PageActions toolbar builder). This logic should be defined
in separate service, easy accessible for different parts of the
Minerva skin.

Changes:
 - Introduced MinervaPagePermissions as a centralized place to manage
 user permissions
 - Introduced MinervaNoTitlePermissions, an NullObject pattern to
 handle situations when we do not have Title object (like in CLI)
 - removed Minerva.ContentHandler service as it's not required any
 more
 - moved all permission names into constants
 - moved isTalkAllowed() into MinervaPermissions
 - renamed isAllowedPageAction() it `isAllowed()` to not mix it
 with PageActions. Those checks are used in many places, not only
 on PageActions menu
 - made isAllowed( watch ) more robust - now it checks that Title
 is watchable

Bug: T221792
Change-Id: I87d44a9c717b5f752b8d1fd2f146d7f5eef3c53f
2019-06-21 15:30:11 +00:00
Piotr Miazga 806663e158 Extract LanguageSwitcher to separate class
The Language switcher will be used in couple places:
 - Toolbar, if the AMC is off
 - both overflow mmenus when AMC is on

To make code DRY, first we should provide a single way to
create Language Switcher menu element, so we can use same way
in all possible scenarios.

Bug: T224735
Change-Id: I5ba0dbad7089012c7fd1bfc43787775c7e36d575
2019-06-20 17:18:20 +02:00
Isarra 492b3fa63e Add DataAfterContent to footer (SkinAfterContent hook)
bug: T226143
Change-Id: I5b0ad889e633fde88c392577ce5373c81fc5486a
2019-06-20 01:49:05 +00:00
Stephen Niedzielski 1e61706e0e Hygiene: rename "secondary button" to "user notifications"
The secondary button is not generic. Rename it to match its specific
purpose.

Bug: T214540
Change-Id: I50b7e7fa7bea91a029a8ca71199b0309dff1c518
2019-06-19 11:31:16 -06:00
Stephen Niedzielski 02726555e0 Hygiene: rename user notification build method
Rename SkinMinerva->prepareUserButton() to
prepareUserNotificationsButton(). The function is responsible for
inflating the button that displays notifications when pressed. This name
would be especially confusing when an actual user button is added in
T214540.

Bug: T214540
Change-Id: I8965ef4c5b29ea692d67e821a06131ad5f287287
2019-06-19 11:16:23 -06:00