transactionGroup.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 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 | TraceError;
  29. barColor?: string;
  30. isOrphanError?: boolean;
  31. measurements?: Map<number, VerticalMark>;
  32. numOfOrphanErrors?: number;
  33. };
  34. type State = {
  35. isExpanded: boolean;
  36. };
  37. class TransactionGroup extends Component<Props, State> {
  38. state: State = {
  39. isExpanded: true,
  40. };
  41. componentDidUpdate(_prevProps: Props, prevState: State) {
  42. if (prevState.isExpanded !== this.state.isExpanded) {
  43. this.props.updateScrollState();
  44. }
  45. }
  46. toggleExpandedState = () => {
  47. this.setState(({isExpanded}) => ({isExpanded: !isExpanded}));
  48. };
  49. render() {
  50. const {
  51. location,
  52. organization,
  53. transaction,
  54. traceInfo,
  55. continuingDepths,
  56. isOrphan,
  57. isLast,
  58. index,
  59. isVisible,
  60. hasGuideAnchor,
  61. renderedChildren,
  62. barColor,
  63. addContentSpanBarRef,
  64. removeContentSpanBarRef,
  65. onWheel,
  66. measurements,
  67. generateBounds,
  68. numOfOrphanErrors,
  69. isOrphanError,
  70. } = this.props;
  71. const {isExpanded} = this.state;
  72. return (
  73. <Fragment>
  74. <TransactionBar
  75. location={location}
  76. organization={organization}
  77. measurements={measurements}
  78. generateBounds={generateBounds}
  79. index={index}
  80. transaction={transaction}
  81. traceInfo={traceInfo}
  82. continuingDepths={continuingDepths}
  83. isOrphan={isOrphan}
  84. isLast={isLast}
  85. isExpanded={isExpanded}
  86. toggleExpandedState={this.toggleExpandedState}
  87. isVisible={isVisible}
  88. hasGuideAnchor={hasGuideAnchor}
  89. barColor={barColor}
  90. addContentSpanBarRef={addContentSpanBarRef}
  91. removeContentSpanBarRef={removeContentSpanBarRef}
  92. onWheel={onWheel}
  93. numOfOrphanErrors={numOfOrphanErrors}
  94. isOrphanError={isOrphanError}
  95. />
  96. {isExpanded && renderedChildren}
  97. </Fragment>
  98. );
  99. }
  100. }
  101. export default withScrollbarManager(TransactionGroup);