11import { Fragment , useCallback , useMemo , useState } from 'react' ;
22import styled from '@emotion/styled' ;
33
4+ import FileSize from 'sentry/components/fileSize' ;
45import { PanelTable , PanelTableHeader } from 'sentry/components/panels' ;
56import Placeholder from 'sentry/components/placeholder' ;
67import { useReplayContext } from 'sentry/components/replays/replayContext' ;
@@ -9,6 +10,7 @@ import Tooltip from 'sentry/components/tooltip';
910import { IconArrow } from 'sentry/icons' ;
1011import { t } from 'sentry/locale' ;
1112import space from 'sentry/styles/space' ;
13+ import { defined } from 'sentry/utils' ;
1214import { ColorOrAlias } from 'sentry/utils/theme' ;
1315import {
1416 ISortConfig ,
@@ -93,25 +95,37 @@ function NetworkList({replayRecord, networkSpans}: Props) {
9395 } ;
9496
9597 const columns = [
96- t ( 'Status' ) ,
97- < SortItem key = "path" onClick = { ( ) => handleSort ( 'description' ) } >
98- { t ( 'Path' ) } { sortArrow ( 'description' ) }
98+ < SortItem key = "status" > { t ( 'Status' ) } </ SortItem > ,
99+ < SortItem key = "path" >
100+ < UnstyledButton onClick = { ( ) => handleSort ( 'description' ) } >
101+ { t ( 'Path' ) } { sortArrow ( 'description' ) }
102+ </ UnstyledButton >
99103 </ SortItem > ,
100- < SortItem key = "type" onClick = { ( ) => handleSort ( 'op' ) } >
101- { t ( 'Type' ) } { sortArrow ( 'op' ) }
104+ < SortItem key = "type" >
105+ < UnstyledButton onClick = { ( ) => handleSort ( 'op' ) } >
106+ { t ( 'Type' ) } { sortArrow ( 'op' ) }
107+ </ UnstyledButton >
102108 </ SortItem > ,
103- < SortItem
104- key = "duration"
105- onClick = { ( ) =>
106- handleSort ( 'duration' , row => {
107- return row . endTimestamp - row . startTimestamp ;
108- } )
109- }
110- >
111- { t ( 'Duration' ) } { sortArrow ( 'duration' ) }
109+ < SortItem key = "size" >
110+ < UnstyledButton onClick = { ( ) => handleSort ( 'size' , row => row . data . size ) } >
111+ { t ( 'Size' ) } { sortArrow ( 'size' ) }
112+ </ UnstyledButton >
113+ </ SortItem > ,
114+ < SortItem key = "duration" >
115+ < UnstyledButton
116+ onClick = { ( ) =>
117+ handleSort ( 'duration' , row => {
118+ return row . endTimestamp - row . startTimestamp ;
119+ } )
120+ }
121+ >
122+ { t ( 'Duration' ) } { sortArrow ( 'duration' ) }
123+ </ UnstyledButton >
112124 </ SortItem > ,
113- < SortItem key = "timestamp" onClick = { ( ) => handleSort ( 'startTimestamp' ) } >
114- { t ( 'Timestamp' ) } { sortArrow ( 'startTimestamp' ) }
125+ < SortItem key = "timestamp" >
126+ < UnstyledButton onClick = { ( ) => handleSort ( 'startTimestamp' ) } >
127+ { t ( 'Timestamp' ) } { sortArrow ( 'startTimestamp' ) }
128+ </ UnstyledButton >
115129 </ SortItem > ,
116130 ] ;
117131
@@ -134,6 +148,7 @@ function NetworkList({replayRecord, networkSpans}: Props) {
134148 overlayStyle = { {
135149 maxWidth : '500px !important' ,
136150 } }
151+ showOnlyOnOverflow
137152 >
138153 < Text > { network . description } </ Text >
139154 </ Tooltip >
@@ -144,6 +159,14 @@ function NetworkList({replayRecord, networkSpans}: Props) {
144159 < Item { ...columnHandlers } >
145160 < Text > { network . op . replace ( 'resource.' , '' ) } </ Text >
146161 </ Item >
162+ < Item { ...columnHandlers } numeric >
163+ { defined ( network . data . size ) ? (
164+ < FileSize bytes = { network . data . size } />
165+ ) : (
166+ < EmptyText > ({ t ( 'Missing size' ) } )</ EmptyText >
167+ ) }
168+ </ Item >
169+
147170 < Item { ...columnHandlers } numeric >
148171 { `${ ( networkEndTimestamp - networkStartTimestamp ) . toFixed ( 2 ) } ms` }
149172 </ Item >
@@ -183,7 +206,7 @@ const Item = styled('div')<{center?: boolean; color?: ColorOrAlias; numeric?: bo
183206` ;
184207
185208const StyledPanelTable = styled ( PanelTable ) < { columns : number } > `
186- grid-template-columns: max-content minmax(200px, 1fr) repeat(3 , max-content);
209+ grid-template-columns: max-content minmax(200px, 1fr) repeat(4 , max-content);
187210 grid-template-rows: 24px repeat(auto-fit, 28px);
188211 font-size: ${ p => p . theme . fontSizeSmall } ;
189212 margin-bottom: 0;
@@ -201,23 +224,24 @@ const StyledPanelTable = styled(PanelTable)<{columns: number}>`
201224 justify-content: end;
202225 }
203226
204- /* 2nd last column */
205- &:nth-child(${ p => p . columns } n - 1) {
227+ /* 3rd and 2nd last column */
228+ &:nth-child(${ p => p . columns } n - 1),
229+ &:nth-child(${ p => p . columns } n - 2) {
206230 text-align: right;
207231 justify-content: end;
208232 }
209233 }
210234
211235 ${ /* sc-selector */ PanelTableHeader } {
212236 min-height: 24px;
213- padding: ${ space ( 0.5 ) } ${ space ( 1.5 ) } ;
214237 border-radius: 0;
215238 color: ${ p => p . theme . subText } ;
216239 line-height: 16px;
217240
218- /* Last and 2nd last header columns. As these are flex direction columns we have to treat them separately */
241+ /* Last, 2nd and 3rd last header columns. As these are flex direction columns we have to treat them separately */
219242 &:nth-child(${ p => p . columns } n),
220- &:nth-child(${ p => p . columns } n - 1) {
243+ &:nth-child(${ p => p . columns } n - 1),
244+ &:nth-child(${ p => p . columns } n - 2) {
221245 justify-content: center;
222246 align-items: end;
223247 }
@@ -244,7 +268,8 @@ const EmptyText = styled(Text)`
244268` ;
245269
246270const SortItem = styled ( 'span' ) `
247- cursor: pointer;
271+ padding: ${ space ( 0.5 ) } ${ space ( 1.5 ) } ;
272+ width: 100%;
248273
249274 svg {
250275 vertical-align: text-top;
@@ -254,6 +279,10 @@ const SortItem = styled('span')`
254279const UnstyledButton = styled ( 'button' ) `
255280 border: 0;
256281 background: none;
282+ padding: 0;
283+ text-transform: inherit;
284+ width: 100%;
285+ text-align: unset;
257286` ;
258287
259288export default NetworkList ;
0 commit comments