transactionGroup.tsx 3.0 KB

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