@@ -1521,23 +1521,41 @@ const ExpandedMessageFooter: FC<{ children?: ReactNode; onDownloadRecord?: () =>
15211521
15221522type ExpandedMessageProps = {
15231523 msg : TopicMessage ;
1524- topicName : string ;
1525- onLoadLargeMessage : ( topicName : string , partitionID : number , offset : number ) => Promise < void > ;
1524+ loadLargeMessage ?: ( ) => Promise < void > ;
1525+ onDownloadRecord ?: ( ) => void ;
1526+ topicName ?: string ;
1527+ onLoadLargeMessage ?: ( topicName : string , partitionID : number , offset : number ) => Promise < void > ;
15261528 onSetDownloadMessages ?: ( messages : TopicMessage [ ] ) => void ;
15271529 onCopyKey ?: ( original : TopicMessage ) => void ;
15281530 onCopyValue ?: ( original : TopicMessage ) => void ;
15291531} ;
15301532
15311533export const ExpandedMessage : FC < ExpandedMessageProps > = React . memo (
1532- ( { msg, topicName, onLoadLargeMessage, onSetDownloadMessages, onCopyKey, onCopyValue } ) => {
1534+ ( {
1535+ msg,
1536+ loadLargeMessage,
1537+ onDownloadRecord,
1538+ topicName,
1539+ onLoadLargeMessage,
1540+ onSetDownloadMessages,
1541+ onCopyKey,
1542+ onCopyValue,
1543+ } ) => {
15331544 const bg = useColorModeValue ( 'gray.50' , 'gray.600' ) ;
1534- const loadLargeMessage = useCallback (
1535- ( ) => onLoadLargeMessage ( topicName , msg . partitionID , msg . offset ) ,
1536- [ msg . offset , msg . partitionID , onLoadLargeMessage , topicName ] ,
1545+ const handleLoadLargeMessage = useCallback (
1546+ ( ) =>
1547+ onLoadLargeMessage && topicName !== undefined
1548+ ? onLoadLargeMessage ( topicName , msg . partitionID , msg . offset )
1549+ : ( loadLargeMessage ?.( ) ?? Promise . resolve ( ) ) ,
1550+ [ loadLargeMessage , msg . offset , msg . partitionID , onLoadLargeMessage , topicName ] ,
15371551 ) ;
1538- const onDownloadRecord = useCallback ( ( ) => {
1539- onSetDownloadMessages ?.( [ msg ] ) ;
1540- } , [ msg , onSetDownloadMessages ] ) ;
1552+ const handleDownloadRecord = useCallback ( ( ) => {
1553+ if ( onSetDownloadMessages ) {
1554+ onSetDownloadMessages ( [ msg ] ) ;
1555+ return ;
1556+ }
1557+ onDownloadRecord ?.( ) ;
1558+ } , [ msg , onDownloadRecord , onSetDownloadMessages ] ) ;
15411559 const handleCopyKey = useCallback ( ( ) => {
15421560 onCopyKey ?.( msg ) ;
15431561 } , [ msg , onCopyKey ] ) ;
@@ -1564,8 +1582,8 @@ export const ExpandedMessage: FC<ExpandedMessageProps> = React.memo(
15641582 component : (
15651583 < Box >
15661584 < TroubleshootReportViewer payload = { msg . key } />
1567- < PayloadComponent payload = { msg . key } loadLargeMessage = { loadLargeMessage } />
1568- < ExpandedMessageFooter onDownloadRecord = { onDownloadRecord } >
1585+ < PayloadComponent payload = { msg . key } loadLargeMessage = { handleLoadLargeMessage } />
1586+ < ExpandedMessageFooter onDownloadRecord = { handleDownloadRecord } >
15691587 { onCopyKey && (
15701588 < Button variant = "outline" onClick = { handleCopyKey } isDisabled = { msg . key . isPayloadNull } >
15711589 Copy Key
@@ -1585,8 +1603,8 @@ export const ExpandedMessage: FC<ExpandedMessageProps> = React.memo(
15851603 component : (
15861604 < Box >
15871605 < TroubleshootReportViewer payload = { msg . value } />
1588- < PayloadComponent payload = { msg . value } loadLargeMessage = { loadLargeMessage } />
1589- < ExpandedMessageFooter onDownloadRecord = { onDownloadRecord } >
1606+ < PayloadComponent payload = { msg . value } loadLargeMessage = { handleLoadLargeMessage } />
1607+ < ExpandedMessageFooter onDownloadRecord = { handleDownloadRecord } >
15901608 { onCopyValue && (
15911609 < Button variant = "outline" onClick = { handleCopyValue } isDisabled = { msg . value . isPayloadNull } >
15921610 Copy Value
@@ -1605,7 +1623,9 @@ export const ExpandedMessage: FC<ExpandedMessageProps> = React.memo(
16051623 component : (
16061624 < Box >
16071625 < MessageHeaders msg = { msg } />
1608- { onSetDownloadMessages && < ExpandedMessageFooter onDownloadRecord = { onDownloadRecord } /> }
1626+ { ( onSetDownloadMessages || onDownloadRecord ) && (
1627+ < ExpandedMessageFooter onDownloadRecord = { handleDownloadRecord } />
1628+ ) }
16091629 </ Box >
16101630 ) ,
16111631 } ,
0 commit comments