MessagesTable.tsx 1.5 KB

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