Details.tsx 2.5 KB

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