Commit Graph

18 Commits

Author SHA1 Message Date
Stephen Niedzielski 805cc92e73 [UI] [AMC] add recent changes to the AMC menu
This mostly reverts commit 692309090d and
updates the icon.

Bug: T224216
Change-Id: I7200aaef5a15479afb4bc99f5195e900351a055a
2019-07-30 11:27:34 -06: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
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
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
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 11525af55e Merge "Introduce new SingleMenuEntry" 2019-06-14 14:18:51 +00:00
Piotr Miazga fa30f03495 Introduce new SingleMenuEntry
Instead of using $group->insert(....)->addComponent() we can define
our own small SingleMenuEntry that defines a standard menu entry with
a label and one icon. The icon name and tracking code by default will
be the same as the menu entry name.

Changes:
 - introduced SingleMenuEntry class
 - updated Definitions class to use new entry instead of using old
 MenuEntry class
 - changed the Contributions meny entry name to match icon/tracking

This should simplify code a bit, thanks to this approach we should be
able to remove the Definitions class in some future and keep building
MenuElements in the builders.

Bug: T221792
Change-Id: I1f145e8cd173b72b01a145b2dba3704593f17ab7
2019-06-13 21:39:37 +02:00
Piotr Miazga b899286650 Encapsulate Login/profile/logout meny entry logic into AuthMenuEntry
The Growth extension would like to override the the profile link in
the main menu. We can replace the MenuEntry from group, but
modifications of each component shouldn't be allowed. That approach
is too much error prone. Furthermore it won't allow us to change
how the Login/Logout link works.

The Menu/Group accepts IMenuEntry objects, instead of building
complicated Login/Logout menu entry, let's encapsulate all that
logic into small, well-contained AuthMenuEntry object.

Now, as we have the AuthMenuEntry, we can add an `overrideProfileURL'
method to allow the profile url modifications. That approach will
allow modify profile links, and "how to modify links" logic in
one place.

Changes:
 - extracted Definitions::insertLogInOutMenuItem() body into new
AuthMenuEntry class
 - renamed some variables like $logoutUrl for better readability
 - introduced `AuthMenuEntry::overrideProfileUrl()` method that
allows modification of the Profile url, label and tracking code.

Bug: T222834
Change-Id: Ib7356acbd3373c7a4b591c9c133d7d02a55239b0
2019-06-05 21:17:31 +02:00
Piotr Miazga 26fea403c2 Harden Definitions::insertCommunityPortal() method
Looks like Title::newFromText() can return null instead
of Title object. Code has to support this edge case.

Bug: T222407
Change-Id: Ie34a26303df8e27247e51ddc2b13e3c2fa59a435
2019-05-04 01:13:05 +00:00
Piotr Miazga 0ef74abc2d Improve Community Main Menu element handling
The Commmunity Portal main menu element should be handled
same way as Skin::buildSideBar() does:

 - it should ignore "-" -> this is how editors disable the
 link
 - it should use inContentLanguage() to properly support
 different languages

Bug: T216152
Change-Id: I41b2373fd1b55d9d4beaba60eeb362e6188d24de
2019-05-02 17:08:29 +00:00
Derick Alangi 2681fa1b13 Hygiene: Various cleanup in Minerva PHP code
Cleanup ranges from removal of unused variables, fixing of method
case mismatch, collapsing of multiple `if` statement that can be
combined into one.

Change-Id: Ib9d6e2e4d747da699067c0c0a9aab5e8af29aef2
2019-04-20 00:37:09 +00:00
Piotr Miazga 692309090d Remove Recent Changes from Main Menu
We decided to remove the Recent Changes menu entry from Advanced
menu for now, we might come back to it later.
For more info: https://phabricator.wikimedia.org/T216152#5123296

Bug: T216152
Change-Id: I6342e273fdc5f483692de6e1ac238c38d06f3e5f
2019-04-18 20:32:23 +02:00
Piotr Miazga 2cf4ed8981 Add Community Portal link to Mobile Main Menu
Changes:
 - introduced new icon for Community Portal
 - added new menu entry in Advanced Builder that links to
 MediaWiki:Portal-url

Bug: T216152
Change-Id: Id38836d8f1a62d4e15181ab10e219d5c5b769ec3
2019-04-16 11:21:43 +00:00
Piotr Miazga 1f4582cc09 Provide a code structure for menus handling and add Advanced menu
Changes:
 - moved all menu elements definitions from SkinMinerva into
 a separate Definitions.php file
 - moved menu building from SkinMinerva into includes/menu/Main
 folder
 - introduced Builder pattern for easy menu building
 Minerva/Menu/Main/Director takes an Minerva/Menu/Main/IBuilder
 and builds the menu. The IBuilders use definitions from
 Minerva/Menu/Definitions file, so all definitions can be shared
 across different menus
 - used ServiceWiring file to register MainMenu Director as Service
 - left class_alias for old MenuBuilder as some extensions still use it
 - The hooks system have to stay like that as some extensions
 are using it (BlueSpiceMultiUpload and GrowthExperiments).
 - introduced AdvancedMenu builder for the AMC mode

Bug: T216152
Change-Id: I210c3f1fa36bbd2f9108d728b12cbb21ee210354
2019-04-16 13:19:51 +02:00