transactionGroup.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 {TraceFullDetailed} from 'sentry/utils/performance/quickTrace/types';
  14. import TransactionBar from './transactionBar';
  15. import {TraceInfo, TraceRoot, TreeDepth} from './types';
  16. type Props = ScrollbarManagerChildrenProps & {
  17. continuingDepths: TreeDepth[];
  18. generateBounds: (bounds: SpanBoundsType) => SpanGeneratedBoundsType;
  19. hasGuideAnchor: boolean;
  20. index: number;
  21. isLast: boolean;
  22. isOrphan: boolean;
  23. isVisible: boolean;
  24. location: Location;
  25. organization: Organization;
  26. renderedChildren: React.ReactNode[];
  27. traceInfo: TraceInfo;
  28. transaction: TraceRoot | TraceFullDetailed;
  29. barColor?: string;
  30. measurements?: Map<number, VerticalMark>;
  31. };
  32. type State = {
  33. isExpanded: boolean;
  34. };
  35. class TransactionGroup extends Component<Props, State> {
  36. state: State = {
  37. isExpanded: true,
  38. };
  39. componentDidUpdate(_prevProps: Props, prevState: State) {
  40. if (prevState.isExpanded !== this.state.isExpanded) {
  41. this.props.updateScrollState();
  42. }
  43. }
  44. toggleExpandedState = () => {
  45. this.setState(({isExpanded}) => ({isExpanded: !isExpanded}));
  46. };
  47. render() {
  48. const {
  49. location,
  50. organization,
  51. transaction,
  52. traceInfo,
  53. continuingDepths,
  54. isOrphan,
  55. isLast,
  56. index,
  57. isVisible,
  58. hasGuideAnchor,
  59. renderedChildren,
  60. barColor,
  61. addContentSpanBarRef,
  62. removeContentSpanBarRef,
  63. onWheel,
  64. measurements,
  65. generateBounds,
  66. } = this.props;
  67. const {isExpanded} = this.state;
  68. return (
  69. <Fragment>
  70. <TransactionBar
  71. location={location}
  72. organization={organization}
  73. measurements={measurements}
  74. generateBounds={generateBounds}
  75. index={index}
  76. transaction={transaction}
  77. traceInfo={traceInfo}
  78. continuingDepths={continuingDepths}
  79. isOrphan={isOrphan}
  80. isLast={isLast}
  81. isExpanded={isExpanded}
  82. toggleExpandedState={this.toggleExpandedState}
  83. isVisible={isVisible}
  84. hasGuideAnchor={hasGuideAnchor}
  85. barColor={barColor}
  86. addContentSpanBarRef={addContentSpanBarRef}
  87. removeContentSpanBarRef={removeContentSpanBarRef}
  88. onWheel={onWheel}
  89. />
  90. {isExpanded && renderedChildren}
  91. </Fragment>
  92. );
  93. }
  94. }
  95. export default withScrollbarManager(TransactionGroup);