transactionGroup.tsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import {Component, Fragment} from 'react';
  2. import {Location} from 'history';
  3. import {SpanDetailProps} from 'sentry/components/events/interfaces/spans/newTraceDetailsSpanDetails';
  4. import {
  5. ScrollbarManagerChildrenProps,
  6. withScrollbarManager,
  7. } from 'sentry/components/events/interfaces/spans/scrollbarManager';
  8. import {
  9. SpanBoundsType,
  10. SpanGeneratedBoundsType,
  11. VerticalMark,
  12. } from 'sentry/components/events/interfaces/spans/utils';
  13. import {Organization} from 'sentry/types';
  14. import {TraceError, TraceFullDetailed} from 'sentry/utils/performance/quickTrace/types';
  15. import {EventDetail} from './newTraceDetailsContent';
  16. import NewTraceDetailsTransactionBar from './newTraceDetailsTransactionBar';
  17. import TransactionBar from './transactionBar';
  18. import {TraceInfo, TraceRoot, TreeDepth} from './types';
  19. type Props = ScrollbarManagerChildrenProps & {
  20. continuingDepths: TreeDepth[];
  21. generateBounds: (bounds: SpanBoundsType) => SpanGeneratedBoundsType;
  22. hasGuideAnchor: boolean;
  23. index: number;
  24. isLast: boolean;
  25. isOrphan: boolean;
  26. isVisible: boolean;
  27. location: Location;
  28. organization: Organization;
  29. renderedChildren: React.ReactNode[];
  30. traceInfo: TraceInfo;
  31. traceViewRef: React.RefObject<HTMLDivElement>;
  32. transaction: TraceRoot | TraceFullDetailed | TraceError;
  33. barColor?: string;
  34. isBarScrolledTo?: boolean;
  35. isOrphanError?: boolean;
  36. measurements?: Map<number, VerticalMark>;
  37. numOfOrphanErrors?: number;
  38. onBarScrolledTo?: () => void;
  39. onRowClick?: (detailKey: EventDetail | SpanDetailProps | undefined) => void;
  40. onlyOrphanErrors?: boolean;
  41. };
  42. type State = {
  43. isExpanded: boolean;
  44. };
  45. class TransactionGroup extends Component<Props, State> {
  46. state: State = {
  47. isExpanded: true,
  48. };
  49. componentDidUpdate(_prevProps: Props, prevState: State) {
  50. if (prevState.isExpanded !== this.state.isExpanded) {
  51. this.props.updateScrollState();
  52. }
  53. }
  54. toggleExpandedState = () => {
  55. this.setState(({isExpanded}) => ({isExpanded: !isExpanded}));
  56. };
  57. render() {
  58. const {
  59. location,
  60. organization,
  61. transaction,
  62. traceInfo,
  63. continuingDepths,
  64. isOrphan,
  65. isLast,
  66. index,
  67. isVisible,
  68. hasGuideAnchor,
  69. renderedChildren,
  70. barColor,
  71. addContentSpanBarRef,
  72. removeContentSpanBarRef,
  73. onWheel,
  74. measurements,
  75. generateBounds,
  76. numOfOrphanErrors,
  77. onlyOrphanErrors,
  78. isOrphanError,
  79. traceViewRef,
  80. onRowClick,
  81. onBarScrolledTo,
  82. isBarScrolledTo,
  83. } = this.props;
  84. const {isExpanded} = this.state;
  85. const commonProps = {
  86. location,
  87. organization,
  88. measurements,
  89. generateBounds,
  90. index,
  91. transaction,
  92. traceInfo,
  93. continuingDepths,
  94. isOrphan,
  95. isLast,
  96. isExpanded,
  97. toggleExpandedState: this.toggleExpandedState,
  98. isVisible,
  99. hasGuideAnchor,
  100. barColor,
  101. addContentSpanBarRef,
  102. removeContentSpanBarRef,
  103. onWheel,
  104. onlyOrphanErrors,
  105. numOfOrphanErrors,
  106. isOrphanError,
  107. };
  108. return (
  109. <Fragment>
  110. {organization.features.includes('performance-trace-details') &&
  111. onBarScrolledTo ? (
  112. <NewTraceDetailsTransactionBar
  113. {...commonProps}
  114. isBarScrolledTo={!!isBarScrolledTo}
  115. onBarScrolledTo={onBarScrolledTo}
  116. traceViewRef={traceViewRef}
  117. onRowClick={onRowClick}
  118. />
  119. ) : (
  120. <TransactionBar {...commonProps} />
  121. )}
  122. {isExpanded && renderedChildren}
  123. </Fragment>
  124. );
  125. }
  126. }
  127. export default withScrollbarManager(TransactionGroup);