transactionGroup.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. } = this.props;
  55. const {isExpanded} = this.state;
  56. return (
  57. <Fragment>
  58. <TransactionBar
  59. location={location}
  60. organization={organization}
  61. index={index}
  62. transaction={transaction}
  63. traceInfo={traceInfo}
  64. continuingDepths={continuingDepths}
  65. isOrphan={isOrphan}
  66. isLast={isLast}
  67. isExpanded={isExpanded}
  68. toggleExpandedState={this.toggleExpandedState}
  69. isVisible={isVisible}
  70. hasGuideAnchor={hasGuideAnchor}
  71. barColor={barColor}
  72. />
  73. {isExpanded && renderedChildren}
  74. </Fragment>
  75. );
  76. }
  77. }
  78. export default withScrollbarManager(TransactionGroup);