flamegraphAxisOptionsMenu.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import styled from '@emotion/styled';
  2. import DropdownButton from 'sentry/components/dropdownButton';
  3. import DropdownControl, {DropdownItem} from 'sentry/components/dropdownControl';
  4. import {t} from 'sentry/locale';
  5. import space from 'sentry/styles/space';
  6. import {useFlamegraphPreferences} from 'sentry/utils/profiling/flamegraph/useFlamegraphPreferences';
  7. function FlamegraphXAxisOptionsMenu(): React.ReactElement {
  8. const [{synchronizeXAxisWithTransaction}, dispatch] = useFlamegraphPreferences();
  9. return (
  10. <OptionsMenuContainer>
  11. <DropdownControl
  12. button={({isOpen, getActorProps}) => (
  13. <DropdownButton
  14. {...getActorProps()}
  15. isOpen={isOpen}
  16. prefix={t('X Axis')}
  17. size="xsmall"
  18. >
  19. {synchronizeXAxisWithTransaction ? 'Transaction' : 'Standalone'}
  20. </DropdownButton>
  21. )}
  22. >
  23. <DropdownItem
  24. onSelect={() =>
  25. dispatch({
  26. type: 'set synchronizeXAxisWithTransaction',
  27. payload: false,
  28. })
  29. }
  30. isActive={!synchronizeXAxisWithTransaction}
  31. >
  32. Standalone
  33. </DropdownItem>
  34. <DropdownItem
  35. onSelect={() =>
  36. dispatch({
  37. type: 'set synchronizeXAxisWithTransaction',
  38. payload: true,
  39. })
  40. }
  41. isActive={synchronizeXAxisWithTransaction}
  42. >
  43. Transaction
  44. </DropdownItem>
  45. </DropdownControl>
  46. </OptionsMenuContainer>
  47. );
  48. }
  49. const OptionsMenuContainer = styled('div')`
  50. display: flex;
  51. flex-direction: row;
  52. gap: ${space(0.5)};
  53. justify-content: flex-end;
  54. `;
  55. export {FlamegraphXAxisOptionsMenu};