breadcrumbRow.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import {CSSProperties, memo, MouseEvent, useCallback} from 'react';
  2. import BreadcrumbItem from 'sentry/components/replays/breadcrumbs/breadcrumbItem';
  3. import type {Crumb} from 'sentry/types/breadcrumbs';
  4. import useCrumbHandlers from 'sentry/utils/replays/hooks/useCrumbHandlers';
  5. interface Props {
  6. breadcrumb: Crumb;
  7. index: number;
  8. isCurrent: boolean;
  9. isHovered: boolean;
  10. onDimensionChange: (
  11. index: number,
  12. path: string,
  13. expandedState: Record<string, boolean>,
  14. event: MouseEvent<HTMLDivElement>
  15. ) => void;
  16. startTimestampMs: number;
  17. style: CSSProperties;
  18. breadcrumbIndex?: number[][];
  19. expandPaths?: string[];
  20. }
  21. function BreadcrumbRow({
  22. breadcrumb,
  23. expandPaths,
  24. index,
  25. isCurrent,
  26. onDimensionChange,
  27. isHovered,
  28. startTimestampMs,
  29. style,
  30. }: Props) {
  31. const {handleMouseEnter, handleMouseLeave, handleClick} =
  32. useCrumbHandlers(startTimestampMs);
  33. const onClickTimestamp = useCallback(
  34. () => handleClick(breadcrumb),
  35. [handleClick, breadcrumb]
  36. );
  37. const onMouseEnter = useCallback(
  38. () => handleMouseEnter(breadcrumb),
  39. [handleMouseEnter, breadcrumb]
  40. );
  41. const onMouseLeave = useCallback(
  42. () => handleMouseLeave(breadcrumb),
  43. [handleMouseLeave, breadcrumb]
  44. );
  45. return (
  46. <BreadcrumbItem
  47. index={index}
  48. crumb={breadcrumb}
  49. isCurrent={isCurrent}
  50. isHovered={isHovered}
  51. onClick={onClickTimestamp}
  52. onMouseEnter={onMouseEnter}
  53. onMouseLeave={onMouseLeave}
  54. startTimestampMs={startTimestampMs}
  55. style={style}
  56. expandPaths={expandPaths}
  57. onDimensionChange={onDimensionChange}
  58. />
  59. );
  60. }
  61. export default memo(BreadcrumbRow);