modulesOnboarding.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 * as ModuleLayout from 'sentry/views/insights/common/components/moduleLayout';
  7. import {useHasFirstSpan} from 'sentry/views/insights/common/queries/useHasFirstSpan';
  8. import {useOnboardingProject} from 'sentry/views/insights/common/queries/useOnboardingProject';
  9. import type {ModuleName} from 'sentry/views/insights/types';
  10. export function ModulesOnboarding({
  11. children,
  12. moduleName,
  13. onboardingContent,
  14. }: {
  15. children: React.ReactNode;
  16. moduleName: ModuleName;
  17. onboardingContent: React.ReactNode;
  18. }) {
  19. const onboardingProject = useOnboardingProject();
  20. const hasData = useHasFirstSpan(moduleName);
  21. if (onboardingProject || !hasData) {
  22. return (
  23. <ModuleLayout.Full>
  24. <ModulesOnboardingPanel>{onboardingContent}</ModulesOnboardingPanel>
  25. </ModuleLayout.Full>
  26. );
  27. }
  28. if (!onboardingProject && hasData) {
  29. return children;
  30. }
  31. // TODO: Add an error state?
  32. return (
  33. <ModuleLayout.Full>
  34. <LoadingIndicator />
  35. </ModuleLayout.Full>
  36. );
  37. }
  38. function ModulesOnboardingPanel({children}: {children: React.ReactNode}) {
  39. return (
  40. <Panel>
  41. <Container>
  42. <ContentContainer>{children}</ContentContainer>
  43. <PerfImage src={emptyStateImg} />
  44. </Container>
  45. </Panel>
  46. );
  47. }
  48. const PerfImage = styled('img')`
  49. width: 260px;
  50. user-select: none;
  51. position: absolute;
  52. bottom: 0;
  53. right: 0;
  54. padding-right: ${space(1)};
  55. `;
  56. const Container = styled('div')`
  57. position: relative;
  58. overflow: hidden;
  59. min-height: 160px;
  60. padding: ${space(4)} ${space(4)} 0;
  61. `;
  62. const ContentContainer = styled('div')`
  63. position: relative;
  64. width: 70%;
  65. z-index: 1;
  66. `;