MessagesTable.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import React from 'react';
  2. import { TopicMessage } from 'generated-sources';
  3. import CustomParamButton from 'components/Topics/shared/Form/CustomParams/CustomParamButton';
  4. import MessageItem from './MessageItem';
  5. export interface MessagesTableProp {
  6. messages: TopicMessage[];
  7. onNext(event: React.MouseEvent<HTMLButtonElement>): void;
  8. }
  9. const MessagesTable: React.FC<MessagesTableProp> = ({ messages, onNext }) => {
  10. if (!messages.length) {
  11. return <div>No messages at selected topic</div>;
  12. }
  13. return (
  14. <>
  15. <table className="table is-striped is-fullwidth">
  16. <thead>
  17. <tr>
  18. <th>Timestamp</th>
  19. <th>Offset</th>
  20. <th>Partition</th>
  21. <th>Content</th>
  22. </tr>
  23. </thead>
  24. <tbody>
  25. {messages.map(
  26. ({ partition, offset, timestamp, content }: TopicMessage) => (
  27. <MessageItem
  28. key={`message-${timestamp.getTime()}`}
  29. partition={partition}
  30. offset={offset}
  31. timestamp={timestamp}
  32. content={content as { [key: string]: string }}
  33. />
  34. )
  35. )}
  36. </tbody>
  37. </table>
  38. <div className="columns">
  39. <div className="column is-full">
  40. <CustomParamButton
  41. className="is-link is-pulled-right"
  42. type="fa-chevron-right"
  43. onClick={onNext}
  44. btnText="Next"
  45. />
  46. </div>
  47. </div>
  48. </>
  49. );
  50. };
  51. export default MessagesTable;