Config.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import React from 'react';
  2. import { useParams } from 'react-router';
  3. import {
  4. ClusterName,
  5. ConnectName,
  6. ConnectorConfig,
  7. ConnectorName,
  8. } from 'redux/interfaces';
  9. import PageLoader from 'components/common/PageLoader/PageLoader';
  10. import JSONEditor from 'components/common/JSONEditor/JSONEditor';
  11. interface RouterParams {
  12. clusterName: ClusterName;
  13. connectName: ConnectName;
  14. connectorName: ConnectorName;
  15. }
  16. export interface ConfigProps {
  17. fetchConfig(
  18. clusterName: ClusterName,
  19. connectName: ConnectName,
  20. connectorName: ConnectorName,
  21. silent?: boolean
  22. ): void;
  23. isConfigFetching: boolean;
  24. config: ConnectorConfig | null;
  25. }
  26. const Config: React.FC<ConfigProps> = ({
  27. fetchConfig,
  28. isConfigFetching,
  29. config,
  30. }) => {
  31. const { clusterName, connectName, connectorName } = useParams<RouterParams>();
  32. React.useEffect(() => {
  33. fetchConfig(clusterName, connectName, connectorName, true);
  34. }, [fetchConfig, clusterName, connectName, connectorName]);
  35. if (isConfigFetching) {
  36. return <PageLoader />;
  37. }
  38. if (!config) return null;
  39. return (
  40. <JSONEditor
  41. readOnly
  42. value={JSON.stringify(config, null, '\t')}
  43. showGutter={false}
  44. highlightActiveLine={false}
  45. isFixedHeight
  46. />
  47. );
  48. };
  49. export default Config;