transactionGroup.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. isOrphanError?: boolean;
  35. measurements?: Map<number, VerticalMark>;
  36. numOfOrphanErrors?: number;
  37. onRowClick?: (detailKey: EventDetail | SpanDetailProps | undefined) => void;
  38. onlyOrphanErrors?: boolean;
  39. };
  40. type State = {
  41. isExpanded: boolean;
  42. };
  43. class TransactionGroup extends Component<Props, State> {
  44. state: State = {
  45. isExpanded: true,
  46. };
  47. componentDidUpdate(_prevProps: Props, prevState: State) {
  48. if (prevState.isExpanded !== this.state.isExpanded) {
  49. this.props.updateScrollState();
  50. }
  51. }
  52. toggleExpandedState = () => {
  53. this.setState(({isExpanded}) => ({isExpanded: !isExpanded}));
  54. };
  55. render() {
  56. const {
  57. location,
  58. organization,
  59. transaction,
  60. traceInfo,
  61. continuingDepths,
  62. isOrphan,
  63. isLast,
  64. index,
  65. isVisible,
  66. hasGuideAnchor,
  67. renderedChildren,
  68. barColor,
  69. addContentSpanBarRef,
  70. removeContentSpanBarRef,
  71. onWheel,
  72. measurements,
  73. generateBounds,
  74. numOfOrphanErrors,
  75. onlyOrphanErrors,
  76. isOrphanError,
  77. traceViewRef,
  78. onRowClick,
  79. } = this.props;
  80. const {isExpanded} = this.state;
  81. const commonProps = {
  82. location,
  83. organization,
  84. measurements,
  85. generateBounds,
  86. index,
  87. transaction,
  88. traceInfo,
  89. continuingDepths,
  90. isOrphan,
  91. isLast,
  92. isExpanded,
  93. toggleExpandedState: this.toggleExpandedState,
  94. isVisible,
  95. hasGuideAnchor,
  96. barColor,
  97. addContentSpanBarRef,
  98. removeContentSpanBarRef,
  99. onWheel,
  100. onlyOrphanErrors,
  101. numOfOrphanErrors,
  102. isOrphanError,
  103. };
  104. return (
  105. <Fragment>
  106. {organization.features.includes('performance-trace-details') ? (
  107. <NewTraceDetailsTransactionBar
  108. {...commonProps}
  109. traceViewRef={traceViewRef}
  110. onRowClick={onRowClick}
  111. />
  112. ) : (
  113. <TransactionBar {...commonProps} />
  114. )}
  115. {isExpanded && renderedChildren}
  116. </Fragment>
  117. );
  118. }
  119. }
  120. export default withScrollbarManager(TransactionGroup);