1
1
import 'react-datepicker/dist/react-datepicker.css' ;
2
2
3
- import { SerdeUsage , TopicMessageConsuming } from 'generated-sources' ;
3
+ import { SerdeUsage , TopicMessageConsuming , TopicMessage } from 'generated-sources' ;
4
4
import React , { ChangeEvent , useMemo , useState } from 'react' ;
5
5
import { format } from 'date-fns' ;
6
6
import MultiSelect from 'components/common/MultiSelect/MultiSelect.styled' ;
@@ -54,7 +54,7 @@ export interface FiltersProps {
54
54
consumptionStats ?: TopicMessageConsuming ;
55
55
isFetching : boolean ;
56
56
abortFetchData : ( ) => void ;
57
- messages ?: any [ ] ; // Add messages prop for download functionality
57
+ messages ?: TopicMessage [ ] ;
58
58
}
59
59
60
60
const Filters : React . FC < FiltersProps > = ( {
@@ -88,10 +88,9 @@ const Filters: React.FC<FiltersProps> = ({
88
88
89
89
const { data : topic } = useTopicDetails ( { clusterName, topicName } ) ;
90
90
const [ createdEditedSmartId , setCreatedEditedSmartId ] = useState < string > ( ) ;
91
- const remove = useMessageFiltersStore ( ( state ) => state . remove ) ;
91
+ const remove = useMessageFiltersStore ( ( state : { remove : ( id : string ) => void } ) => state . remove ) ;
92
92
93
93
// Download functionality
94
- const [ selectedFormat , setSelectedFormat ] = useState < DownloadFormat > ( 'json' ) ;
95
94
const [ showFormatSelector , setShowFormatSelector ] = useState ( false ) ;
96
95
97
96
const formatOptions = [
@@ -101,7 +100,7 @@ const Filters: React.FC<FiltersProps> = ({
101
100
102
101
const baseFileName = `topic-messages${ padCurrentDateTimeString ( ) } ` ;
103
102
104
- const savedMessagesJson : MessageData [ ] = messages . map ( ( message ) => ( {
103
+ const savedMessagesJson : MessageData [ ] = messages . map ( ( message : TopicMessage ) => ( {
105
104
Value : message . content ,
106
105
Offset : message . offset ,
107
106
Key : message . key ,
@@ -145,9 +144,8 @@ const Filters: React.FC<FiltersProps> = ({
145
144
) ;
146
145
147
146
const handleFormatSelect = ( downloadFormat : DownloadFormat ) => {
148
- setSelectedFormat ( downloadFormat ) ;
149
147
setShowFormatSelector ( false ) ;
150
-
148
+
151
149
// Automatically download after format selection
152
150
if ( downloadFormat === 'json' ) {
153
151
jsonSaver . saveFile ( ) ;
@@ -325,24 +323,35 @@ const Filters: React.FC<FiltersProps> = ({
325
323
} }
326
324
>
327
325
{ formatOptions . map ( ( option ) => (
328
- < div
326
+ < button
329
327
key = { option . value }
330
328
onClick = { ( ) => handleFormatSelect ( option . value ) }
329
+ onKeyDown = { ( e ) => {
330
+ if ( e . key === 'Enter' || e . key === ' ' ) {
331
+ handleFormatSelect ( option . value ) ;
332
+ }
333
+ } }
331
334
style = { {
332
335
padding : '8px 12px' ,
333
336
cursor : 'pointer' ,
334
337
borderRadius : '4px' ,
335
338
fontSize : '12px' ,
339
+ border : 'none' ,
340
+ background : 'transparent' ,
341
+ width : '100%' ,
342
+ textAlign : 'left' ,
336
343
} }
337
344
onMouseEnter = { ( e ) => {
338
- e . currentTarget . style . backgroundColor = '#f5f5f5' ;
345
+ const target = e . currentTarget ;
346
+ target . style . backgroundColor = '#f5f5f5' ;
339
347
} }
340
348
onMouseLeave = { ( e ) => {
341
- e . currentTarget . style . backgroundColor = 'transparent' ;
349
+ const target = e . currentTarget ;
350
+ target . style . backgroundColor = 'transparent' ;
342
351
} }
343
352
>
344
353
{ option . label }
345
- </ div >
354
+ </ button >
346
355
) ) }
347
356
</ div >
348
357
) }
@@ -405,4 +414,3 @@ const Filters: React.FC<FiltersProps> = ({
405
414
} ;
406
415
407
416
export default Filters ;
408
-
0 commit comments