Commit Graph

235 Commits

Author SHA1 Message Date
Stephen Niedzielski 0867ff03aa [fix] [notifications] fix icon width
When notifications are present, the wrong icon width was used. Set the
icon width and remove a useless class, main-header-button.

https://codesearch.wmflabs.org/search/?q=main-header-button&i=nope&files=&repos=

Change-Id: Ie274ffcc93cf576f36eb0fccee80ecd3d4ac3a21
2019-08-02 14:39:04 -06:00
jenkins-bot 7cca6b42f8 Merge "Hygiene: SkinOptions should know what are AMC options" 2019-08-02 18:52:50 +00:00
jenkins-bot ca5afd9ac0 Merge "Hygiene: remove deprecated calls from MinervaSkin and MinervaTemplate" 2019-08-02 17:09:36 +00:00
jenkins-bot 573a08ddf5 Merge "Hygiene: Simplify if statement and move comment" 2019-08-02 16:35:48 +00:00
jenkins-bot 0c4186746a Merge "Hygiene: Wrap userMenu and pageActions into prepareMenus" 2019-08-02 16:31:24 +00:00
Piotr Miazga ab1d39ea4f Hygiene: Wrap userMenu and pageActions into prepareMenus
Changes:
 - introduce preapreMenus()
 - move getUserMenuHTML logic into prepareMenus
 - move preparePageActions logic into prepareMenus
 - rename 'page_actions' into 'pageActionsMenu' to be consistent

Change-Id: Ie8cc137f749741074e1a5787bee67893fc45fde9
2019-08-02 17:39:31 +02:00
Piotr Miazga ec77b3ab25 Hygiene: remove deprecated calls from MinervaSkin and MinervaTemplate
Changes:
 - Title::getTalkPage() is deprecated, use NamespaceInfo instead
 - Title::getSubjectPage() is deprecated, use NamespaceInfo instead

Note: NamespaceInfo returns LinkTarget instance, but most of our
logic is wrapped around Titles, that's why we need to call
Title::newFromLinkTarget() to be sure that we got Title object.

Change-Id: Ibf2237ea369b0cee67ab5f623bdddcd9058eec3e
2019-08-02 17:04:53 +02:00
Piotr Miazga 05cdcc09c8 Hygiene: SkinOptions should know what are AMC options
Do not hardcode special handling of Options in other places
than SkinOptions. SkinOptions should be only one place that
knows all interpedences.

Change-Id: I9ad8c1560332665dbcd88ccc7105fb253a2f41b9
2019-08-02 16:26:52 +02:00
Piotr Miazga b03e24aa9c Hygiene: Rename MainMenu related classes
For better readability Main Menu building classes should
contain MainMenu in the name as not everyone uses smart
IDEs.

Change-Id: Ica3bf4bbd18cab1a6cd88061dfb9d1ce51b0f63d
2019-08-02 14:20:00 +00:00
Piotr Miazga 0ac08cafb2 Hygiene: Simplify if statement and move comment
It feels like the comment about history link time should be located
next to the getHistoryLink function, not somewhere in the code.

Statements like:

  if ( a ) {
    if ( b ) {
      // do sth;
    }
  }
can be easily wrapped into:

 if ( a && b ) {
   // do sth
 }

Change-Id: I98c071ecdd855210bc0a92f032ee622fb91e8df5
2019-08-02 15:38:18 +02:00
Piotr Miazga 4efd72a879 Hygiene: Remove OPTIONS_ and OPTION_ prefixes from SKinOptions
Additionally, renamed couple options for better readability.

Bug: T221012
Change-Id: Ia347a60d469fba8f35afa7c70aa806a46271dccd
2019-08-01 10:34:03 -07:00
jdlrobson 87a0795ed8 Subtitle appear below page actions
Bug: T217197
Change-Id: I6582db82ac750783dffa5612c9a0b3ccc86749a1
2019-07-30 09:59:58 -07:00
Stephen Niedzielski 8dbd511e88 [fix] [AMC] load main menu icons on desktop Minerva
The main menu icons are needed in the user menu by the no-JavaScript
desktop Minerva experience which does not have an active
SkinOptions::OPTION_OVERFLOW_SUBMENU option. This was introduced in
Ic6a2490fbd3903c5d34ff8267d745fdd93c73fd2.

Bug: T214540
Change-Id: I780e5639057f236d6ff91675f82cf4682520021a
2019-07-29 12:23:28 -06:00
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
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
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
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
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 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
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 0d9f6786e4 Merge "Hygiene: Drop isAuthenticatedUser method" 2019-06-21 19:56:44 +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
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
jenkins-bot 48c3aa0662 Merge "Make the tabs scrollable horizontally" 2019-06-18 16:20:01 +00:00
Stephane Bisson 4f5dbf7d55 Make the tabs scrollable horizontally
* Add a container around the tabs and use flexbox
  to position the tabs on one line and make it
  scrollable.
* Add some JS to scroll the currently selected
  tab into view.

Bug: T223142
Change-Id: Ie2205e6836797c2ac000e12a01f78a4aa7bc5b81
2019-06-14 13:50:23 -04:00
jenkins-bot 3461c9dd93 Merge "Add wikidata link to overflow menu" 2019-06-14 16:54:12 +00: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
Nicholas Ray 162f8aa95c Add wikidata link to overflow menu
The director is now passed the array from `BaseTemplate::getToolbox()`
as all of the server rendered links we show in the main namespace/user
namespace overflow menus (including wikibase) will be in the toolbox
array except for the "Uploads" link in the User overflow menu which is
added in the UserNamespaceOverflowBuilder.

Bug: T222630
Change-Id: I280537c6b8b32036d68a5a004571bb5a41c2e703
2019-06-12 19:50:48 -06:00
jdlrobson 37a3045f62 🐛 Bug: Make the history action's filters form toggleable again
Before this commit, the filters form would stay collapsed and the user
couldn't toggle the visibility of the form. This commit fixes that by
loading the necessary modules for the history action to make the form
toggleable again:

- mediawiki.page.ready
- jquery.makeCollapsible
- jquery.makeCollapsible.styles

Additional Changes:

- The explicit addition of the 'mediawiki.action.history' module to the
defaultModules array in SkinMinerva was removed because this module
should already be added by HistoryAction.php and all we are doing with
Minerva is styling it differently.

- The styling to hide the filter revisions box in
skinStyles/mediawiki.action.history.styles.less was removed now that
this functionality should work again

Bug: T223204
Change-Id: Icf4a22a62228aca5a120bcdf3d6fede35b3c928e
2019-06-07 14:27:23 +00:00
jenkins-bot 11c4309193 Merge "PageActions menu should use Builder pattern" 2019-06-05 22:19:11 +00:00
jenkins-bot 7bd31a1ef9 Merge "Add hook to override SkinOptions, and allow overriding tabs output" 2019-06-05 21:49:26 +00:00