Details.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import React from 'react';
  2. import { ClusterName, TopicName } from 'redux/interfaces';
  3. import { Topic, TopicDetails } from 'generated-sources';
  4. import Breadcrumb from 'components/common/Breadcrumb/Breadcrumb';
  5. import { NavLink, Switch, Route } from 'react-router-dom';
  6. import {
  7. clusterTopicsPath,
  8. clusterTopicSettingsPath,
  9. clusterTopicPath,
  10. clusterTopicMessagesPath,
  11. clusterTopicsTopicEditPath,
  12. } from 'lib/paths';
  13. import ClusterContext from 'components/contexts/ClusterContext';
  14. import OverviewContainer from './Overview/OverviewContainer';
  15. import MessagesContainer from './Messages/MessagesContainer';
  16. import SettingsContainer from './Settings/SettingsContainer';
  17. import SettingsEditButton from './Settings/SettingsEditButton';
  18. interface Props extends Topic, TopicDetails {
  19. clusterName: ClusterName;
  20. topicName: TopicName;
  21. }
  22. const Details: React.FC<Props> = ({ clusterName, topicName }) => {
  23. const { isReadOnly } = React.useContext(ClusterContext);
  24. return (
  25. <div className="section">
  26. <div className="level">
  27. <div className="level-item level-left">
  28. <Breadcrumb
  29. links={[
  30. { href: clusterTopicsPath(clusterName), label: 'All Topics' },
  31. ]}
  32. >
  33. {topicName}
  34. </Breadcrumb>
  35. </div>
  36. {!isReadOnly && (
  37. <SettingsEditButton
  38. to={clusterTopicsTopicEditPath(clusterName, topicName)}
  39. />
  40. )}
  41. </div>
  42. <div className="box">
  43. <nav className="navbar" role="navigation">
  44. <NavLink
  45. exact
  46. to={clusterTopicPath(clusterName, topicName)}
  47. className="navbar-item is-tab"
  48. activeClassName="is-active is-primary"
  49. >
  50. Overview
  51. </NavLink>
  52. <NavLink
  53. exact
  54. to={clusterTopicMessagesPath(clusterName, topicName)}
  55. className="navbar-item is-tab"
  56. activeClassName="is-active"
  57. >
  58. Messages
  59. </NavLink>
  60. <NavLink
  61. exact
  62. to={clusterTopicSettingsPath(clusterName, topicName)}
  63. className="navbar-item is-tab"
  64. activeClassName="is-active"
  65. >
  66. Settings
  67. </NavLink>
  68. </nav>
  69. <br />
  70. <Switch>
  71. <Route
  72. exact
  73. path="/ui/clusters/:clusterName/topics/:topicName/messages"
  74. component={MessagesContainer}
  75. />
  76. <Route
  77. exact
  78. path="/ui/clusters/:clusterName/topics/:topicName/settings"
  79. component={SettingsContainer}
  80. />
  81. <Route
  82. exact
  83. path="/ui/clusters/:clusterName/topics/:topicName"
  84. component={OverviewContainer}
  85. />
  86. </Switch>
  87. </div>
  88. </div>
  89. );
  90. };
  91. export default Details;