FlamegraphWarnings.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. if (props.flamegraph.profile.samples.length === 0) {
  12. return (
  13. <Overlay>
  14. <p>
  15. {t(
  16. 'This profile either has no samples or the total duration of frames in the profile is 0.'
  17. )}
  18. </p>
  19. <div>
  20. <ExportProfileButton
  21. variant="default"
  22. eventId={params.eventId}
  23. orgId={params.orgId}
  24. size="sm"
  25. projectId={params.projectId}
  26. title={undefined}
  27. disabled={
  28. params.eventId === undefined ||
  29. params.orgId === undefined ||
  30. params.projectId === undefined
  31. }
  32. >
  33. {t('Export Raw Profile')}
  34. </ExportProfileButton>
  35. </div>
  36. </Overlay>
  37. );
  38. }
  39. return null;
  40. }
  41. const Overlay = styled('div')`
  42. position: absolute;
  43. left: 0;
  44. top: 0;
  45. width: 100%;
  46. height: 100%;
  47. display: grid;
  48. grid: auto/50%;
  49. place-content: center;
  50. z-index: ${p => p.theme.zIndex.modal};
  51. text-align: center;
  52. `;