networkList.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import {PanelTable} from 'sentry/components/panels';
  4. import Placeholder from 'sentry/components/placeholder';
  5. import {showPlayerTime} from 'sentry/components/replays/utils';
  6. import {t} from 'sentry/locale';
  7. import {EventTransaction} from 'sentry/types';
  8. type NetworkSpan = {
  9. data: Record<string, any>;
  10. endTimestamp: number;
  11. op: string;
  12. startTimestamp: number;
  13. description?: string | undefined;
  14. };
  15. type Props = {
  16. event: EventTransaction;
  17. networkSpans: NetworkSpan[];
  18. };
  19. const columns = [
  20. t('url'),
  21. t('type'),
  22. t('size'),
  23. t('start time'),
  24. t('duration'),
  25. t('response code'),
  26. ];
  27. function NetworkList({event, networkSpans}: Props) {
  28. const {startTimestamp} = event;
  29. const renderTableRow = (network: NetworkSpan, index: number) => {
  30. const networkStartTimestamp = network.startTimestamp * 1000;
  31. const networkEndTimestamp = network.endTimestamp * 1000;
  32. return (
  33. <Fragment key={index}>
  34. <Item>{network.description || <Placeholder height="24px" />}</Item>
  35. <Item>{network.op}</Item>
  36. <Item>{network.data?.size ?? 0}</Item>
  37. <Item>{showPlayerTime(networkStartTimestamp, startTimestamp)}</Item>
  38. <Item>{`${(networkEndTimestamp - networkStartTimestamp).toFixed(2)}ms`}</Item>
  39. <Item>{<Placeholder height="24px" />}</Item>
  40. </Fragment>
  41. );
  42. };
  43. return (
  44. <StyledPanelTable
  45. isEmpty={networkSpans.length === 0}
  46. emptyMessage={t('No related network requests found.')}
  47. headers={columns}
  48. >
  49. {networkSpans.map(renderTableRow) || null}
  50. </StyledPanelTable>
  51. );
  52. }
  53. const Item = styled('div')`
  54. display: flex;
  55. align-items: center;
  56. `;
  57. const StyledPanelTable = styled(PanelTable)`
  58. overflow: scroll;
  59. word-break: break-word;
  60. grid-template-columns: minmax(200px, 1fr) repeat(5, max-content);
  61. &::-webkit-scrollbar {
  62. display: none;
  63. }
  64. -ms-overflow-style: none;
  65. scrollbar-width: none;
  66. `;
  67. export default NetworkList;