From c0ab8046ac7d2e7eb96c9126ef0ab7e261f13917 Mon Sep 17 00:00:00 2001 From: Jan Drewniak Date: Thu, 7 Mar 2019 21:50:57 +0100 Subject: [PATCH] Add config option for showing history link in page actions menu Bug: T213352 Change-Id: I6a53a7303434b0fd374bc5b6ea2dbc8e760807e6 --- README.md | 13 +++++++++++++ includes/MinervaHooks.php | 10 ++++++++++ includes/skins/SkinMinerva.php | 10 ++++------ skin.json | 5 +++++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 278de25..c848e4d 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,19 @@ Controls whether page issues should be replaced with a "Page issues" link (false Controls whether the talk option should be displayed at the top of the page. This will work for all pages except the main page. +#### $wgMinervaHistoryInPageActions + +* Type: `Array` +* Default: +```php + [ + 'beta' => false, + 'base' => false, + 'amc' => true, + ] +``` +Controls whether the history link appears in the page actions menu. + #### $wgMinervaShowShareButton * Type: `Array` diff --git a/includes/MinervaHooks.php b/includes/MinervaHooks.php index 183574a..dd37aa3 100644 --- a/includes/MinervaHooks.php +++ b/includes/MinervaHooks.php @@ -74,6 +74,13 @@ class MinervaHooks { $config->get( 'MinervaTalkAtTop' ) ) ); + $featureManager->registerFeature( + new MobileFrontend\Features\Feature( + 'MinervaHistoryInPageActions', + 'skin-minerva', + $config->get( 'MinervaHistoryInPageActions' ) + ) + ); } catch ( RuntimeException $e ) { // features already registered... // due to a bug it's possible for this to run twice @@ -207,6 +214,9 @@ class MinervaHooks { => $featureManager->isFeatureAvailableInContext( 'MinervaShareButton', $mobileContext ), SkinMinerva::OPTION_TOGGLING => true, SkinMinerva::OPTION_MOBILE_OPTIONS => true, + SkinMinerva::OPTIONS_HISTORY_PAGE_ACTIONS => $featureManager->isFeatureAvailableForCurrentUser( + 'MinervaHistoryInPageActions' + ), ] ); } } diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php index 55a1505..86b11b5 100644 --- a/includes/skins/SkinMinerva.php +++ b/includes/skins/SkinMinerva.php @@ -38,6 +38,7 @@ class SkinMinerva extends SkinTemplate { const OPTION_TOGGLING = 'toggling'; const OPTIONS_MOBILE_BETA = 'beta'; const OPTIONS_TALK_AT_TOP = 'talkAtTop'; + const OPTIONS_HISTORY_PAGE_ACTIONS = 'historyInPageActions'; /** @const LEAD_SECTION_NUMBER integer which corresponds to the lead section in editing mode */ @@ -111,6 +112,7 @@ class SkinMinerva extends SkinTemplate { self::OPTION_TOGGLING => false, self::OPTION_PAGE_ISSUES => false, self::OPTIONS_TALK_AT_TOP => false, + self::OPTIONS_HISTORY_PAGE_ACTIONS => false, ]; /** @@ -1158,9 +1160,7 @@ class SkinMinerva extends SkinTemplate { $menu[] = $this->createWatchPageAction( $actions ); } - if ( - MediaWikiServices::getInstance()->getService( 'MobileFrontend.AMC.UserMode' )->isEnabled() - ) { + if ( $this->getSkinOption( self::OPTIONS_HISTORY_PAGE_ACTIONS ) ) { $menu[] = $this->getHistoryPageAction( $actions ); } @@ -1278,13 +1278,11 @@ class SkinMinerva extends SkinTemplate { * pageActionMenu.mustache template. */ protected function getHistoryPageAction() { - $baseResult = [ + return [ 'class' => MinervaUI::iconClass( 'clock-gray' ), 'text' => $this->msg( 'mobile-frontend-history' ), 'href' => $this->getHistoryUrl( $this->getTitle() ) ]; - - return $baseResult; } /** diff --git a/skin.json b/skin.json index 92ce68e..24f611b 100644 --- a/skin.json +++ b/skin.json @@ -40,6 +40,11 @@ "beta": false, "amc": true }, + "MinervaHistoryInPageActions": { + "base": false, + "beta": false, + "amc": true + }, "MinervaShowCategoriesButton": { "base": false, "beta": true