The Minerva permission manager distinguishes between user edit
permissions and content model edit support. Rename EDIT constant to
CONTENT_EDIT to help clarify the distinction.
The resolved name in skin.json is not updated to avoid deprecation
policy.
Change-Id: If86b8b5cd9d04ec2881931a3b629bc50e1dd9252
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
Change the info icon from an outline ("info") to a filled or inverted
("infoFilled") representation.
Bug: T230693
Change-Id: I10f9421661c5244c6859871793bd75650cb0e1e5
Changes:
- added support of event-data-name to toggle list and all menu
entries
- track main menu open actions
- prefix all menu interactions with `menu.`
- prefix menu opening with `ui.`
- track tab clicks (also a part of new ui)
- track notification icon clicks
We're not tracking the Download icon as it has it's own
instrumentation.
Bug: T220016
Change-Id: I442103c1f8967c6710429329f024f266c9b11ea6
Changes:
- Title::getTalkPage() is deprecated, use NamespaceInfo instead
- Http::isValidURI is deprecated, use MWHttpRequest instead
Change-Id: I6938fe93d18372ef855f398a506c8b5ba68b640e
For better readability Main Menu building classes should
contain MainMenu in the name as not everyone uses smart
IDEs.
Change-Id: Ica3bf4bbd18cab1a6cd88061dfb9d1ce51b0f63d
* 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
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
Old MainMenuAdvancedBulder doesn't require the personal section
any more as that section is handled by new UserMenu.
Additionally we should add hook support in the new UserMenu so
different extensions can add their own menu entries.
Bug: T214540
Change-Id: Ibbfbee9d13d58c92d90a22d2b6dcf124b1313c23
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
Break up Menu/DefaultBuilder into functions that are reusable without
inheritance. The functions do not need much state to produce their
outputs and a weighty inheritance hierarchy makes the code difficult to
reason about. The functions are used in a following patch for the user
menu. They're now simple, independent, static functions in BuilderUtil
that are easy to reason about and compose.
Also, ban inheritance via `final` in a few places nearby. Inheritance
has not worked well in MobileFrontend and enabling it should be a
special deliberate case, not a default. E.g., in the user menu, the
changes could have been to the base class' getPersonalTools() method
such that the client passes a parameter for the advanced config or maybe
just override it in the subclass. In either case, it makes the whole
hierarchy nuanced and harder to reason about for something that should
be dead simple.
Bug: T214540
Change-Id: I6e9a2b36a1bff387eb3b33ea65b0a6806962810a
- Separate AuthMenuEntry into reusable parts.
- Add some missed finals in nearby classes.
Bug: T214540
Change-Id: Icf285bf8d2b791dd1aa4ee37ae90d27afe42bd91
Make an interface for changing the URL of the menu profile item. This
functionality is needed by Growth and a subsequent patch will provide a
second profile implementation that should implement this interface.
Bug: T214540
Change-Id: Ie3647ac52a83b4cc34f3582a41c5d5524343965c
There's no reason to copy and paste all this here. These icons
can be imported directly from core using ResourceLoaderOOUIIconPackModule
Depends-On: I7800da87a6a10399f705b43e05c8592c766bae6f
Change-Id: I1f25aaca9b7313cd95cefc7f5629b8a7e65c887f
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
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
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
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
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
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
Allow editors to define a different URL for random
by editing
/wiki/MediaWiki:Randompage-url
e.g. Special:RandomRootpage
Bug: T188697
Change-Id: I72bfbb9b02c99faa0c42c3212939f59b9b87149b
* 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
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
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
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
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
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
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
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
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
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
Instead of using Title::quickUserCan() and User::isBlockedFrom()
we have to use the PermissionManager.
Bug: T221792
Change-Id: I5bffd859140f73a78fa2fc155b7b2343eefd3807
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