Commit Graph

189 Commits

Author SHA1 Message Date
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
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 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
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 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
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 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
Piotr Miazga 209becf63d PageActions menu should use Builder pattern
The PageActions menu shouldn't be built inside SkinMinerva class.
All menus should be build in similar way so it's easier to understand
how different parts of the system work. This will allow us to easily
track different menu elements/move elements between different menus.

Additionally we should allow extensions/3rd party to modify both the
toolbar and overflow menus.

Changes:
 - Removed PageActions logic from SkinMinerva class
 - introduced new PageActions/Director to build page actions menu
 - introduced Builders for toolbar, and different types of overflow
 menu
 - because Overflow menu elements require the
 BaseTemplate::data['nav_urls] array, instead building all links,
 pass the array when building PageActions menu. Code for getting
 menu entries had to be rewritten (use $navUrls array instead of
 $this->tpl['nav_urls'];
 - ServiceWirings file contains logic on what to pass to
 PageActions/Director class (which builders)
 - PageActionsMenuEntry setTitle() and setNodeID() returns $this
 so we can use method chaining. Only a syntax sugar.
 - if AMC is not available/Overflow menu is disabled via config,
 system will pass EmptyOverflowBuilder. System will not add
 "show more" icon to toolbar menu when $overflowBuilder returns
 empty set of options.
 - both ToolbarBulder and OverflowMenuBuilders (except
 EmptyOverflowBuilder) will run 'MobileMenu' hook. Extensions should
 listen to hook, and inject it's own menu entries at their leisure.

Required follow-ups:
 - SkinMinerva provides isAllowedAction() method which is used
 both in the skin code and in Toolbar builder. We should extract
 that method into separate service
 - SkinMinerva provides getHistoryUrl() method which is used
 both in the skin code and in Toolbar builder. We should provide
 MinervaUrls service that knows how to build custom mobile URLs.

Bug: T221792
Change-Id: Ie08c4b61cea60c3a42fbf796a39360feea22bc33
2019-06-05 21:07:40 +02:00
Piotr Miazga 9d1217e13e PageActions menu elements should be built by using IMenuElement
To simplify and make code reusable all menu elements should be built
by using Builder pattern. This a first step, first we the pageActions
methods should return Group object/IMenuElement objects, then in the
second step we will extract this logic into Director/Builder
classes leaving SkinMinerva class much smaller.

Bug: T221792
Change-Id: Ic51c4ca4139919fc3c5f3ada8b1b2fe5d23031d7
2019-06-05 13:08:33 +02:00
jenkins-bot cb7dfc2dc6 Merge "Untangle watchstar icon" 2019-06-04 22:17:50 +00:00
Jan Drewniak 7af32bc309 Treat anonymouse user IP pages as UserPages
Ensure SkinUserPageHelper::isUserPage() returns true for user pages
that are IP addresses.

Also adds the page-action menu to all user pages.

Bug: T220114
Change-Id: I3703899bc9ff0042c74260d36f48a388b78b0b6b
2019-06-04 11:53:07 +02:00
jenkins-bot 9dd0d21029 Merge "Minerva nav_urls are used only when OverflowMenu is present" 2019-06-03 17:26:03 +00:00
jenkins-bot 4ef947da28 Merge "Watchstar should respect viewmywatchlist|editmywatchlist permissions" 2019-06-03 16:16:58 +00:00
Piotr Miazga 4ec9b06a77 Watchstar should respect viewmywatchlist|editmywatchlist permissions
If viewmywatchlist|editmywatchlist permisions were set to false for
anonymous user, MinervaSkin would show a watchstar icon that links
to LoginPage, even if user was logged in. Clicking watching action
would cause browser to reload the page without any effect.
Under the hood - system would redirect to login, and then the login
page would redirect user back to the article page because user is
logged in.

MinervaSkin should respect viewmywatchlist|editmywatchlist
permissions. If user do not have access to watchlist, do not show
watch icon.

Bug: T221792
Change-Id: I26a1133a7ccff6a4adcdc72d594d0902bfa8ff79
2019-05-31 17:34:35 +00:00
Piotr Miazga 82a2edf585 Untangle watchstar icon
The SkinMinerva::createWatchPageAction() was depending upon
$tpl['content_navigation']['actions'] object, which is created by
SkinTemplate::buildContentNavigationUrls(). Although only 'watch'
and 'unwatch' keys were used, moreover, code was using only 'href'
property from both 'watch' and 'unwatch'. All other props are
overrided, not used when rendering. Also the title of unwatch
icon was set to "watch this page" which was incorrect.

This system was bit complex to manage (we should provide dependencies
not pass the whole 'content_navigation']['actions'] array). It would
also make further refactoring more difficult, as watchstar icon
shouldn't depened on quicktemplate stuff. We were using only href
attribute which is super easy to calculate.

Changes:
 - do not depend upon $actions, get href by using $title->getLocalUrl
 - set proper title for unwatch icon
 - simplified SkinMinerva::createWatchPageAction() logic

Bug: T221792
Change-Id: I9609949b60a7e2f2f0a947c05c80c89be32d4cb1
2019-05-29 17:37:40 +02:00
Santhosh Thottingal 80484b74de
Fix a comment about SkinMinerva::buildPersonalUrls
Change-Id: Iaff610894ee34f343a735990614e569b4682a4f2
2019-05-27 12:10:20 +05:30
Jan Drewniak 078aab76d8 Adds AMC styles for action=history page
Styles the action=history page to resemble it's desktop
counterpart for users in AMC mode.

Bug: T219895
Change-Id: Ide359724a4628f69ef03acee7718d70c698b8faf
2019-05-22 14:24:43 +02:00