traceLoadingRow.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import type {Theme} from '@emotion/react';
  2. import Placeholder from 'sentry/components/placeholder';
  3. import {isTraceNode} from '../traceGuards';
  4. import {TraceTree} from '../traceModels/traceTree';
  5. import type {TraceTreeNode} from '../traceModels/traceTreeNode';
  6. import type {VirtualizedViewManager} from '../traceRenderers/virtualizedViewManager';
  7. import {
  8. TRACE_COUNT_FORMATTER,
  9. TRACE_RIGHT_COLUMN_EVEN_CLASSNAME,
  10. TRACE_RIGHT_COLUMN_ODD_CLASSNAME,
  11. TraceChildrenButton,
  12. TraceRowConnectors,
  13. } from '../traceRow/traceRow';
  14. function randomBetween(min: number, max: number) {
  15. return Math.floor(Math.random() * (max - min + 1) + min);
  16. }
  17. export function TraceLoadingRow(props: {
  18. index: number;
  19. manager: VirtualizedViewManager;
  20. node: TraceTreeNode<TraceTree.NodeValue>;
  21. style: React.CSSProperties;
  22. theme: Theme;
  23. }) {
  24. return (
  25. <div
  26. key={props.index}
  27. className="TraceRow"
  28. style={{
  29. transform: props.style.transform,
  30. height: props.style.height,
  31. pointerEvents: 'none',
  32. color: props.theme.subText,
  33. paddingLeft: 8,
  34. }}
  35. >
  36. <div
  37. className="TraceLeftColumn"
  38. style={{width: props.manager.columns.list.width * 100 + '%'}}
  39. >
  40. <div
  41. className="TraceLeftColumnInner"
  42. style={{
  43. paddingLeft: TraceTree.Depth(props.node) * props.manager.row_depth_padding,
  44. }}
  45. >
  46. <div
  47. className={`TraceChildrenCountWrapper ${isTraceNode(props.node) ? 'Root' : ''}`}
  48. >
  49. <TraceRowConnectors node={props.node} manager={props.manager} />
  50. {props.node.children.length > 0 || props.node.canFetch ? (
  51. <TraceChildrenButton
  52. icon="+"
  53. status={props.node.fetchStatus}
  54. expanded={props.node.expanded || props.node.zoomedIn}
  55. onClick={() => void 0}
  56. onDoubleClick={() => void 0}
  57. >
  58. {props.node.children.length > 0
  59. ? TRACE_COUNT_FORMATTER.format(props.node.children.length)
  60. : null}
  61. </TraceChildrenButton>
  62. ) : null}
  63. </div>
  64. <Placeholder
  65. className="Placeholder"
  66. height="12px"
  67. width={randomBetween(20, 80) + '%'}
  68. style={{
  69. transition: 'all 30s ease-out',
  70. }}
  71. />
  72. </div>
  73. </div>
  74. <div
  75. className={
  76. props.index % 2 === 1
  77. ? TRACE_RIGHT_COLUMN_ODD_CLASSNAME
  78. : TRACE_RIGHT_COLUMN_EVEN_CLASSNAME
  79. }
  80. style={{
  81. width: props.manager.columns.span_list.width * 100 + '%',
  82. }}
  83. >
  84. <Placeholder
  85. className="Placeholder"
  86. height="12px"
  87. width={randomBetween(20, 80) + '%'}
  88. style={{
  89. transition: 'all 30s ease-out',
  90. transform: `translate(${randomBetween(0, 200) + 'px'}, 0)`,
  91. }}
  92. />
  93. </div>
  94. </div>
  95. );
  96. }