traceResetZoomButton.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import {useCallback} from 'react';
  2. import styled from '@emotion/styled';
  3. import {Button} from 'sentry/components/button';
  4. import {t} from 'sentry/locale';
  5. import type {Organization} from 'sentry/types/organization';
  6. import {traceAnalytics} from 'sentry/views/performance/newTraceDetails/traceAnalytics';
  7. import type {VirtualizedViewManager} from 'sentry/views/performance/newTraceDetails/traceRenderers/virtualizedViewManager';
  8. export function TraceResetZoomButton(props: {
  9. organization: Organization;
  10. viewManager: VirtualizedViewManager;
  11. }) {
  12. const onResetZoom = useCallback(() => {
  13. traceAnalytics.trackResetZoom(props.organization);
  14. props.viewManager.resetZoom();
  15. }, [props.viewManager, props.organization]);
  16. return (
  17. <ResetZoomButton
  18. size="xs"
  19. onClick={onResetZoom}
  20. ref={props.viewManager.registerResetZoomRef}
  21. >
  22. {t('Reset Zoom')}
  23. </ResetZoomButton>
  24. );
  25. }
  26. const ResetZoomButton = styled(Button)`
  27. transition: opacity 0.2s 0.5s ease-in-out;
  28. &[disabled] {
  29. cursor: not-allowed;
  30. opacity: 0.65;
  31. }
  32. `;