@@ -17,13 +17,12 @@ import Panel from 'sentry/components/panels/panel';
17
17
import PanelHeader from 'sentry/components/panels/panelHeader' ;
18
18
import PanelItem from 'sentry/components/panels/panelItem' ;
19
19
import PerformanceDuration from 'sentry/components/performanceDuration' ;
20
- import type { SmartSearchBarProps } from 'sentry/components/smartSearchBar' ;
21
20
import { IconChevron } from 'sentry/icons/iconChevron' ;
22
21
import { t } from 'sentry/locale' ;
23
22
import { space } from 'sentry/styles/space' ;
24
23
import type { PageFilters } from 'sentry/types/core' ;
25
24
import { useApiQuery } from 'sentry/utils/queryClient' ;
26
- import { decodeInteger , decodeScalar } from 'sentry/utils/queryString' ;
25
+ import { decodeInteger , decodeList } from 'sentry/utils/queryString' ;
27
26
import { useLocation } from 'sentry/utils/useLocation' ;
28
27
import useOrganization from 'sentry/utils/useOrganization' ;
29
28
import usePageFilters from 'sentry/utils/usePageFilters' ;
@@ -46,26 +45,52 @@ const DEFAULT_PER_PAGE = 20;
46
45
export function Content ( ) {
47
46
const location = useLocation ( ) ;
48
47
49
- const query = useMemo ( ( ) => {
50
- return decodeScalar ( location . query . query , '' ) ;
48
+ const queries = useMemo ( ( ) => {
49
+ return decodeList ( location . query . query ) ;
51
50
} , [ location . query . query ] ) ;
52
51
53
52
const limit = useMemo ( ( ) => {
54
53
return decodeInteger ( location . query . perPage , DEFAULT_PER_PAGE ) ;
55
54
} , [ location . query . perPage ] ) ;
56
55
57
- const handleSearch : SmartSearchBarProps [ 'onSearch' ] = useCallback (
58
- ( searchQuery : string ) => {
56
+ const handleSearch = useCallback (
57
+ ( searchIndex : number , searchQuery : string ) => {
58
+ const newQueries = [ ...queries ] ;
59
+ if ( newQueries . length === 0 ) {
60
+ // In the odd case someone wants to add search bars before any query has been made, we add both the default one shown and a new one.
61
+ newQueries [ 0 ] = '' ;
62
+ }
63
+ newQueries [ searchIndex ] = searchQuery ;
59
64
browserHistory . push ( {
60
65
...location ,
61
66
query : {
62
67
...location . query ,
63
68
cursor : undefined ,
64
- query : searchQuery || undefined ,
69
+ query : typeof searchQuery === 'string' ? newQueries : queries ,
65
70
} ,
66
71
} ) ;
67
72
} ,
68
- [ location ]
73
+ [ location , queries ]
74
+ ) ;
75
+
76
+ const handleClearSearch = useCallback (
77
+ ( searchIndex : number ) => {
78
+ const newQueries = [ ...queries ] ;
79
+ if ( typeof newQueries [ searchIndex ] !== undefined ) {
80
+ delete newQueries [ searchIndex ] ;
81
+ browserHistory . push ( {
82
+ ...location ,
83
+ query : {
84
+ ...location . query ,
85
+ cursor : undefined ,
86
+ query : newQueries ,
87
+ } ,
88
+ } ) ;
89
+ return true ;
90
+ }
91
+ return false ;
92
+ } ,
93
+ [ location , queries ]
69
94
) ;
70
95
71
96
const traces = useTraces < Field > ( {
@@ -76,7 +101,7 @@ export function Content() {
76
101
) ,
77
102
] ,
78
103
limit,
79
- query,
104
+ query : queries ,
80
105
sort : SORTS ,
81
106
} ) ;
82
107
@@ -92,7 +117,11 @@ export function Content() {
92
117
< EnvironmentPageFilter />
93
118
< DatePageFilter />
94
119
</ PageFilterBar >
95
- < TracesSearchBar query = { query } handleSearch = { handleSearch } />
120
+ < TracesSearchBar
121
+ queries = { queries }
122
+ handleSearch = { handleSearch }
123
+ handleClearSearch = { handleClearSearch }
124
+ />
96
125
< StyledPanel >
97
126
< TracePanelContent >
98
127
< StyledPanelHeader align = "right" lightText >
@@ -292,7 +321,7 @@ interface UseTracesOptions<F extends string> {
292
321
datetime ?: PageFilters [ 'datetime' ] ;
293
322
enabled ?: boolean ;
294
323
limit ?: number ;
295
- query ?: string ;
324
+ query ?: string | string [ ] ;
296
325
sort ?: string [ ] ;
297
326
suggestedQuery ?: string ;
298
327
}
0 commit comments