diff --git a/client/app/components/items-list/ItemsList.tsx b/client/app/components/items-list/ItemsList.tsx index c13cb809b..1ae4d53e3 100644 --- a/client/app/components/items-list/ItemsList.tsx +++ b/client/app/components/items-list/ItemsList.tsx @@ -10,6 +10,10 @@ export interface PaginationOptions { itemsPerPage?: number; } +export interface SearchOptions { + isServerSideFTS?: boolean; +} + export interface Controller { params: P; // TODO: Find out what params is (except merging with props) @@ -18,7 +22,7 @@ export interface Controller { // search searchTerm?: string; - updateSearch: (searchTerm: string) => void; + updateSearch: (searchTerm: string, searchOptions?: SearchOptions) => void; // tags selectedTags: string[]; diff --git a/client/app/components/items-list/classes/ItemsSource.js b/client/app/components/items-list/classes/ItemsSource.js index 583541874..50b229c8f 100644 --- a/client/app/components/items-list/classes/ItemsSource.js +++ b/client/app/components/items-list/classes/ItemsSource.js @@ -135,13 +135,13 @@ export class ItemsSource { this._changed({ sorting: true }); }; - updateSearch = (searchTerm) => { + updateSearch = (searchTerm, options) => { // here we update state directly, but later `fetchData` will update it properly this._searchTerm = searchTerm; // in search mode ignore the ordering and use the ranking order // provided by the server-side FTS backend instead, unless it was // requested by the user by actively ordering in search mode - if (searchTerm === "") { + if (searchTerm === "" || !options?.isServerSideFTS) { this._sorter.setField(this._savedOrderByField); // restore ordering } else { this._sorter.setField(null); diff --git a/client/app/pages/queries-list/QueriesList.jsx b/client/app/pages/queries-list/QueriesList.jsx index 2a200e98b..f21ccaff4 100644 --- a/client/app/pages/queries-list/QueriesList.jsx +++ b/client/app/pages/queries-list/QueriesList.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef } from "react"; +import React, { useCallback, useEffect, useRef } from "react"; import cx from "classnames"; import routeWithUserSession from "@/components/ApplicationArea/routeWithUserSession"; @@ -20,7 +20,7 @@ import ItemsTable, { Columns } from "@/components/items-list/components/ItemsTab import Layout from "@/components/layouts/ContentWithSidebar"; import { Query } from "@/services/query"; -import { currentUser } from "@/services/auth"; +import { clientConfig, currentUser } from "@/services/auth"; import location from "@/services/location"; import routes from "@/services/routes"; @@ -95,18 +95,25 @@ function QueriesList({ controller }) { const controllerRef = useRef(); controllerRef.current = controller; + const updateSearch = useCallback( + (searchTemm) => { + controller.updateSearch(searchTemm, { isServerSideFTS: !clientConfig.multiByteSearchEnabled }); + }, + [controller] + ); + useEffect(() => { const unlistenLocationChanges = location.listen((unused, action) => { const searchTerm = location.search.q || ""; if (action === "PUSH" && searchTerm !== controllerRef.current.searchTerm) { - controllerRef.current.updateSearch(searchTerm); + updateSearch(searchTerm); } }); return () => { unlistenLocationChanges(); }; - }, []); + }, [updateSearch]); const { areExtraActionsAvailable, @@ -135,7 +142,7 @@ function QueriesList({ controller }) { placeholder="Search Queries..." label="Search queries" value={controller.searchTerm} - onChange={controller.updateSearch} + onChange={updateSearch} /> diff --git a/redash/handlers/authentication.py b/redash/handlers/authentication.py index 23bff14cf..ca49382a3 100644 --- a/redash/handlers/authentication.py +++ b/redash/handlers/authentication.py @@ -278,6 +278,7 @@ def client_config(): "showPermissionsControl": current_org.get_setting("feature_show_permissions_control"), "hidePlotlyModeBar": current_org.get_setting("hide_plotly_mode_bar"), "disablePublicUrls": current_org.get_setting("disable_public_urls"), + "multiByteSearchEnabled": current_org.get_setting("multi_byte_search_enabled"), "allowCustomJSVisualizations": settings.FEATURE_ALLOW_CUSTOM_JS_VISUALIZATIONS, "autoPublishNamedQueries": settings.FEATURE_AUTO_PUBLISH_NAMED_QUERIES, "extendedAlertOptions": settings.FEATURE_EXTENDED_ALERT_OPTIONS,