Commit Graph

265 Commits

Author SHA1 Message Date
Piotr Miazga b8abf809ac Hygiene: rename $navUrls to $toolbox
Previously we were passing the $tpl->data['nav_urls'] array,
because of that all params were called $navUrls. That approach
was incorrect and we have to pass $tpl->getToolbox(), which
means all $navUrls variables/paramters have to be renamed to
$toolbox for better clarity

Changes:
 - renamed $navUrls to $toolbox
 - update phpdocs blocks
 - renamed buildEntry() into build()

Bug: T222630
Change-Id: Id0023cfbb9779c502edc0f91e31a2a912af84084
2019-06-14 19:05:37 +02: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
Derick Alangi a9ead1938b menu: Add system generated logoutToken on logout action in Minerva
Upon building the menu components for logged in users, the logoutToken
was not properly appended to the logout URL. The URL is supposed to be

`?title=Special:UserLogout&returnto=...&logoutToken=...`

and not what was rendered previously, see below

`?title=Special:UserLogout&<token>`

The absense of the 'logoutToken' param prompted an intermediate step asking
users to confirm the logout action. We don't need this in Minerva if users want
to logout from their accounts and asking users to confirm this action is annoying.

We want the user to be able to logout when the "Logout" button is clicked
and the system would have generated a logout token and appended to the logout
URL in the format specified above. This patch has been tested locally and
everything works just fine.

Bug: T225220
Change-Id: I20f30db707915179a0604a1dc9061d8db225a230
2019-06-11 12:54:37 +01: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 ececc1b98c Define default OPTION_TABS_ON_SPECIALS option
If the option is not default, system will throw OutOfBoundsException
when trying to access OPTION_TABS_ON_SPECIALS value.

Bug: T225279
Change-Id: I01ff016caea0bfd961c71e15388d670cd93acc7f
2019-06-07 11:44:53 +00:00
Kosta Harlan b035d76d0f Add method for getting menu entry by name
* Also fix typo with $returnToQuery
* More usage of DomainException

Bug: T222834
Change-Id: I5623741779eebe4c5694bdbd7a1aa1bcdd7f04c6
2019-06-06 13:04:29 -04:00
jenkins-bot b64585dfad Merge "Hygiene: Use PermissionsManager instead of deprecated methods" 2019-06-06 00:38:14 +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
jenkins-bot 3ee4891bc5 Merge "Encapsulate Login/profile/logout meny entry logic into AuthMenuEntry" 2019-06-05 21:43:28 +00: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 204cdb2a74 Hygiene: Use PermissionsManager instead of deprecated methods
Instead of using Title::quickUserCan() and User::isBlockedFrom()
we have to use the PermissionManager.

Bug: T221792
Change-Id: I5bffd859140f73a78fa2fc155b7b2343eefd3807
2019-06-05 21:12:10 +02: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
Piotr Miazga 047618c24d Hygiene: SkinUserPageHelper should support Title = null
In some edge cases the RequestContext::getTitle() can return null
instead of Title object. Similar situations already happened in the
past (see T179833). The RequestContext::getTitle() documentation
says it can return null, therefore code should be resilient and
support such situations, even if there are not common.

Bug: T221792
Change-Id: I842f8c49f20e511fda3b081e59a06586810bc748
2019-06-04 17:17:58 +02:00
Kosta Harlan 1e87c62191 Add hook to override SkinOptions, and allow overriding tabs output
Bug: T222835
Change-Id: I0d390eadbd0a8de7f328360df5c60d9fb2225db1
2019-06-04 10:24:30 -04: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
jenkins-bot c4b31067ab Merge "Provide IMenuEntry interface" 2019-05-17 13:12:09 +00:00
jenkins-bot 7a83809f4d Merge "Minerva shouldn't call Skin::getNewTalks() twice" 2019-05-14 15:34:44 +00:00
Piotr Miazga 39a2078472 Minerva shouldn't call Skin::getNewTalks() twice
The Skin::getNewTalks() is already called in SkinTemplate::prepareQuickTemplate.
There is no need to call this function again, as is pretty heavy. Instead of
calling it second time, just re-use the value stored in the QuickTemplate

Change-Id: I0e9491405f4d760278db3a423ee14e8f80720291
2019-05-14 16:09:18 +02:00
Piotr Miazga 6905b85d67 Provide IMenuEntry interface
The Group shouldn't depend upon concrete MenuEntry definition.
Different Menus can present different MenuElements. Code should
allow easy extensions, not limit only to single MenuEntry
definition.

Changes:
 - introduced IMenuEntry interface
 - MenuEntry implements IMenuEntry
 - removed isJSOnly from logic as it's related only to one menu
 element (Watchstar) and Group shouldn't be aware of some special
 handling for some elements. The IMenuEntry shouldn't define this
 method
 - getName, getComponents, getCSSClasses should have defined return
 types

Bug: 1221792
Change-Id: I0646df734e869c26bfa8c3a772200e8258a8acce
2019-05-14 13:12:37 +02:00
Piotr Miazga 6c70498e91 Hygiene: Deduplicate MenuEntry uniqness check code
The check to verify uniqness of the MenuEntry $name existed
twice, in insert() and in insideAfter() methods. To respect
"do not repeat" yourself rule, we should keep this check
in one place only.

Bug: T221792
Change-Id: I973b0427623e579f97ae47f7c80dc2a9db2fcca7
2019-05-14 11:38:39 +02:00
jenkins-bot b503d36560 Merge "MinervaNeue doesn't need PersonalUrls" 2019-05-08 18:35:04 +00:00
Piotr Miazga f4fa534b9d Minerva nav_urls are used only when OverflowMenu is present
There is no need to call SkinTemplate::buildNavUrls() as the 'nav_urls'
from QuickTemplate are used only when OverlfowMenu is present. There is
no need to do that heavy calculation unless we really need it.

Change-Id: I003efcdeffe10f6a3a155932a20c09e8f62c747e
2019-05-07 22:42:49 +02:00
Piotr Miazga 339f1f5789 MinervaNeue doesn't need PersonalUrls
MinervaNeueu do not use any of personal urls on the page. There is
not need to calculate that.

Change-Id: Ie8febe2dc9c03e8988e7100c4656aea65f76e1f1
2019-05-07 22:23:57 +02:00
Piotr Miazga 44d5ffd6e9 MinervaNeue has no sidebar, do not process this method
MinervaNeue doesn't show any sidebar, only MainMenu and
PagetActions menu. There is no need to call original
Skin::buildSidebar() as the result is not used.

Change-Id: Iec60491d4b45b7b6f6ba23525a4f6af08903bb31
2019-05-07 22:21:10 +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
jenkins-bot e0624d1725 Merge "Improve Community Main Menu element handling" 2019-05-02 18:05:46 +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
Stephen Niedzielski b594daf8c8 Fix: AMC overflow menu initial CSS and SSR icons
When advanced mobile contributions is enabled and the overflow menu is
shown:

- The initial state should have no transition. This prevents the menu
  from flickering initially. Move the transition to the checked state
  only.

- The icons should be available for server-side rendered HTML without
  JavaScript. Add wikimedia.ui to the SSR modules.

Bug: T216418#5129152
Change-Id: I3b91f6cdefd4b727c2fb512272d8c4282af632bf
2019-05-01 09:29:50 -06:00
jenkins-bot efcc4792a4 Merge "Hygiene: Various cleanup in Minerva PHP code" 2019-04-20 00:50:19 +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
jenkins-bot 55ad654176 Merge "Update: add secondary page actions submenu in AMC mode" 2019-04-19 22:15:22 +00:00
Stephen Niedzielski 815f3386e3 Update: add secondary page actions submenu in AMC mode
When advanced mobile contributions mode is enabled and
`$wgMinervaOverflowInPageActions` is set, show a secondary overflow menu
on main namespace articles and user namespace pages. The menu content
varies for each namespace. The new submenu is *disabled* by default,
even when AMC is active. This feature should not be deployed until
instrumentation is available.

The secondary menu is rendered in PHP using the existing menu system
with some changes to the template. The checkbox hack is needed for no-
JavaScript keyboard navigation until :focus-within is supported. CSS
additions are documented in the source.

All client side toolbar execution occurs in Toolbar.js. Enhancements are
documented in the source.

Minor changes to the existing download button:
- Move download and edit button initialization to Toolbar.
- Update copy (not visible) from "Download" to "Download PDF".
- When the overflow menu is present, use the "hasText" / label style.

Wikimedia UI icons are copied from OOUI at d00a0ac and seem useful to
expose as HTTP URIs (not data URIs).

The overflow menu does not show for pages provided by the content proxy
since its entries depend on $tpl->data['nav_urls'] being populated.

Bug: T216418
Depends-On: I0781151a8232b6a7b52f79a34298afcecb8e4271
Change-Id: I4b50a0e519024a7ab91dae6ab40b23cf14a03861
2019-04-19 14:51:17 +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
Piotr Miazga 258e635ae5 Extract SkinOptions to separate class
SkinOptions array was used to determine which options are available
for current session. Once we started extracting things from
SkinMinerva class, we found out that lots of things depend on
SkinOptions.

For example MainMenu/PageActionsMenu depend on skinsOptions var.
We could pass $skin object as dependency to a menu builder, but
this would cause a circural dependency (Skin depends on menu builder,
menu builder depends on skin) which is an anti-pattern.
In order to avoid such situations lets prepare first, and extract
the SkinOptions to a separate class, register it as a service
so different parts of Skin Minerva can freely use a single instance
of SkinOptions object.

Bug: T216152
Bug: T221012
Change-Id: Icd5da546e1bfaf8d9bfe86dab3b659a88eae19e4
2019-04-15 20:34:12 +00:00
Piotr Miazga 572ffdf25a Use MediaWikiServices to cache commonly used helpers
SkinMinerva cached the ContentHandler object for better performance.
In the future the ContentHandler will be also used in the Menu,
for better readability, store ContentHandler as Service.

MediaWikiServices will initialize service on first access and cache
it for future needs. Same applies to SkinUserPageHelper,

Bug: T216152
Change-Id: Ia98dc860862360a68556272714669f0c3a13eb1e
2019-04-15 20:50:11 +02:00
jdlrobson e836083ad1 Consult "shouldUseSpecialHistory" when making history page link
This avoids an unnecessary redirect in mobile for AMC users.
Bug: T219874
Change-Id: I049045d44f6e45ebb2c81f90aac4bb20831890df
2019-04-08 22:05:44 +00:00