11import 'react-datepicker/dist/react-datepicker.css' ;
22
3- import { SerdeUsage , TopicMessageConsuming } from 'generated-sources' ;
3+ import { SerdeUsage , TopicMessageConsuming , TopicMessage } from 'generated-sources' ;
44import React , { ChangeEvent , useMemo , useState } from 'react' ;
55import { format } from 'date-fns' ;
66import MultiSelect from 'components/common/MultiSelect/MultiSelect.styled' ;
@@ -54,7 +54,7 @@ export interface FiltersProps {
5454 consumptionStats ?: TopicMessageConsuming ;
5555 isFetching : boolean ;
5656 abortFetchData : ( ) => void ;
57- messages ?: any [ ] ; // Add messages prop for download functionality
57+ messages ?: TopicMessage [ ] ;
5858}
5959
6060const Filters : React . FC < FiltersProps > = ( {
@@ -88,10 +88,9 @@ const Filters: React.FC<FiltersProps> = ({
8888
8989 const { data : topic } = useTopicDetails ( { clusterName, topicName } ) ;
9090 const [ createdEditedSmartId , setCreatedEditedSmartId ] = useState < string > ( ) ;
91- const remove = useMessageFiltersStore ( ( state ) => state . remove ) ;
91+ const remove = useMessageFiltersStore ( ( state : { remove : ( id : string ) => void } ) => state . remove ) ;
9292
9393 // Download functionality
94- const [ selectedFormat , setSelectedFormat ] = useState < DownloadFormat > ( 'json' ) ;
9594 const [ showFormatSelector , setShowFormatSelector ] = useState ( false ) ;
9695
9796 const formatOptions = [
@@ -101,7 +100,7 @@ const Filters: React.FC<FiltersProps> = ({
101100
102101 const baseFileName = `topic-messages${ padCurrentDateTimeString ( ) } ` ;
103102
104- const savedMessagesJson : MessageData [ ] = messages . map ( ( message ) => ( {
103+ const savedMessagesJson : MessageData [ ] = messages . map ( ( message : TopicMessage ) => ( {
105104 Value : message . content ,
106105 Offset : message . offset ,
107106 Key : message . key ,
@@ -145,9 +144,8 @@ const Filters: React.FC<FiltersProps> = ({
145144 ) ;
146145
147146 const handleFormatSelect = ( downloadFormat : DownloadFormat ) => {
148- setSelectedFormat ( downloadFormat ) ;
149147 setShowFormatSelector ( false ) ;
150-
148+
151149 // Automatically download after format selection
152150 if ( downloadFormat === 'json' ) {
153151 jsonSaver . saveFile ( ) ;
@@ -325,24 +323,35 @@ const Filters: React.FC<FiltersProps> = ({
325323 } }
326324 >
327325 { formatOptions . map ( ( option ) => (
328- < div
326+ < button
329327 key = { option . value }
330328 onClick = { ( ) => handleFormatSelect ( option . value ) }
329+ onKeyDown = { ( e ) => {
330+ if ( e . key === 'Enter' || e . key === ' ' ) {
331+ handleFormatSelect ( option . value ) ;
332+ }
333+ } }
331334 style = { {
332335 padding : '8px 12px' ,
333336 cursor : 'pointer' ,
334337 borderRadius : '4px' ,
335338 fontSize : '12px' ,
339+ border : 'none' ,
340+ background : 'transparent' ,
341+ width : '100%' ,
342+ textAlign : 'left' ,
336343 } }
337344 onMouseEnter = { ( e ) => {
338- e . currentTarget . style . backgroundColor = '#f5f5f5' ;
345+ const target = e . currentTarget ;
346+ target . style . backgroundColor = '#f5f5f5' ;
339347 } }
340348 onMouseLeave = { ( e ) => {
341- e . currentTarget . style . backgroundColor = 'transparent' ;
349+ const target = e . currentTarget ;
350+ target . style . backgroundColor = 'transparent' ;
342351 } }
343352 >
344353 { option . label }
345- </ div >
354+ </ button >
346355 ) ) }
347356 </ div >
348357 ) }
@@ -405,4 +414,3 @@ const Filters: React.FC<FiltersProps> = ({
405414} ;
406415
407416export default Filters ;
408-
0 commit comments