index.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import {useContext} from 'react';
  2. import {useTheme} from '@emotion/react';
  3. import styled from '@emotion/styled';
  4. import {Location} from 'history';
  5. import Placeholder from 'sentry/components/placeholder';
  6. import {space} from 'sentry/styles/space';
  7. import {Group, Organization} from 'sentry/types';
  8. import {Event} from 'sentry/types/event';
  9. import {QuickTraceContext} from 'sentry/utils/performance/quickTrace/quickTraceContext';
  10. import useMedia from 'sentry/utils/useMedia';
  11. import IssueQuickTrace from './issueQuickTrace';
  12. type Props = {
  13. event: Event;
  14. group: Group;
  15. location: Location;
  16. organization: Organization;
  17. };
  18. function QuickTrace({group, event, organization, location}: Props) {
  19. const theme = useTheme();
  20. const hasPerformanceView = organization.features.includes('performance-view');
  21. const hasTraceContext = Boolean(event.contexts?.trace?.trace_id);
  22. const quickTrace = useContext(QuickTraceContext);
  23. const isSmallViewport = useMedia(`(max-width: ${theme.breakpoints.small})`);
  24. if (isSmallViewport || !hasPerformanceView || !hasTraceContext) {
  25. return null;
  26. }
  27. if (quickTrace?.isLoading) {
  28. return <TracePlaceholder height="20px" />;
  29. }
  30. return (
  31. <IssueQuickTrace
  32. organization={organization}
  33. event={event}
  34. location={location}
  35. group={group}
  36. quickTrace={quickTrace}
  37. />
  38. );
  39. }
  40. const TracePlaceholder = styled(Placeholder)`
  41. width: auto;
  42. max-width: 300px;
  43. margin-top: ${space(0.75)};
  44. `;
  45. export default QuickTrace;