frameStackContextMenu.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import {Fragment} from 'react';
  2. import {
  3. ProfilingContextMenu,
  4. ProfilingContextMenuGroup,
  5. ProfilingContextMenuHeading,
  6. ProfilingContextMenuItem,
  7. ProfilingContextMenuLayer,
  8. } from 'sentry/components/profiling/ProfilingContextMenu/profilingContextMenu';
  9. import {t} from 'sentry/locale';
  10. import {useContextMenu} from 'sentry/utils/profiling/hooks/useContextMenu';
  11. interface FrameStackContextMenuProps {
  12. contextMenu: ReturnType<typeof useContextMenu>;
  13. onHighlightAllFramesClick: (evt: React.MouseEvent<HTMLDivElement>) => void;
  14. onZoomIntoFrameClick: (evt: React.MouseEvent<HTMLDivElement>) => void;
  15. }
  16. export function FrameStackContextMenu(props: FrameStackContextMenuProps) {
  17. return props.contextMenu.open ? (
  18. <Fragment>
  19. <ProfilingContextMenuLayer onClick={() => props.contextMenu.setOpen(false)} />
  20. <ProfilingContextMenu
  21. {...props.contextMenu.getMenuProps()}
  22. style={{
  23. position: 'absolute',
  24. left: props.contextMenu.position?.left ?? -9999,
  25. top: props.contextMenu.position?.top ?? -9999,
  26. maxHeight: props.contextMenu.containerCoordinates?.height ?? 'auto',
  27. }}
  28. >
  29. <ProfilingContextMenuGroup>
  30. <ProfilingContextMenuHeading>{t('Actions')}</ProfilingContextMenuHeading>
  31. <ProfilingContextMenuItem
  32. {...props.contextMenu.getMenuItemProps()}
  33. onClick={props.onZoomIntoFrameClick}
  34. >
  35. {t('Show on flamechart')}
  36. </ProfilingContextMenuItem>
  37. <ProfilingContextMenuItem
  38. {...props.contextMenu.getMenuItemProps()}
  39. onClick={props.onHighlightAllFramesClick}
  40. >
  41. {t('Highlight all occurrences')}
  42. </ProfilingContextMenuItem>
  43. </ProfilingContextMenuGroup>
  44. </ProfilingContextMenu>
  45. </Fragment>
  46. ) : null;
  47. }