@@ -18,7 +18,7 @@ import { ResponseCodeFormatter } from '../LogsFormatters'
1818const LogRowCodeBlock = ( { value, className } : { value : string ; className ?: string } ) => (
1919 < pre
2020 className = { cn (
21- 'px-1 bg-surface-300 w-full pt-1 max-w-full border-none text-xs prose-sm transition-all overflow-auto rounded-md' ,
21+ 'px-1 bg-surface-300 w-full pt-1 max-w-full border-none text-xs prose-sm transition-all overflow-auto rounded-md whitespace-pre-wrap ' ,
2222 className
2323 ) }
2424 >
@@ -47,8 +47,18 @@ const PropertyRow = ({
4747 const isObject = typeof value === 'object' && value !== null
4848 const isStatus = keyName === 'status' || keyName === 'status_code'
4949 const isMethod = keyName === 'method'
50- const isPath = keyName === 'path '
50+ const isSearch = keyName === 'search '
5151 const isUserAgent = keyName === 'user_agent'
52+ const isEventMessage = keyName === 'event_message'
53+ const isPath = keyName === 'path'
54+
55+ function getSearchPairs ( ) {
56+ if ( isSearch && typeof value === 'string' ) {
57+ const str = value . startsWith ( '?' ) ? value . slice ( 1 ) : value
58+ return str . split ( '&' ) . filter ( Boolean )
59+ }
60+ return [ ]
61+ }
5262
5363 const storageKey = `log-viewer-expanded-${ keyName } `
5464 const [ isExpanded , setIsExpanded ] = useState ( ( ) => {
@@ -76,7 +86,7 @@ const PropertyRow = ({
7686 } , 1000 )
7787 }
7888
79- if ( isObject ) {
89+ if ( isObject || isEventMessage ) {
8090 return (
8191 < >
8292 < div className = "flex flex-col gap-1" >
@@ -86,17 +96,20 @@ const PropertyRow = ({
8696 className = { cn ( 'px-2.5' , {
8797 'max-h-[80px]' : ! isExpanded ,
8898 'max-h-[400px]' : isExpanded ,
99+ 'py-2' : isEventMessage ,
89100 } ) }
90101 value = { value }
91102 />
92- < Button
93- className = "mt-1 w-full"
94- size = "tiny"
95- type = "outline"
96- onClick = { ( ) => setIsExpanded ( ! isExpanded ) }
97- >
98- { isExpanded ? 'Collapse' : 'Expand' }
99- </ Button >
103+ { ! isEventMessage && (
104+ < Button
105+ className = "mt-1 w-full"
106+ size = "tiny"
107+ type = "outline"
108+ onClick = { ( ) => setIsExpanded ( ! isExpanded ) }
109+ >
110+ { isExpanded ? 'Collapse' : 'Expand' }
111+ </ Button >
112+ ) }
100113 </ div >
101114 </ div >
102115 < LogRowSeparator />
@@ -141,7 +154,7 @@ const PropertyRow = ({
141154 < ResponseCodeFormatter value = { value } />
142155 </ div >
143156 ) : (
144- < div className = "truncate" > { JSON . stringify ( value ) } </ div >
157+ < div className = "truncate" > { value } </ div >
145158 ) }
146159 </ div >
147160 </ div >
@@ -158,7 +171,7 @@ const PropertyRow = ({
158171 { isExpanded ? 'Collapse' : 'Expand' } value
159172 </ DropdownMenuItem >
160173 ) }
161- { ( isPath || isMethod || isUserAgent || isStatus ) && (
174+ { ( isMethod || isUserAgent || isStatus || isPath ) && (
162175 < DropdownMenuItem
163176 onClick = { ( ) => {
164177 handleSearch ( 'search-input-change' , { query : value } )
@@ -167,6 +180,18 @@ const PropertyRow = ({
167180 Search by { keyName }
168181 </ DropdownMenuItem >
169182 ) }
183+ { isSearch
184+ ? getSearchPairs ( ) . map ( ( pair ) => (
185+ < DropdownMenuItem
186+ key = { pair }
187+ onClick = { ( ) => {
188+ handleSearch ( 'search-input-change' , { query : pair } )
189+ } }
190+ >
191+ Search by { pair }
192+ </ DropdownMenuItem >
193+ ) )
194+ : null }
170195 </ DropdownMenuContent >
171196 < LogRowSeparator />
172197 </ DropdownMenu >
0 commit comments