networkHeaderCell.tsx 2.3 KB

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