mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-27 17:10:19 +00:00
Vector sticky header dynamic edit icons order
Problem: Edit-links are shown in static order in sticky header always source edit 1st, then visual editor Patch Changes: - We now read the configuration from the visual editor extension. - Based on the order that page views portlet shows of the tabs, we add the icons to the sticky header in the same order as it shows in the portlet. Bug: T318447 Change-Id: I2d926bf84131b13c881b09c87ccd5d2010c0dffc
This commit is contained in:
parent
4a26581901
commit
0903ecba9c
|
@ -58,25 +58,26 @@ class VectorComponentStickyHeader implements VectorComponent {
|
|||
private $search;
|
||||
/** @var VectorComponent|null */
|
||||
private $langButton;
|
||||
|
||||
/** @var bool */
|
||||
private $includeEditIcons;
|
||||
private $visualEditorTabPositionFirst;
|
||||
|
||||
/**
|
||||
* @param MessageLocalizer $localizer
|
||||
* @param VectorComponent $searchBox
|
||||
* @param VectorComponent|null $langButton
|
||||
* @param bool $includeEditIcons whether to include edit icons in the result
|
||||
* @param bool $visualEditorTabPositionFirst
|
||||
*/
|
||||
public function __construct(
|
||||
MessageLocalizer $localizer,
|
||||
VectorComponent $searchBox,
|
||||
$langButton = null,
|
||||
$includeEditIcons = false
|
||||
bool $visualEditorTabPositionFirst = false
|
||||
) {
|
||||
$this->search = $searchBox;
|
||||
$this->langButton = $langButton;
|
||||
$this->includeEditIcons = $includeEditIcons;
|
||||
$this->localizer = $localizer;
|
||||
$this->visualEditorTabPositionFirst = $visualEditorTabPositionFirst;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,11 +100,9 @@ class VectorComponentStickyHeader implements VectorComponent {
|
|||
self::HISTORY_ICON,
|
||||
self::WATCHSTAR_ICON,
|
||||
];
|
||||
if ( $this->includeEditIcons ) {
|
||||
$icons[] = self::EDIT_WIKITEXT_ICON;
|
||||
$icons[] = self::EDIT_PROTECTED_ICON;
|
||||
$icons[] = self::EDIT_VE_ICON;
|
||||
}
|
||||
$icons[] = $this->visualEditorTabPositionFirst ? self::EDIT_VE_ICON : self::EDIT_WIKITEXT_ICON;
|
||||
$icons[] = $this->visualEditorTabPositionFirst ? self::EDIT_WIKITEXT_ICON : self::EDIT_VE_ICON;
|
||||
$icons[] = self::EDIT_PROTECTED_ICON;
|
||||
$iconButtons = [];
|
||||
foreach ( $icons as $icon ) {
|
||||
$iconButtons[] = new VectorComponentButton(
|
||||
|
|
|
@ -183,6 +183,23 @@ class SkinVector22 extends SkinMustache {
|
|||
return ExtensionRegistry::getInstance()->isLoaded( 'UniversalLanguageSelector' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether Visual Editor Tab Position is first
|
||||
*
|
||||
* @param array $dataViews
|
||||
* @return bool
|
||||
*/
|
||||
final protected function isVisualEditorTabPositionFirst( $dataViews ): bool {
|
||||
$names = [ 've-edit', 'edit' ];
|
||||
// find if under key 'name' 've-edit' or 'edit' is the before item in the array
|
||||
for ( $i = 0; $i < count( $dataViews[ 'array-items' ] ); $i++ ) {
|
||||
if ( in_array( $dataViews[ 'array-items' ][ $i ][ 'name' ], $names ) ) {
|
||||
return $dataViews[ 'array-items' ][ $i ][ 'name' ] === $names[ 0 ];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the ULS button if it's modern Vector, languages in header is enabled,
|
||||
* the ULS extension is enabled, and we are on a subect page. Hide it otherwise.
|
||||
|
@ -480,7 +497,7 @@ class SkinVector22 extends SkinMustache {
|
|||
],
|
||||
'quiet',
|
||||
) : null,
|
||||
true
|
||||
$this->isVisualEditorTabPositionFirst( $portlets[ 'data-views' ] )
|
||||
) : null,
|
||||
'data-vector-settings-button' => new VectorComponentButton(
|
||||
$this->msg( 'vector-limited-width-toggle' ),
|
||||
|
|
Loading…
Reference in a new issue