FlamegraphWarnings.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import styled from '@emotion/styled';
  2. import {ExportProfileButton} from 'sentry/components/profiling/exportProfileButton';
  3. import {t} from 'sentry/locale';
  4. import {Flamegraph} from 'sentry/utils/profiling/flamegraph';
  5. import {useParams} from 'sentry/utils/useParams';
  6. interface FlamegraphWarningProps {
  7. flamegraph: Flamegraph;
  8. }
  9. export function FlamegraphWarnings(props: FlamegraphWarningProps) {
  10. const params = useParams();
  11. // A profile may be empty while we are fetching it from the network; while that is happening an empty profile is
  12. // passed down to the view so that all the components can be loaded and initialized ahead of time.
  13. if (props.flamegraph.profile.isEmpty()) {
  14. return null;
  15. }
  16. if (props.flamegraph.profile.samples.length === 0) {
  17. return (
  18. <Overlay>
  19. <p>
  20. {t(
  21. 'This profile either has no samples or the total duration of frames in the profile is 0.'
  22. )}
  23. </p>
  24. <div>
  25. <ExportProfileButton
  26. variant="default"
  27. eventId={params.eventId}
  28. orgId={params.orgId}
  29. size="sm"
  30. projectId={params.projectId}
  31. title={undefined}
  32. disabled={
  33. params.eventId === undefined ||
  34. params.orgId === undefined ||
  35. params.projectId === undefined
  36. }
  37. >
  38. {t('Export Raw Profile')}
  39. </ExportProfileButton>
  40. </div>
  41. </Overlay>
  42. );
  43. }
  44. return null;
  45. }
  46. const Overlay = styled('div')`
  47. position: absolute;
  48. left: 0;
  49. top: 0;
  50. width: 100%;
  51. height: 100%;
  52. display: grid;
  53. grid: auto/50%;
  54. place-content: center;
  55. z-index: ${p => p.theme.zIndex.initial};
  56. text-align: center;
  57. `;