Schemas.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React from 'react';
  2. import { ClusterName } from 'redux/interfaces';
  3. import { Switch, Route, useParams } from 'react-router-dom';
  4. import PageLoader from 'components/common/PageLoader/PageLoader';
  5. import ListContainer from './List/ListContainer';
  6. import DetailsContainer from './Details/DetailsContainer';
  7. import NewContainer from './New/NewContainer';
  8. import ClusterContext from '../contexts/ClusterContext';
  9. export interface SchemasProps {
  10. isFetching: boolean;
  11. fetchSchemasByClusterName: (clusterName: ClusterName) => void;
  12. isReadOnly: boolean;
  13. }
  14. const Schemas: React.FC<SchemasProps> = ({
  15. isFetching,
  16. fetchSchemasByClusterName,
  17. isReadOnly,
  18. }) => {
  19. const { clusterName } = useParams<{ clusterName: string }>();
  20. React.useEffect(() => {
  21. fetchSchemasByClusterName(clusterName);
  22. }, [fetchSchemasByClusterName, clusterName]);
  23. if (isFetching) {
  24. return <PageLoader />;
  25. }
  26. return (
  27. <ClusterContext.Provider value={{ isReadOnly }}>
  28. <Switch>
  29. <Route
  30. exact
  31. path="/ui/clusters/:clusterName/schemas"
  32. component={ListContainer}
  33. />
  34. <Route
  35. exact
  36. path="/ui/clusters/:clusterName/schemas/new"
  37. component={NewContainer}
  38. />
  39. <Route
  40. exact
  41. path="/ui/clusters/:clusterName/schemas/:subject/latest"
  42. component={DetailsContainer}
  43. />
  44. </Switch>
  45. </ClusterContext.Provider>
  46. );
  47. };
  48. export default Schemas;