mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-23 22:03:39 +00:00
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
This commit is contained in:
parent
fa3ad50aa4
commit
4a3e1fa9e8
|
@ -25,7 +25,7 @@
|
|||
},
|
||||
{
|
||||
"resourceModule": "skins.minerva.icons.wikimedia",
|
||||
"maxSize": "0.7KB"
|
||||
"maxSize": "0.8KB"
|
||||
},
|
||||
{
|
||||
"resourceModule": "skins.minerva.mainMenu.icons",
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace MediaWiki\Minerva\Menu\PageActions;
|
|||
|
||||
use ExtensionRegistry;
|
||||
use Hooks;
|
||||
use MediaWiki\Config\ServiceOptions;
|
||||
use MediaWiki\Minerva\LanguagesHelper;
|
||||
use MediaWiki\Minerva\Menu\Entries\IMenuEntry;
|
||||
use MediaWiki\Minerva\Menu\Entries\LanguageSelectorEntry;
|
||||
|
@ -74,6 +75,18 @@ class ToolbarBuilder {
|
|||
*/
|
||||
private $languagesHelper;
|
||||
|
||||
/**
|
||||
* @var bool Correlates to $wgWatchlistExpiry feature flag.
|
||||
*/
|
||||
private $watchlistExpiryEnabled;
|
||||
|
||||
/**
|
||||
* ServiceOptions needed.
|
||||
*/
|
||||
public const CONSTRUCTOR_OPTIONS = [
|
||||
'WatchlistExpiry',
|
||||
];
|
||||
|
||||
/**
|
||||
* Build Group containing icons for toolbar
|
||||
* @param Title $title Article title user is currently browsing
|
||||
|
@ -86,6 +99,7 @@ class ToolbarBuilder {
|
|||
* user talk page, UserPageHelper should be instantiated with the user page
|
||||
* Title and NOT with the user talk page Title.
|
||||
* @param LanguagesHelper $languagesHelper Helper to check title languages/variants
|
||||
* @param ServiceOptions $options
|
||||
*/
|
||||
public function __construct(
|
||||
Title $title,
|
||||
|
@ -94,7 +108,8 @@ class ToolbarBuilder {
|
|||
IMinervaPagePermissions $permissions,
|
||||
SkinOptions $skinOptions,
|
||||
SkinUserPageHelper $relevantUserPageHelper,
|
||||
LanguagesHelper $languagesHelper
|
||||
LanguagesHelper $languagesHelper,
|
||||
ServiceOptions $options
|
||||
) {
|
||||
$this->title = $title;
|
||||
$this->user = $user;
|
||||
|
@ -103,6 +118,7 @@ class ToolbarBuilder {
|
|||
$this->skinOptions = $skinOptions;
|
||||
$this->relevantUserPageHelper = $relevantUserPageHelper;
|
||||
$this->languagesHelper = $languagesHelper;
|
||||
$this->watchlistExpiryEnabled = $options->get( 'WatchlistExpiry' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -220,17 +236,18 @@ class ToolbarBuilder {
|
|||
* @throws MWException
|
||||
*/
|
||||
protected function createWatchPageAction(): IMenuEntry {
|
||||
$title = $this->title;
|
||||
$user = $this->user;
|
||||
$isWatched = $title && $user->isLoggedIn() && $user->isWatched( $title );
|
||||
$isWatched = $this->user->isLoggedIn() && $this->user->isWatched( $this->title );
|
||||
$isTempWatched = $this->watchlistExpiryEnabled &&
|
||||
$isWatched &&
|
||||
$this->user->isTempWatched( $this->title );
|
||||
$newModeToSet = $isWatched ? 'unwatch' : 'watch';
|
||||
$href = $user->isAnon()
|
||||
? $this->getLoginUrl( [ 'returnto' => $title ] )
|
||||
: $title->getLocalURL( [ 'action' => $newModeToSet ] );
|
||||
$href = $this->user->isAnon()
|
||||
? $this->getLoginUrl( [ 'returnto' => $this->title ] )
|
||||
: $this->title->getLocalURL( [ 'action' => $newModeToSet ] );
|
||||
|
||||
if ( $isWatched ) {
|
||||
$msg = $this->messageLocalizer->msg( 'unwatch' );
|
||||
$icon = 'unStar-progressive';
|
||||
$icon = $isTempWatched ? 'halfStar-progressive' : 'unStar-progressive';
|
||||
} else {
|
||||
$msg = $this->messageLocalizer->msg( 'watch' );
|
||||
$icon = 'star-base20';
|
||||
|
@ -243,7 +260,9 @@ class ToolbarBuilder {
|
|||
'wikimedia'
|
||||
);
|
||||
|
||||
if ( $isWatched ) {
|
||||
if ( $isTempWatched ) {
|
||||
$iconClass .= ' temp-watched';
|
||||
} elseif ( $isWatched ) {
|
||||
$iconClass .= ' watched';
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
* @file
|
||||
*/
|
||||
|
||||
use MediaWiki\Config\ServiceOptions;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Minerva\LanguagesHelper;
|
||||
use MediaWiki\Minerva\Menu\Definitions;
|
||||
|
@ -98,7 +99,9 @@ return [
|
|||
$services->getService( 'Minerva.Permissions' ),
|
||||
$skinOptions,
|
||||
$relevantUserPageHelper,
|
||||
$languagesHelper
|
||||
$languagesHelper,
|
||||
new ServiceOptions( PageActionsMenu\ToolbarBuilder::CONSTRUCTOR_OPTIONS,
|
||||
$services->getMainConfig() )
|
||||
);
|
||||
if ( $skinOptions->get( SkinOptions::TOOLBAR_SUBMENU ) ) {
|
||||
$overflowBuilder = $relevantUserPageHelper->isUserPage() ?
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var WATCHED_CLASS = 'mw-ui-icon-wikimedia-unStar-progressive',
|
||||
TEMP_WATCHED_CLASS = 'mw-ui-icon-wikimedia-halfStar-progressive',
|
||||
UNWATCHED_CLASS = 'mw-ui-icon-wikimedia-star-base20';
|
||||
|
||||
/**
|
||||
|
@ -9,7 +10,7 @@ var WATCHED_CLASS = 'mw-ui-icon-wikimedia-unStar-progressive',
|
|||
module.exports = function init( $icon ) {
|
||||
$icon.on( 'watchpage.mw', function ( _ev, action ) {
|
||||
$( this ).find( 'a' ).removeClass(
|
||||
[ WATCHED_CLASS, 'watched', UNWATCHED_CLASS ]
|
||||
[ WATCHED_CLASS, 'watched', TEMP_WATCHED_CLASS, UNWATCHED_CLASS ]
|
||||
).addClass(
|
||||
action === 'watch' ? [ WATCHED_CLASS, 'watched' ] : UNWATCHED_CLASS
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue