Commit graph

29 commits

Author SHA1 Message Date
vladshapik 6da72c8099 Avoid using User::isIP
Remove using of User::isIP since this method will be hard-deprecated. Now it is soft-deprecated

Bug: T275602
Change-Id: I01a0c2ef4d750cf0e81a9345ee462787d4ee28da
2021-03-02 14:29:58 +02:00
MusikAnimal 4a3e1fa9e8 Show half star for temporarily watched pages
This does not complete watchlist expiry support in MinervaNeue. It only
instructs the skin to show a half star instead of a full star on page
load if the page is being temporarily watched.

Bug: T251690
Change-Id: Ib5c479dcfe49041152ba662c56cc630c32eb220e
2020-08-27 11:57:13 -04:00
Jdlrobson 74838b2fa2 Revert "ServiceWiring: Avoid usage of deprecated Title::getSubjectPage()"
This reverts commit ae8e3ad58b.

Reason for revert: This led to T260155 as the internal class uses
isSubPage which is not available on LinkTarget

Bug: T260155
Change-Id: I783f41e70cf1cf3b91737bce9cbf9ac729a778df
2020-08-11 15:50:44 +00:00
Derick A ae8e3ad58b ServiceWiring: Avoid usage of deprecated Title::getSubjectPage()
SkinUserPageHelper::__construct() should be able to consume a LinkTarget
too as NamespaceInfo::getSubjectPage() method returns a LinkTarget and
the Title::getSubjectPage() is deprecated.

Change-Id: I08bfc9bb21772b450798b6354bee2ab09d5dba4d
2020-08-08 14:07:48 +01:00
jdlrobson 2e450e104e Donate link should be in a separate group in main menu
Bug: T219793
Change-Id: I7501c87eaa799e4c8a9052f5e3f650a89f376d1b
2020-06-29 14:38:34 -07:00
Umherirrender 1b5d9ea755 build: Updating composer dependencies
* php-parallel-lint/php-console-highlighter: 0.4.0 → 0.5.0
* php-parallel-lint/php-parallel-lint: 1.0.0 → 1.2.0
* mediawiki/mediawiki-phan-config: 0.9.0 → 0.10.2
* mediawiki/mediawiki-codesniffer: 29.0.0 → 31.0.0
* mediawiki/minus-x: 1.0.0 → 1.1.0

Additional changes:
* Replaced "jakub-onderka" packages with "php-parallel-lint".
* remove taint-check, now bundled with phan-config

Change-Id: I202a48e1b0aab38181a402d6f2661d782ecd79e2
2020-06-01 19:43:05 +00:00
Reedy 01f824f684 Fix namespace of SkinUserPageHelper
Allows autoloading of file

Change-Id: Ife276b5802e3cdcfd5789a7a91684317c81d5bb3
2020-05-01 02:29:54 +01:00
Bartosz Dziewoński 700b1c43e9 Allow passing context to MinervaPagePermissions
Previously it always used the global context RequestContext::getMain(),
which is basically equivalent to using $wgTitle or $wgUser, and will
not produce the correct results when used in other situations than
regular web requests (e.g. API requests or jobs).

MinervaPagePermissions is required to parse pages (due to the custom
section edit links in SkinMinerva::doEditSectionLink), which is often
done in API requests or jobs.

Pass the appropriate context in SkinMinerva::getPermissions(). This
fixes T234868. Note that MinervaPagePermissions is also used elsewhere
and I am not fixing those cases.

Depends-On: Iaa83e5f801c7776bf8218d8ce7484e2485b227d4
Bug: T234868
Change-Id: I2d6fd525f20a0b6beeeaa731f6b8caa471b8529d
2020-01-29 10:33:36 -08:00
Umherirrender 5b0a4f30b2 build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
Change-Id: I529c6a67eeb5eb012031b69ef63f4338f3685178
2020-01-26 20:26:31 +01:00
Nicholas Ray ec93d34370 Resemble AMC mode for all users on user pages & user talk pages
This commit:

* Removes the blue secondary action links found on User pages

* Modifies ToolbarBuilder to add the contributions
icon into the toolbar when on a user page/user talk page.

* Turns on HISTORY_IN_PAGE_ACTIONS, TOOLBAR_SUBMENU,
TALK_AT_TOP skin options for all users on user pages / user talk pages.

* Languages icon is moved to overflow menu

* Remove $userPageHelper param from UserNamespaceOverflowBuilder as
it isn't using it and it is confusing to pass it in

Bug: T232653
Bug: T235681
Depends-On: I2138472e68d8cab1c50cbb42807bd5b79e7e2749
Change-Id: I940e5cf7638ff38686eeca3d41554b8a22d35615
2019-12-13 14:10:43 -08:00
Stephen Niedzielski 54060a3cc4 [edit] [UI] hide edit section links for blocked users
When a user is blocked, only present the "locked" page edit link. Omit
the section edit links entirely.

The logic for checking user permissions already existed in
ToolbarBuilder. Move this logic to MinervaPagePermissions and add a new
"EDIT_OR_CREATE" action distinct from IMinervaPagePermissions::EDIT.
These names will be revisited in a following patch.

Bug: T206265
Change-Id: Ia43a670a259cabc313c004fe06c91e078bd41562
2019-09-03 22:29:43 +02:00
jdlrobson 9150aec131 Feature flag overhaul
Two new feature flags:
1) MinervaPersonalMenu
2) MinervaAdvancedMainMenu

Changes:
* AMC defaults to false on desktop - desktop doesn't have AMC mode it just
enables several skin options.
* WHen inserting a link at the bottom of the page check whether the talk at top
of the page (tabs) is enabled.. not AMC
* Update ServiceWiring to construct menu based on MinervaAdvancedMainMenu
and  MinervaPersonalMenu - note when former is enabled but not latter there is
no way to logout. Noted in README.
* Use one entry point for skins.minerva.amc.styles/index.less
* Document files inside skins.minerva.amc.styles to make it clear which features
they are associated with
* Drop history page styles when AMC is disabled - it's not possible to ever get to
these as the history page redirects in non-AMC mode
* Rename the class .minerva--amc-enabled to minerva--history-page-action-enabled
to reflect its real purpose and move styles from skins.minerva.base.styles to skins.minerva.amc.styles
No need to worry about cached HTML as AMC runs without cache...
* Remove isAnyAMCOptionEnabled - it's an antipattern and should be discouraged as it discourages the
art of feature flagging. Nothing is using it after these changes.
* The AMC_MODE flag is disabled. There is no need for this - AMC is not a feature and therefore not a
skin option. It is a mechanism for turning on other skin options. Tests are updated.

Testing:
It should now be possible to enable any feature in `beta` and see it in the beta of the
site.

Bug: T229295
Change-Id: I48959905f5c09721b14a27aa1a5ad82849ac6263
2019-08-23 10:48:14 -07: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 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
Kosta Harlan 2669afe911 Set title from Skin relevant title
This allows extensions which set relevant title to make use of theme elements
rendered by Minerva on pages where UserPageHelper returns true for isUserPage.

See also I20cce5bd58cdfbf21c0917905df15ee1f36e68d1

Bug: T225663
Change-Id: I4c1add98167ae908a05b2224adea0c417eb4a290
2019-07-31 13:17:49 +02: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
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
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 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 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 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 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 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