networkHeaderCell.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import type {ComponentProps, CSSProperties} from 'react';
  2. import {forwardRef} from 'react';
  3. import ExternalLink from 'sentry/components/links/externalLink';
  4. import HeaderCell from 'sentry/components/replays/virtualizedGrid/headerCell';
  5. import type {Tooltip} from 'sentry/components/tooltip';
  6. import {t, tct} from 'sentry/locale';
  7. import type useSortNetwork from 'sentry/views/replays/detail/network/useSortNetwork';
  8. type SortConfig = ReturnType<typeof useSortNetwork>['sortConfig'];
  9. type Props = {
  10. handleSort: ReturnType<typeof useSortNetwork>['handleSort'];
  11. index: number;
  12. sortConfig: SortConfig;
  13. style: CSSProperties;
  14. };
  15. const COLUMNS: {
  16. field: SortConfig['by'];
  17. label: string;
  18. tooltipTitle?: ComponentProps<typeof Tooltip>['title'];
  19. }[] = [
  20. {field: 'method', label: t('Method')},
  21. {
  22. field: 'status',
  23. label: t('Status'),
  24. tooltipTitle: tct(
  25. 'If the status is [zero], the resource might be a cross-origin request.[linebreak][linebreak]Configure the server to respond with the CORS header [header] to see the actual response codes. [mozilla].',
  26. {
  27. zero: <code>0</code>,
  28. header: <code>Access-Control-Allow-Origin</code>,
  29. linebreak: <br />,
  30. mozilla: (
  31. <ExternalLink href="https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/responseStatus#cross-origin_response_status_codes">
  32. Learn more on MDN
  33. </ExternalLink>
  34. ),
  35. }
  36. ),
  37. },
  38. {field: 'description', label: t('Path')},
  39. {
  40. field: 'op',
  41. label: t('Type'),
  42. },
  43. {
  44. field: 'size',
  45. label: t('Size'),
  46. tooltipTitle: t(
  47. 'The number used for fetch/xhr is the response body size. It is possible the network transfer size is smaller due to compression.'
  48. ),
  49. },
  50. {field: 'duration', label: t('Duration')},
  51. {field: 'startTimestamp', label: t('Timestamp')},
  52. ];
  53. export const COLUMN_COUNT = COLUMNS.length;
  54. const NetworkHeaderCell = forwardRef<HTMLButtonElement, Props>(
  55. ({handleSort, index, sortConfig, style}: Props, ref) => {
  56. const {field, label, tooltipTitle} = COLUMNS[index];
  57. return (
  58. <HeaderCell
  59. ref={ref}
  60. handleSort={handleSort}
  61. field={field}
  62. label={label}
  63. tooltipTitle={tooltipTitle}
  64. sortConfig={sortConfig}
  65. style={style}
  66. />
  67. );
  68. }
  69. );
  70. export default NetworkHeaderCell;