List.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import React from 'react';
  2. import { TopicWithDetailedInfo, ClusterId } from 'redux/interfaces';
  3. import ListItem from './ListItem';
  4. import Breadcrumb from 'components/common/Breadcrumb/Breadcrumb';
  5. import { NavLink } from 'react-router-dom';
  6. import { clusterTopicNewPath } from 'lib/paths';
  7. interface Props {
  8. clusterId: ClusterId;
  9. topics: (TopicWithDetailedInfo)[];
  10. externalTopics: (TopicWithDetailedInfo)[];
  11. }
  12. const List: React.FC<Props> = ({
  13. clusterId,
  14. topics,
  15. externalTopics,
  16. }) => {
  17. const [showInternal, setShowInternal] = React.useState<boolean>(true);
  18. const handleSwitch = () => setShowInternal(!showInternal);
  19. const items = showInternal ? topics : externalTopics;
  20. return (
  21. <div className="section">
  22. <Breadcrumb>All Topics</Breadcrumb>
  23. <div className="box">
  24. <div className="level">
  25. <div className="level-item level-left">
  26. <div className="field">
  27. <input
  28. id="switchRoundedDefault"
  29. type="checkbox"
  30. name="switchRoundedDefault"
  31. className="switch is-rounded"
  32. checked={showInternal}
  33. onChange={handleSwitch}
  34. />
  35. <label htmlFor="switchRoundedDefault">
  36. Show Internal Topics
  37. </label>
  38. </div>
  39. </div>
  40. <div className="level-item level-right">
  41. <NavLink
  42. className="button is-primary"
  43. to={clusterTopicNewPath(clusterId)}
  44. >
  45. Add a Topic
  46. </NavLink>
  47. </div>
  48. </div>
  49. </div>
  50. <div className="box">
  51. <table className="table is-striped is-fullwidth">
  52. <thead>
  53. <tr>
  54. <th>Topic Name</th>
  55. <th>Total Partitions</th>
  56. <th>Out of sync replicas</th>
  57. <th>Type</th>
  58. </tr>
  59. </thead>
  60. <tbody>
  61. {items.map((topic, index) => (
  62. <ListItem
  63. key={`topic-list-item-key-${index}`}
  64. {...topic}
  65. />
  66. ))}
  67. </tbody>
  68. </table>
  69. </div>
  70. </div>
  71. );
  72. }
  73. export default List;