traceRootNode.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import {Fragment} from 'react';
  2. import {t} from 'sentry/locale';
  3. import {isTraceNode} from '../traceGuards';
  4. import {TraceIcons} from '../traceIcons';
  5. import type {TraceTree} from '../traceModels/traceTree';
  6. import type {TraceTreeNode} from '../traceModels/traceTreeNode';
  7. import {makeTraceNodeBarColor, TraceBar} from '../traceRow/traceBar';
  8. import {
  9. maybeFocusTraceRow,
  10. TRACE_COUNT_FORMATTER,
  11. TraceChildrenButton,
  12. TraceRowConnectors,
  13. type TraceRowProps,
  14. } from '../traceRow/traceRow';
  15. const NO_ERRORS = new Set<TraceTree.TraceError>();
  16. const NO_PERFORMANCE_ISSUES = new Set<TraceTree.TracePerformanceIssue>();
  17. const NO_PROFILES = [];
  18. export function TraceRootRow(props: TraceRowProps<TraceTreeNode<TraceTree.Trace>>) {
  19. if (!isTraceNode(props.node)) {
  20. throw new Error('Trace row rendered called on row that is not root');
  21. }
  22. return (
  23. <div
  24. key={props.index}
  25. ref={r =>
  26. props.tabIndex === 0
  27. ? maybeFocusTraceRow(r, props.node, props.previouslyFocusedNodeRef)
  28. : null
  29. }
  30. tabIndex={props.tabIndex}
  31. className={`TraceRow ${props.rowSearchClassName} ${props.node.hasErrors ? props.node.maxIssueSeverity : ''}`}
  32. onPointerDown={props.onRowClick}
  33. onKeyDown={props.onRowKeyDown}
  34. style={props.style}
  35. >
  36. <div
  37. className="TraceLeftColumn"
  38. ref={props.registerListColumnRef}
  39. onDoubleClick={props.onRowDoubleClick}
  40. >
  41. <div className="TraceLeftColumnInner" style={props.listColumnStyle}>
  42. {' '}
  43. <div className="TraceChildrenCountWrapper Root">
  44. <TraceRowConnectors node={props.node} manager={props.manager} />
  45. {props.node.children.length > 0 || props.node.canFetch ? (
  46. <TraceChildrenButton
  47. icon={''}
  48. status={props.node.fetchStatus}
  49. expanded
  50. onClick={() => void 0}
  51. onDoubleClick={props.onExpandDoubleClick}
  52. >
  53. {props.node.fetchStatus === 'loading'
  54. ? null
  55. : props.node.children.length > 0
  56. ? TRACE_COUNT_FORMATTER.format(props.node.children.length)
  57. : null}
  58. </TraceChildrenButton>
  59. ) : null}
  60. </div>
  61. <span className="TraceOperation">{t('Trace')}</span>
  62. {props.trace_id ? (
  63. <Fragment>
  64. <strong className="TraceEmDash"> — </strong>
  65. <span className="TraceDescription">{props.trace_id}</span>
  66. </Fragment>
  67. ) : null}
  68. </div>
  69. </div>
  70. <div
  71. ref={props.registerSpanColumnRef}
  72. className={props.spanColumnClassName}
  73. onDoubleClick={props.onRowDoubleClick}
  74. >
  75. <TraceBar
  76. node={props.node}
  77. virtualized_index={props.virtualized_index}
  78. manager={props.manager}
  79. color={makeTraceNodeBarColor(props.theme, props.node)}
  80. node_space={props.node.space}
  81. errors={NO_ERRORS}
  82. performance_issues={NO_PERFORMANCE_ISSUES}
  83. profiles={NO_PROFILES}
  84. />
  85. <button
  86. ref={props.registerSpanArrowRef}
  87. className="TraceArrow"
  88. onClick={props.onSpanArrowClick}
  89. >
  90. <TraceIcons.Chevron direction="left" />
  91. </button>
  92. </div>
  93. </div>
  94. );
  95. }