Commit Graph

350 Commits

Author SHA1 Message Date
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
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
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
jenkins-bot e0f96e5f7c Merge "Hygiene: remove outdated comment in footer.mustache" 2019-04-04 18:15:30 +00:00
Stephen Niedzielski 4f2c12bf2e Hygiene: remove outdated comment in footer.mustache
Remove old comment. I think this may have been referring `{{.}}` but
that's not present.

Change-Id: If2443027cfc2da970f4c986c6a85406161ee9173
2019-04-04 17:43:35 +00:00
jdlrobson 0be05950af Desktop should use AMC mode
To help us test special pages prior to moving them on mobile it
would be useful to make AMC the default on desktop
where the special page override does not exist

This is also probably what editors on desktop using the Minerva
skin want out of the skin.

On top of this, add an amc class to the body tag so we can
target styles at AMC and/or non-AMC users

Change-Id: I7f3141bae71181131ae4878fd21fb6ff4322c8ca
2019-04-04 17:43:12 +00:00
Stephen Niedzielski a3e524192d Hygiene: reduce getPageActions() visibility
- Reduce MinervaTemplate.getPageActions() visibility from public to
  protected. No one seems to use it.

- Use camelCase instead of lowercase for the pageActionMenu.mustache
  template's pageActions variable. writingwithcaseindifference is
  difficult to read and the templates seem to support casing.

Change-Id: I6d283c7b97eeef6902cb010904748bd8c72b660c
2019-04-04 16:51:42 +00:00
Derick Alangi 88854b90d4 skins: Fix function name case mismatch for getLocalUrl()
Change-Id: I827b27f1caaf36d7bb96f96ede8ca759f94f0b13
2019-04-04 13:30:22 +01:00
Timo Tijhof 23a0f5f78c Simplify code in SkinMinerva::getHeadingHtml
The conditional and comment here were probably copied from
MonoBook or Vector. There, they were used to decide whether
to output an H1 or not.

The way the conditional was placed here, though, was a no-op.
When this condition was false ($pageTitle == '') the implicit
behaviour was to leave $heading unchanged, which is '', hence
it is using the very value it pretends to reject.

Remove this indirection as it behaves the same either way.

Change-Id: Id3056b199172bbd21b350f920dd0640241b0dd95
2019-04-02 20:18:57 +01:00
jdlrobson bb4e8b8689 Do not show page actions bar on action pages
The page actions bar should not show on the following
pages:
?action=history
?action=edit
?action=unwatch
?action=watch

Change-Id: Ib54c332a221d4a1b64064807e693c8882ef97938
2019-03-26 09:59:33 -07:00
Jan Drewniak a809420f8d Add IDs to page-action menu items.
Bug: T215890
Change-Id: I3330f3ccc8226605f44745befc34dcfcc7c474d8
2019-03-26 16:33:03 +00:00
jenkins-bot 1aaad74847 Merge "Remove skins.minerva.icons.images.variants module" 2019-03-22 17:45:04 +00:00
Jan Drewniak 6d34e401ff Remove skins.minerva.icons.images.variants module
This module produces 6 icons:

["clock", "profile"] * ["black", "gray", "white"]

of which only 3 are needed: clock-gray, clock-white, profile-gray.

This patch removes the module and moves the "clock" and "profile"
icons into `skins.minerva.icons.images`. Since that module
does not inline SVG's, the additional cost of adding these icons,
which are loaded at startup, is minimal.

The editLocked.svg icon has also been edited to correct its color.

Bug: T218807
Change-Id: Ib54960eb556dfe0c1ae06d2f73d4f350e519e20f
2019-03-22 09:46:14 -07:00
Jan Drewniak b2607d3a1a Only show history link in page-actions menu if page exists
Bug: T213352
Change-Id: Ib51c68679426fdf0bd4cc33aeda37decebfd4ace
2019-03-21 16:20:22 +01:00
Derick Alangi b3c5745808 includes: Code cleanup for the Minerva codebase
These code cleanups involves the following;
- Consistency in using single quotes as already been
  used in the code base for loading resource loader
  test modules.
- Remove irrelevant else cases when there is a return
  statement in the if cases.
- Remove passing objects as references as they're already
  by default passed by references so no need for &.
- Proper call to getLocalURL() instead of getLocalUrl()
  though PHP doesn't really care much about the case but
  let's use the function names as they are.
- Fix PHPDoc params, remove useless $skin wrongly placed
  in the comment.

The changes in this patch doesn't affect the behavior of
the current system in any way.

Change-Id: I9c886c058592486b7190b9567f79c496855f4ae3
2019-03-19 21:08:57 +01:00
Stephen Niedzielski 88dd2530e7 Update: don't prompt to create User pages
Suppress the redlink drawer for User namespace pages. The redlink drawer
prompts the user to create a missing page but this hinders the usual
workflow for User page visits specifically. A User page is connection to
an account's contributions, age, and other activities and encouraging
the creation of a missing User page when trying to view these
connections is a hindrance, especially if the missing User page is not
associated with the current user.

Bug: T201339
Change-Id: I784493a8ecf28176b5a393cb52d7bfa9fa9b1309
2019-03-19 18:07:32 +00:00
Jan Drewniak 835d54b3dd Remove unnecessary parameter from `getHistoryPageAction`.
Change-Id: I7ff1dee39be6b2cd213cf963605aff3c75bddc96
2019-03-13 11:34:57 +01:00
Jan Drewniak c0ab8046ac Add config option for showing history link in page actions menu
Bug: T213352
Change-Id: I6a53a7303434b0fd374bc5b6ea2dbc8e760807e6
2019-03-07 21:50:57 +01:00