Hygiene: SkinOptions should know what are AMC options

Do not hardcode special handling of Options in other places
than SkinOptions. SkinOptions should be only one place that
knows all interpedences.

Change-Id: I9ad8c1560332665dbcd88ccc7105fb253a2f41b9
This commit is contained in:
Piotr Miazga 2019-08-02 16:23:28 +02:00
parent d8de612e0c
commit 05cdcc09c8
2 changed files with 24 additions and 11 deletions

View file

@ -109,4 +109,26 @@ final class SkinOptions {
return false;
}
/**
* Check if user enabled any of the options bundled in the AMC mode
*
* @todo this shouldn't exist, each option should provide it's own logic/styles/js modules
*
* @return bool
*/
public function isAnyAMCOptionEnabled() {
$keys = [
self::AMC_MODE,
self::TALK_AT_TOP,
self::HISTORY_IN_PAGE_ACTIONS,
self::TOOLBAR_SUBMENU,
self::TABS_ON_SPECIALS
];
foreach ( $keys as $key ) {
if ( $this->skinOptions[$key] ) {
return true;
}
}
return false;
}
}

View file

@ -938,20 +938,11 @@ class SkinMinerva extends SkinTemplate {
$styles[] = 'skins.minerva.icons.loggedin';
}
$keys = [
SkinOptions::AMC_MODE,
SkinOptions::TALK_AT_TOP,
SkinOptions::HISTORY_IN_PAGE_ACTIONS,
SkinOptions::TOOLBAR_SUBMENU,
SkinOptions::TABS_ON_SPECIALS
];
$includeAMCStyles = array_reduce( $keys, function ( $val, $key ) {
return $val || $this->skinOptions->get( $key );
}, false );
if ( $includeAMCStyles ) {
if ( $this->skinOptions->isAnyAMCOptionEnabled() ) {
$styles[] = 'skins.minerva.amc.styles';
$styles[] = 'wikimedia.ui';
}
if ( $this->skinOptions->get( SkinOptions::AMC_MODE ) ) {
// ToolbarBuilder is reusing the Contributions icon in toolbar @see T224735
$styles[] = 'skins.minerva.mainMenu.icons';