File tree Expand file tree Collapse file tree
search-component/src/utils/hooks
frontends/dashboard/src/pages/dataset Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -206,6 +206,7 @@ export type ModalProps = {
206206 previewTopicId ?: string ;
207207 overrideFetch ?: boolean ;
208208 searchBar ?: boolean ;
209+ defaultSearchQuery ?: string ;
209210} ;
210211
211212const defaultProps = {
@@ -278,6 +279,7 @@ const defaultProps = {
278279 usePortal : true ,
279280 previewTopicId : undefined ,
280281 searchBar : false ,
282+ defaultSearchQuery : undefined ,
281283} satisfies ModalProps ;
282284
283285const ModalContext = createContext < {
@@ -689,7 +691,7 @@ const ModalProvider = ({
689691 props . defaultSearchMode === "search"
690692 ) {
691693 const url = new URL ( window . location . href ) ;
692- const initialQuery = url . searchParams . get ( "q" ) ;
694+ const initialQuery = url . searchParams . get ( "q" ) || props . defaultSearchQuery ;
693695 if ( initialQuery ) {
694696 setQuery ( initialQuery ) ;
695697 }
Original file line number Diff line number Diff line change 1562715627 },
1562815628 "nullable": true
1562915629 },
15630+ "defaultSearchQuery": {
15631+ "type": "string",
15632+ "nullable": true
15633+ },
1563015634 "floatingButtonPosition": {
1563115635 "type": "string",
1563215636 "nullable": true
1572415728 "type": "boolean",
1572515729 "nullable": true
1572615730 },
15731+ "searchBar": {
15732+ "type": "boolean",
15733+ "nullable": true
15734+ },
1572715735 "searchOptions": {
1572815736 "allOf": [
1572915737 {
Original file line number Diff line number Diff line change @@ -2914,6 +2914,7 @@ export type PublicPageParameters = {
29142914 defaultImageQuestion ?: ( string ) | null ;
29152915 defaultSearchMode ?: ( string ) | null ;
29162916 defaultSearchQueries ?: Array < ( string ) > | null ;
2917+ defaultSearchQuery ?: ( string ) | null ;
29172918 floatingButtonPosition ?: ( string ) | null ;
29182919 floatingButtonVersion ?: ( string ) | null ;
29192920 floatingSearchIconPosition ?: ( string ) | null ;
@@ -2934,6 +2935,7 @@ export type PublicPageParameters = {
29342935 problemLink ?: ( string ) | null ;
29352936 relevanceToolCallOptions ?: ( ( RelevanceToolCallOptions ) | null ) ;
29362937 responsive ?: ( boolean ) | null ;
2938+ searchBar ?: ( boolean ) | null ;
29372939 searchOptions ?: ( ( PublicPageSearchOptions ) | null ) ;
29382940 searchPageProps ?: ( ( SearchPageProps ) | null ) ;
29392941 showFloatingButton ?: ( boolean ) | null ;
Original file line number Diff line number Diff line change @@ -1939,6 +1939,7 @@ export const SerpPageOptions = () => {
19391939 "defaultSearchMode" ,
19401940 checked ? "search" : extraParams . defaultSearchMode ,
19411941 ) ;
1942+ setExtraParams ( "searchBar" , checked ) ;
19421943
19431944 if ( checked && ! showFilters ( ) ) {
19441945 setShowFilters ( true ) ;
@@ -1972,6 +1973,20 @@ export const SerpPageOptions = () => {
19721973 </ div >
19731974 </ div >
19741975
1976+ < div class = "flex gap-4" >
1977+ < div class = "grow" >
1978+ < label class = "block" > Default Search Query</ label >
1979+ < input
1980+ placeholder = "Default search query"
1981+ value = { extraParams . defaultSearchQuery || "" }
1982+ onInput = { ( e ) => {
1983+ setExtraParams ( "defaultSearchQuery" , e . currentTarget . value ) ;
1984+ } }
1985+ class = "block w-full rounded border border-neutral-300 px-3 py-1.5 shadow-sm placeholder:text-neutral-400 focus:outline-magenta-500 sm:text-sm sm:leading-6"
1986+ />
1987+ </ div >
1988+ </ div >
1989+
19751990 { extraParams . searchPageProps ?. display && (
19761991 < >
19771992 < FilterSidebarBuilder />
Original file line number Diff line number Diff line change @@ -3622,6 +3622,12 @@ impl DatasetConfigurationDTO {
36223622 search_page_props : page_parameters_self
36233623 . search_page_props
36243624 . or ( page_parameters_curr. search_page_props ) ,
3625+ default_search_query : page_parameters_self
3626+ . default_search_query
3627+ . or ( page_parameters_curr. default_search_query ) ,
3628+ search_bar : page_parameters_self
3629+ . search_bar
3630+ . or ( page_parameters_curr. search_bar ) ,
36253631 } ) ,
36263632 } ,
36273633 DISABLE_ANALYTICS : self
Original file line number Diff line number Diff line change @@ -362,6 +362,10 @@ pub struct PublicPageParameters {
362362 pub show_result_highlights : Option < bool > ,
363363 #[ serde( skip_serializing_if = "Option::is_none" ) ]
364364 pub search_page_props : Option < SearchPageProps > ,
365+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
366+ pub search_bar : Option < bool > ,
367+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
368+ pub default_search_query : Option < String > ,
365369}
366370
367371#[ utoipa:: path(
You can’t perform that action at this time.
0 commit comments