Merge "Development: Allow us to test search with different API hosts"

This commit is contained in:
jenkins-bot 2020-12-09 00:14:43 +00:00 committed by Gerrit Code Review
commit a9b47f57fb
5 changed files with 13 additions and 2 deletions

View File

@ -35,6 +35,7 @@ class Hooks {
Config $config
) {
return [
'wgVectorSearchHost' => $config->get( 'VectorSearchHost' ),
'wgVectorUseCoreSearch' => $config->get( 'VectorUseCoreSearch' ),
];
}

View File

@ -43,7 +43,8 @@ interface MediaWiki {
};
Api: MwApiConstructor;
config: {
get( configKey: string|null ): string;
get( configKey: string|null, fallback?: any|null ): string;
set( configKey: string|null, value: any|null ): void;
},
loader: {
/**

View File

@ -132,6 +132,11 @@ function initSearchLoader( document ) {
var searchForm = document.getElementById( SEARCH_FORM_ID ),
searchInput = document.getElementById( SEARCH_INPUT_ID );
// Allow developers to defined $wgVectorSearchHost in LocalSettings to target different APIs
if ( config.wgVectorSearchHost ) {
mw.config.set( 'wgVectorSearchHost', config.wgVectorSearchHost );
}
if ( !searchForm || !searchInput ) {
return;
}

View File

@ -61,7 +61,7 @@ module.exports = {
},
domain: function () {
// It might be helpful to allow this to be configurable in future.
return location.host;
return mw.config.get( 'wgVectorSearchHost', location.host );
}
},
props: {

View File

@ -173,6 +173,10 @@
}
},
"config": {
"VectorSearchHost": {
"value": "",
"description": "Override default search API. Can be used with $wgDisableTextSearch and $wgSearchForwardUrl to mimic user experience on production."
},
"VectorUseIconWatch": {
"value": true
},