mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-24 23:55:53 +00:00
ce77018b7c
[Visual changes] This should result in 9 visual regression failures relating to increased height of search results and loading bar [More details about change] - Migrate search app from Vue 2 to Vue 3; update tests accordingly - Remove dependence on WVUI and use Codex instead, via the special `@wikimedia/codex-search` package - Update search app to use CdxTypeaheadSearch, which no longer takes in props related to the search client or fetch start/end instrumentation. Instead, directly use the restSearchClient and call fetch start/end events in the search app. - Handle hideDirection in the search app/API response formatting code, not within the TypeaheadSearch component - Handle showing/hiding the search button in the app - Move the WVUI URL generator into Vector - Update server-rendered search box styles to match design updates included with CdxTypeaheadSearch - Replace references to WVUI with references to Codex - Update values of various LESS variables to match Codex, and update searchBox styling to prevent jankiness when the searchBox is replaced with the Codex TypeaheadSearch component The VectorWvuiSearchOptions config variable has been maintained and will be updated to a code-agnostic name in a future patch. Bug: T300573 Bug: T302137 Bug: T303558 Bug: T309722 Bug: T310525 Co-Authored-By: Anne Tomasevich <atomasevich@wikimedia.org> Change-Id: I59fa3a006d988b14ebd8020cbd58e8d7bedbfe01
60 lines
1.4 KiB
JavaScript
60 lines
1.4 KiB
JavaScript
/* global RestResult, SearchResult */
|
|
|
|
/**
|
|
* @typedef {Object} UrlParams
|
|
* @param {string} title
|
|
* @param {string} fulltext
|
|
*/
|
|
|
|
/**
|
|
* @callback generateUrl
|
|
* @param {RestResult|SearchResult|string} searchResult
|
|
* @param {UrlParams} [params]
|
|
* @param {string} [articlePath]
|
|
* @return {string}
|
|
*/
|
|
|
|
/**
|
|
* @typedef {Object} UrlGenerator
|
|
* @property {generateUrl} generateUrl
|
|
*/
|
|
|
|
/**
|
|
* Generates URLs for suggestions like those in MediaWiki's mediawiki.searchSuggest implementation.
|
|
*
|
|
* @param {MwMap} config
|
|
* @return {UrlGenerator}
|
|
*/
|
|
function urlGenerator( config ) {
|
|
// TODO: This is a placeholder for enabling customization of the URL generator.
|
|
// wgVectorSearchUrlGenerator has not been defined as a config variable yet.
|
|
const customGenerator = config.get( 'wgVectorSearchUrlGenerator' );
|
|
return customGenerator || {
|
|
/**
|
|
* @type {generateUrl}
|
|
*/
|
|
generateUrl(
|
|
suggestion,
|
|
params = {
|
|
title: 'Special:Search'
|
|
},
|
|
articlePath = config.get( 'wgScript' )
|
|
) {
|
|
if ( typeof suggestion !== 'string' ) {
|
|
suggestion = suggestion.title;
|
|
} else {
|
|
// Add `fulltext` query param to search within pages and for navigation
|
|
// to the search results page (prevents being redirected to a certain
|
|
// article).
|
|
// @ts-ignore
|
|
params.fulltext = '1';
|
|
}
|
|
|
|
return articlePath + '?' + $.param( $.extend( {}, params, { search: suggestion } ) );
|
|
}
|
|
};
|
|
}
|
|
|
|
/** @module urlGenerator */
|
|
module.exports = urlGenerator;
|