transactionGroup.tsx 3.7 KB

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