List.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import React from 'react';
  2. import { ClusterName } from 'redux/interfaces';
  3. import { ConsumerGroup } from 'generated-sources';
  4. import Breadcrumb from 'components/common/Breadcrumb/Breadcrumb';
  5. import ListItem from './ListItem';
  6. interface Props {
  7. clusterName: ClusterName;
  8. consumerGroups: ConsumerGroup[];
  9. }
  10. const List: React.FC<Props> = ({ consumerGroups }) => {
  11. const [searchText, setSearchText] = React.useState<string>('');
  12. const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
  13. setSearchText(event.target.value);
  14. };
  15. return (
  16. <div className="section">
  17. <Breadcrumb>All Consumer Groups</Breadcrumb>
  18. <div className="box">
  19. {consumerGroups.length > 0 ? (
  20. <div>
  21. <div className="columns">
  22. <div className="column is-half is-offset-half">
  23. <input
  24. id="searchText"
  25. type="text"
  26. name="searchText"
  27. className="input"
  28. placeholder="Search"
  29. value={searchText}
  30. onChange={handleInputChange}
  31. />
  32. </div>
  33. </div>
  34. <div className="table-container">
  35. <table className="table is-striped is-fullwidth is-hoverable">
  36. <thead>
  37. <tr>
  38. <th>Consumer group ID</th>
  39. <th>Num of consumers</th>
  40. <th>Num of topics</th>
  41. </tr>
  42. </thead>
  43. <tbody>
  44. {consumerGroups
  45. .filter(
  46. (consumerGroup) =>
  47. !searchText ||
  48. consumerGroup?.consumerGroupId?.indexOf(searchText) >= 0
  49. )
  50. .map((consumerGroup) => (
  51. <ListItem
  52. key={consumerGroup.consumerGroupId}
  53. consumerGroup={consumerGroup}
  54. />
  55. ))}
  56. </tbody>
  57. </table>
  58. </div>
  59. </div>
  60. ) : (
  61. 'No active consumer groups'
  62. )}
  63. </div>
  64. </div>
  65. );
  66. };
  67. export default List;