index.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import {Fragment, MouseEvent} from 'react';
  2. import styled from '@emotion/styled';
  3. import {Button} from 'sentry/components/button';
  4. import Stacked from 'sentry/components/replays/breadcrumbs/stacked';
  5. import {IconClose} from 'sentry/icons';
  6. import {t} from 'sentry/locale';
  7. import {space} from 'sentry/styles/space';
  8. import {useResizableDrawer} from 'sentry/utils/useResizableDrawer';
  9. import useUrlParams from 'sentry/utils/useUrlParams';
  10. import SplitDivider from 'sentry/views/replays/detail/layout/splitDivider';
  11. import NetworkDetailsContent from 'sentry/views/replays/detail/network/details/content';
  12. import NetworkDetailsTabs, {
  13. TabKey,
  14. } from 'sentry/views/replays/detail/network/details/tabs';
  15. import type {NetworkSpan} from 'sentry/views/replays/types';
  16. type Props = {
  17. isSetup: boolean;
  18. item: null | NetworkSpan;
  19. onClose: () => void;
  20. projectId: undefined | string;
  21. startTimestampMs: number;
  22. } & Omit<ReturnType<typeof useResizableDrawer>, 'size'>;
  23. function NetworkDetails({
  24. isHeld,
  25. isSetup,
  26. item,
  27. onClose,
  28. onDoubleClick,
  29. onMouseDown,
  30. projectId,
  31. startTimestampMs,
  32. }: Props) {
  33. const {getParamValue: getDetailTab} = useUrlParams('n_detail_tab', 'details');
  34. if (!item || !projectId) {
  35. return null;
  36. }
  37. const visibleTab = getDetailTab() as TabKey;
  38. return (
  39. <Fragment>
  40. <StyledStacked>
  41. <StyledNetworkDetailsTabs underlined={false} />
  42. <StyledSplitDivider
  43. isHeld={isHeld}
  44. onDoubleClick={onDoubleClick}
  45. onMouseDown={onMouseDown}
  46. slideDirection="updown"
  47. />
  48. <CloseButtonWrapper>
  49. <Button
  50. aria-label={t('Hide request details')}
  51. borderless
  52. icon={<IconClose isCircled size="sm" color="subText" />}
  53. onClick={(e: MouseEvent) => {
  54. e.preventDefault();
  55. onClose();
  56. }}
  57. size="zero"
  58. />
  59. </CloseButtonWrapper>
  60. </StyledStacked>
  61. <NetworkDetailsContent
  62. isSetup={isSetup}
  63. item={item}
  64. projectId={projectId}
  65. startTimestampMs={startTimestampMs}
  66. visibleTab={visibleTab}
  67. />
  68. </Fragment>
  69. );
  70. }
  71. const StyledStacked = styled(Stacked)`
  72. position: relative;
  73. border-top: 1px solid ${p => p.theme.border};
  74. border-bottom: 1px solid ${p => p.theme.border};
  75. `;
  76. const StyledNetworkDetailsTabs = styled(NetworkDetailsTabs)`
  77. /*
  78. Use padding instead of margin so all the <li> will cover the <SplitDivider>
  79. without taking 100% width.
  80. */
  81. & > li {
  82. margin-right: 0;
  83. padding-right: ${space(3)};
  84. background: ${p => p.theme.surface400};
  85. z-index: ${p => p.theme.zIndex.initial};
  86. }
  87. & > li:first-child {
  88. padding-left: ${space(2)};
  89. }
  90. & > li:last-child {
  91. padding-right: ${space(1)};
  92. }
  93. & > li > a {
  94. padding-top: ${space(1)};
  95. padding-bottom: ${space(0.5)};
  96. height: 100%;
  97. border-bottom: ${space(0.5)} solid transparent;
  98. }
  99. `;
  100. const CloseButtonWrapper = styled('div')`
  101. position: absolute;
  102. right: 0;
  103. height: 100%;
  104. padding: ${space(1)};
  105. z-index: ${p => p.theme.zIndex.initial};
  106. `;
  107. const StyledSplitDivider = styled(SplitDivider)<{isHeld: boolean}>`
  108. height: 100%;
  109. ${p => (p.isHeld ? `z-index: ${p.theme.zIndex.initial + 1};` : '')}
  110. :hover {
  111. z-index: ${p => p.theme.zIndex.initial + 1};
  112. }
  113. `;
  114. export default NetworkDetails;