index.tsx 1.3 KB

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