Skip to content

Commit e3a40af

Browse files
jenkins-botGerrit Code Review
authored andcommitted
Merge "Add feature flag for ScopedTypeaheadSearch"
2 parents 251699e + df15eb3 commit e3a40af

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

repo/config/Wikibase.default.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,4 +457,14 @@
457457
* @see https://phabricator.wikimedia.org/T297393
458458
*/
459459
'tmpEnableMulLanguageCode' => false,
460+
461+
/**
462+
* @note This config option is primarily added for the Wikidata transition use-case
463+
* and must be considered temporary. It will be removed in the future with no warning.
464+
*
465+
* @var bool Whether to enable the "scoped type-ahead search" component,
466+
* replacing the standard search bar in Vector 2022.
467+
* @see https://phabricator.wikimedia.org/T338483
468+
*/
469+
'tmpEnableScopedTypeaheadSearch' => false,
460470
];

repo/includes/RepoHooks.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
8585
if ( $settings->getSetting( 'enableEntitySearchUI' ) === true ) {
8686
$skinName = $skin->getSkinName();
8787
if ( $skinName === 'vector-2022' ) {
88-
$out->addModules( 'wikibase.vector.searchClient' );
88+
if ( $settings->getSetting( 'tmpEnableScopedTypeaheadSearch' ) ) {
89+
$out->addModules( 'wikibase.vector.scopedTypeaheadSearch' );
90+
} else {
91+
$out->addModules( 'wikibase.vector.searchClient' );
92+
}
8993
} elseif ( $skinName !== 'minerva' ) {
9094
// Minerva uses its own search widget.
9195
$out->addModules( 'wikibase.ui.entitysearch' );
@@ -983,6 +987,18 @@ public static function onResourceLoaderRegisterModules( ResourceLoader $resource
983987
$modules['wikibase.special.languageLabelDescriptionAliases']['dependencies'][] = 'ext.uls.mediawiki';
984988
}
985989

990+
// temporarily register this RL module only if the feature flag is enabled,
991+
// so that wikis without the feature flag don’t even pay the small cost of loading the module *definition*
992+
// (when the feature stabilizes, this should move into repo/resources/Resources.php: T385446)
993+
$settings = WikibaseRepo::getSettings();
994+
if ( $settings->getSetting( 'tmpEnableScopedTypeaheadSearch' ) ) {
995+
$modules['wikibase.vector.scopedTypeaheadSearch'] = $moduleTemplate + [
996+
'packageFiles' => [
997+
'resources/wikibase.vector.scopedTypeaheadSearch.js',
998+
],
999+
];
1000+
}
1001+
9861002
$resourceLoader->register( $modules );
9871003
}
9881004

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
( function ( mw ) {
2+
'use strict';
3+
4+
/* eslint-disable no-console */
5+
6+
let searchInputWrapper = document.getElementById( 'simpleSearch' );
7+
if ( searchInputWrapper ) {
8+
console.log( ' scopedTypeaheadSearch loaded before full Vector search' );
9+
} else {
10+
searchInputWrapper = document.querySelector( '#searchform .cdx-search-input__input-wrapper' );
11+
if ( searchInputWrapper ) {
12+
console.log( 'scopedTypeaheadSearch loaded after full Vector search' );
13+
} else {
14+
console.error( 'scopedTypeaheadSearch could not find element to replace' );
15+
return;
16+
}
17+
}
18+
searchInputWrapper.replaceWith( 'ScopedTypeaheadSearch will go here (T338483)' );
19+
20+
/* eslint-enable */
21+
}( mw ) );

0 commit comments

Comments
 (0)