Skip to content

Commit e8395aa

Browse files
authored
feat(replays): New column size and improve of a11y (#37765)
<!-- Describe your PR here. --> ### Changes - Added new column `size` to the network table - Improved a11y and some styles Closes #37615 ![image](https://user-images.githubusercontent.com/39612839/184424404-c8b20eba-d9ba-4421-802c-91717613fad6.png)
1 parent 0853545 commit e8395aa

File tree

1 file changed

+52
-23
lines changed
  • static/app/views/replays/detail/network

1 file changed

+52
-23
lines changed

static/app/views/replays/detail/network/index.tsx

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Fragment, useCallback, useMemo, useState} from 'react';
22
import styled from '@emotion/styled';
33

4+
import FileSize from 'sentry/components/fileSize';
45
import {PanelTable, PanelTableHeader} from 'sentry/components/panels';
56
import Placeholder from 'sentry/components/placeholder';
67
import {useReplayContext} from 'sentry/components/replays/replayContext';
@@ -9,6 +10,7 @@ import Tooltip from 'sentry/components/tooltip';
910
import {IconArrow} from 'sentry/icons';
1011
import {t} from 'sentry/locale';
1112
import space from 'sentry/styles/space';
13+
import {defined} from 'sentry/utils';
1214
import {ColorOrAlias} from 'sentry/utils/theme';
1315
import {
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

185208
const 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

246270
const 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')`
254279
const 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

259288
export default NetworkList;

0 commit comments

Comments
 (0)