traceTransactionRow.tsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import {PlatformIcon} from 'platformicons';
  2. import {TraceIcons} from '../traceIcons';
  3. import type {TraceTree} from '../traceModels/traceTree';
  4. import type {TraceTreeNode} from '../traceModels/traceTreeNode';
  5. import {makeTraceNodeBarColor, TraceBar} from '../traceRow/traceBar';
  6. import {
  7. maybeFocusTraceRow,
  8. TRACE_COUNT_FORMATTER,
  9. TraceChildrenButton,
  10. TraceRowConnectors,
  11. type TraceRowProps,
  12. } from '../traceRow/traceRow';
  13. export function TraceTransactionRow(
  14. props: TraceRowProps<TraceTreeNode<TraceTree.Transaction>>
  15. ) {
  16. return (
  17. <div
  18. key={props.index}
  19. ref={r =>
  20. props.tabIndex === 0
  21. ? maybeFocusTraceRow(r, props.node, props.previouslyFocusedNodeRef)
  22. : null
  23. }
  24. tabIndex={props.tabIndex}
  25. className={`TraceRow ${props.rowSearchClassName} ${props.node.hasErrors ? props.node.maxIssueSeverity : ''}`}
  26. onKeyDown={props.onRowKeyDown}
  27. onPointerDown={props.onRowClick}
  28. style={props.style}
  29. >
  30. <div
  31. className="TraceLeftColumn"
  32. ref={props.registerListColumnRef}
  33. onDoubleClick={props.onRowDoubleClick}
  34. >
  35. <div className="TraceLeftColumnInner" style={props.listColumnStyle}>
  36. <div className={props.listColumnClassName}>
  37. <TraceRowConnectors node={props.node} manager={props.manager} />
  38. {props.node.children.length > 0 || props.node.canFetch ? (
  39. <TraceChildrenButton
  40. icon={
  41. props.node.canFetch ? (
  42. props.node.fetchStatus === 'idle' ? (
  43. '+'
  44. ) : props.node.zoomedIn ? (
  45. <TraceIcons.Chevron direction="up" />
  46. ) : (
  47. '+'
  48. )
  49. ) : (
  50. <TraceIcons.Chevron direction={props.node.expanded ? 'up' : 'down'} />
  51. )
  52. }
  53. status={props.node.fetchStatus}
  54. expanded={props.node.expanded || props.node.zoomedIn}
  55. onDoubleClick={props.onExpandDoubleClick}
  56. onClick={e => {
  57. props.node.canFetch ? props.onZoomIn(e) : props.onExpand(e);
  58. }}
  59. >
  60. {props.node.children.length > 0
  61. ? TRACE_COUNT_FORMATTER.format(props.node.children.length)
  62. : null}
  63. </TraceChildrenButton>
  64. ) : null}
  65. </div>
  66. <PlatformIcon
  67. platform={props.projects[props.node.value.project_slug] ?? 'default'}
  68. />
  69. <span className="TraceOperation">{props.node.value['transaction.op']}</span>
  70. <strong className="TraceEmDash"> — </strong>
  71. <span className="TraceDescription">{props.node.value.transaction}</span>
  72. </div>
  73. </div>
  74. <div
  75. ref={props.registerSpanColumnRef}
  76. className={props.spanColumnClassName}
  77. onDoubleClick={props.onRowDoubleClick}
  78. >
  79. <TraceBar
  80. node={props.node}
  81. virtualized_index={props.virtualized_index}
  82. manager={props.manager}
  83. color={makeTraceNodeBarColor(props.theme, props.node)}
  84. node_space={props.node.space}
  85. errors={props.node.errors}
  86. performance_issues={props.node.performance_issues}
  87. profiles={props.node.profiles}
  88. />
  89. <button
  90. ref={props.registerSpanArrowRef}
  91. className="TraceArrow"
  92. onClick={props.onSpanArrowClick}
  93. >
  94. <TraceIcons.Chevron direction="left" />
  95. </button>
  96. </div>
  97. </div>
  98. );
  99. }