frameStackContextMenu.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. onZoomIntoFrameClick: (evt: React.MouseEvent<HTMLDivElement>) => void;
  14. }
  15. export function FrameStackContextMenu(props: FrameStackContextMenuProps) {
  16. return props.contextMenu.open ? (
  17. <Fragment>
  18. <ProfilingContextMenuLayer onClick={() => props.contextMenu.setOpen(false)} />
  19. <ProfilingContextMenu
  20. {...props.contextMenu.getMenuProps()}
  21. style={{
  22. position: 'absolute',
  23. left: props.contextMenu.position?.left ?? -9999,
  24. top: props.contextMenu.position?.top ?? -9999,
  25. maxHeight: props.contextMenu.containerCoordinates?.height ?? 'auto',
  26. }}
  27. >
  28. <ProfilingContextMenuGroup>
  29. <ProfilingContextMenuHeading>{t('Actions')}</ProfilingContextMenuHeading>
  30. <ProfilingContextMenuItem
  31. {...props.contextMenu.getMenuItemProps()}
  32. onClick={props.onZoomIntoFrameClick}
  33. >
  34. {t('Show in flamegraph')}
  35. </ProfilingContextMenuItem>
  36. </ProfilingContextMenuGroup>
  37. </ProfilingContextMenu>
  38. </Fragment>
  39. ) : null;
  40. }