modulesOnboarding.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import styled from '@emotion/styled';
  2. import emptyStateImg from 'sentry-images/spot/performance-waiting-for-span.svg';
  3. import LoadingIndicator from 'sentry/components/loadingIndicator';
  4. import Panel from 'sentry/components/panels/panel';
  5. import {space} from 'sentry/styles/space';
  6. import type {MutableSearch} from 'sentry/utils/tokenizeSearch';
  7. import {useOnboardingProject} from 'sentry/views/performance/browser/webVitals/utils/useOnboardingProject';
  8. import * as ModuleLayout from 'sentry/views/performance/moduleLayout';
  9. import {useHasData} from 'sentry/views/performance/onboarding/useHasData';
  10. export function ModulesOnboarding({
  11. children,
  12. moduleQueryFilter,
  13. onboardingContent,
  14. referrer,
  15. }: {
  16. children: React.ReactNode;
  17. moduleQueryFilter: MutableSearch;
  18. onboardingContent: React.ReactNode;
  19. referrer: string;
  20. }) {
  21. const onboardingProject = useOnboardingProject();
  22. const {hasData, isLoading} = useHasData(moduleQueryFilter, referrer);
  23. if (onboardingProject || (!hasData && !isLoading)) {
  24. return (
  25. <ModuleLayout.Full>
  26. <ModulesOnboardingPanel>{onboardingContent}</ModulesOnboardingPanel>
  27. </ModuleLayout.Full>
  28. );
  29. }
  30. if (!onboardingProject && hasData && !isLoading) {
  31. return children;
  32. }
  33. // TODO: Add an error state?
  34. return (
  35. <ModuleLayout.Full>
  36. <LoadingIndicator />
  37. </ModuleLayout.Full>
  38. );
  39. }
  40. function ModulesOnboardingPanel({children}: {children: React.ReactNode}) {
  41. return (
  42. <Panel>
  43. <Container>
  44. <ContentContainer>{children}</ContentContainer>
  45. <PerfImage src={emptyStateImg} />
  46. </Container>
  47. </Panel>
  48. );
  49. }
  50. const PerfImage = styled('img')`
  51. -webkit-transform: scaleX(-1);
  52. transform: scaleX(-1);
  53. width: 600px;
  54. user-select: none;
  55. position: absolute;
  56. bottom: 0;
  57. right: 0;
  58. `;
  59. const Container = styled('div')`
  60. position: relative;
  61. overflow: hidden;
  62. min-height: 160px;
  63. padding: ${space(4)} ${space(4)} 0;
  64. `;
  65. const ContentContainer = styled('div')`
  66. position: relative;
  67. z-index: 1;
  68. `;