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 * as ModuleLayout from 'sentry/views/insights/common/components/moduleLayout';
  8. import {useHasData} from 'sentry/views/insights/common/queries/useHasData';
  9. import {useOnboardingProject} from 'sentry/views/insights/common/queries/useOnboardingProject';
  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. width: 260px;
  52. user-select: none;
  53. position: absolute;
  54. bottom: 0;
  55. right: 0;
  56. padding-right: ${space(1)};
  57. `;
  58. const Container = styled('div')`
  59. position: relative;
  60. overflow: hidden;
  61. min-height: 160px;
  62. padding: ${space(4)} ${space(4)} 0;
  63. `;
  64. const ContentContainer = styled('div')`
  65. position: relative;
  66. width: 70%;
  67. z-index: 1;
  68. `;