Overview.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import React from 'react';
  2. import { ClusterId, Topic, TopicDetails, TopicName } from 'types';
  3. import MetricsWrapper from 'components/common/Dashboard/MetricsWrapper';
  4. import Indicator from 'components/common/Dashboard/Indicator';
  5. interface Props extends Topic, TopicDetails {
  6. isFetched: boolean;
  7. clusterId: ClusterId;
  8. topicName: TopicName;
  9. fetchTopicDetails: (clusterId: ClusterId, topicName: TopicName) => void;
  10. }
  11. const Overview: React.FC<Props> = ({
  12. isFetched,
  13. clusterId,
  14. topicName,
  15. partitions,
  16. underReplicatedPartitions,
  17. inSyncReplicas,
  18. replicas,
  19. partitionCount,
  20. internal,
  21. replicationFactor,
  22. fetchTopicDetails,
  23. }) => {
  24. React.useEffect(
  25. () => { fetchTopicDetails(clusterId, topicName); },
  26. [fetchTopicDetails, clusterId, topicName],
  27. );
  28. if (!isFetched) {
  29. return null;
  30. }
  31. return (
  32. <>
  33. <MetricsWrapper>
  34. <Indicator label="Partitions">
  35. {partitionCount}
  36. </Indicator>
  37. <Indicator label="Replication Factor">
  38. {replicationFactor}
  39. </Indicator>
  40. <Indicator label="URP" title="Under replicated partitions">
  41. {underReplicatedPartitions}
  42. </Indicator>
  43. <Indicator label="In sync replicas">
  44. {inSyncReplicas}
  45. <span className="subtitle has-text-weight-light"> of {replicas}</span>
  46. </Indicator>
  47. <Indicator label="Type">
  48. <span className="tag is-primary">
  49. {internal ? 'Internal' : 'External'}
  50. </span>
  51. </Indicator>
  52. </MetricsWrapper>
  53. <div className="box">
  54. <table className="table is-striped is-fullwidth">
  55. <thead>
  56. <tr>
  57. <th>Partition ID</th>
  58. <th>Broker leader</th>
  59. </tr>
  60. </thead>
  61. <tbody>
  62. {partitions.map(({ partition, leader }) => (
  63. <tr key={`partition-list-item-key-${partition}`}>
  64. <td>{partition}</td>
  65. <td>{leader}</td>
  66. </tr>
  67. ))}
  68. </tbody>
  69. </table>
  70. </div>
  71. </>
  72. );
  73. }
  74. export default Overview;