transactionGroup.tsx 3.0 KB

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