Skip to content

Commit 3c57e66

Browse files
authored
feat(replay): Unify the tooltips into one for replay details os/browser (#95558)
One tooltip is enough, and some error handling in case `replay` is messed up somehow. <img width="260" height="112" alt="SCR-20250715-ijrc" src="https://github.com/user-attachments/assets/a5a3ef16-d593-4094-991b-cd50e687b219" />
1 parent 36ecbdc commit 3c57e66

File tree

1 file changed

+53
-26
lines changed

1 file changed

+53
-26
lines changed

static/app/views/replays/detail/browserOSIcons.tsx

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
import {Fragment} from 'react';
12
import styled from '@emotion/styled';
3+
import {PlatformIcon} from 'platformicons';
24

35
import {Flex} from 'sentry/components/core/layout';
46
import {Tooltip} from 'sentry/components/core/tooltip';
57
import Placeholder from 'sentry/components/placeholder';
8+
import CountTooltipContent from 'sentry/components/replays/countTooltipContent';
69
import {useReplayContext} from 'sentry/components/replays/replayContext';
7-
import ReplayPlatformIcon from 'sentry/components/replays/replayPlatformIcon';
10+
import {t} from 'sentry/locale';
811
import {space} from 'sentry/styles/space';
12+
import {generatePlatformIconName} from 'sentry/utils/replays/generatePlatformIconName';
913

1014
export default function BrowserOSIcons({
1115
showBrowser = true,
@@ -17,33 +21,56 @@ export default function BrowserOSIcons({
1721
const {replay} = useReplayContext();
1822
const replayRecord = replay?.getReplay();
1923

20-
return isLoading ? (
21-
<Placeholder width="50px" height="32px" />
22-
) : (
23-
<Flex direction="row-reverse">
24-
<Tooltip title={`${replayRecord?.os.name ?? ''} ${replayRecord?.os.version ?? ''}`}>
25-
<ReplayPlatformIcon
26-
name={replayRecord?.os.name ?? ''}
27-
version={replayRecord?.os.version ?? undefined}
28-
showVersion
29-
/>
24+
if (isLoading) {
25+
return <Placeholder width="34px" height="20px" />;
26+
}
27+
28+
if (!replayRecord) {
29+
return (
30+
<Tooltip title={t('Unknown Device')}>
31+
<PlatformIcon platform="unknown" size="20px" />
3032
</Tooltip>
31-
{showBrowser && (
32-
<Overlap>
33-
<Tooltip
34-
title={`${replayRecord?.browser.name ?? ''} ${
35-
replayRecord?.browser.version ?? ''
36-
}`}
37-
>
38-
<ReplayPlatformIcon
39-
name={replayRecord?.browser.name ?? ''}
40-
version={replayRecord?.browser.version ?? undefined}
41-
showVersion
33+
);
34+
}
35+
36+
return (
37+
<Tooltip
38+
title={
39+
<CountTooltipContent>
40+
{showBrowser && (
41+
<Fragment>
42+
<dt>{t('Browser:')}</dt>
43+
<dd>{`${replayRecord?.browser.name ?? ''} ${replayRecord?.browser.version ?? ''}`}</dd>
44+
</Fragment>
45+
)}
46+
<dt>{t('OS:')}</dt>
47+
<dd>
48+
{replayRecord?.os.name ?? ''} {replayRecord?.os.version ?? ''}
49+
</dd>
50+
</CountTooltipContent>
51+
}
52+
>
53+
<Flex>
54+
{showBrowser && (
55+
<Overlap>
56+
<PlatformIcon
57+
platform={generatePlatformIconName(
58+
replayRecord?.browser.name ?? '',
59+
replayRecord?.browser.version ?? undefined
60+
)}
61+
size="20px"
4262
/>
43-
</Tooltip>
44-
</Overlap>
45-
)}
46-
</Flex>
63+
</Overlap>
64+
)}
65+
<PlatformIcon
66+
platform={generatePlatformIconName(
67+
replayRecord?.os.name ?? '',
68+
replayRecord?.os.version ?? undefined
69+
)}
70+
size="20px"
71+
/>
72+
</Flex>
73+
</Tooltip>
4774
);
4875
}
4976

0 commit comments

Comments
 (0)