diff --git a/bundlesize.config.json b/bundlesize.config.json index cc0f950a4..695c3fca2 100644 --- a/bundlesize.config.json +++ b/bundlesize.config.json @@ -25,7 +25,7 @@ }, { "resourceModule": "skins.minerva.icons.wikimedia", - "maxSize": "0.7KB" + "maxSize": "0.8KB" }, { "resourceModule": "skins.minerva.mainMenu.icons", diff --git a/includes/Menu/PageActions/ToolbarBuilder.php b/includes/Menu/PageActions/ToolbarBuilder.php index 288b52e31..e2298d664 100644 --- a/includes/Menu/PageActions/ToolbarBuilder.php +++ b/includes/Menu/PageActions/ToolbarBuilder.php @@ -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'; } diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index 0476abf17..1273626b8 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -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() ? diff --git a/resources/skins.minerva.scripts/watchstar.js b/resources/skins.minerva.scripts/watchstar.js index 906efb619..a12de3a4d 100644 --- a/resources/skins.minerva.scripts/watchstar.js +++ b/resources/skins.minerva.scripts/watchstar.js @@ -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 ); diff --git a/skin.json b/skin.json index 871abc1e0..514418c17 100644 --- a/skin.json +++ b/skin.json @@ -355,6 +355,7 @@ "search", "userAvatar", "star", + "halfStar", "unStar" ] },