transactionGroup.tsx 2.3 KB

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