pipelineView.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {useEffect} from 'react';
  2. import Indicators from 'sentry/components/indicators';
  3. import {ThemeAndStyleProvider} from 'sentry/components/themeAndStyleProvider';
  4. import AwsLambdaCloudformation from './awsLambdaCloudformation';
  5. import AwsLambdaFailureDetails from './awsLambdaFailureDetails';
  6. import AwsLambdaFunctionSelect from './awsLambdaFunctionSelect';
  7. import AwsLambdaProjectSelect from './awsLambdaProjectSelect';
  8. const pipelineMapper: Record<string, [React.ComponentType<any>, string]> = {
  9. awsLambdaProjectSelect: [AwsLambdaProjectSelect, 'AWS Lambda Select Project'],
  10. awsLambdaFunctionSelect: [AwsLambdaFunctionSelect, 'AWS Lambda Select Lambdas'],
  11. awsLambdaCloudformation: [AwsLambdaCloudformation, 'AWS Lambda Create Cloudformation'],
  12. awsLambdaFailureDetails: [AwsLambdaFailureDetails, 'AWS Lambda View Failures'],
  13. };
  14. type Props = {
  15. [key: string]: any;
  16. pipelineName: string;
  17. };
  18. /**
  19. * This component is a wrapper for specific pipeline views for integrations
  20. */
  21. function PipelineView({pipelineName, ...props}: Props) {
  22. const mapping = pipelineMapper[pipelineName];
  23. if (!mapping) {
  24. throw new Error(`Invalid pipeline name ${pipelineName}`);
  25. }
  26. const [Component, title] = mapping;
  27. // Set the page title
  28. useEffect(() => void (document.title = title), [title]);
  29. return (
  30. <ThemeAndStyleProvider>
  31. <Indicators className="indicators-container" />
  32. <Component {...props} />
  33. </ThemeAndStyleProvider>
  34. );
  35. }
  36. export default PipelineView;