7
7
* @flow
8
8
*/
9
9
10
+ import type { CommitDataFrontend } from './types' ;
11
+
10
12
import * as React from 'react' ;
11
13
import { useEffect , useMemo , useRef , useState } from 'react' ;
12
14
import AutoSizer from 'react-virtualized-auto-sizer' ;
@@ -31,6 +33,7 @@ export type ItemData = {|
31
33
| } ;
32
34
33
35
type Props = { |
36
+ commitData : CommitDataFrontend ,
34
37
commitDurations : Array < number > ,
35
38
commitTimes : Array < number > ,
36
39
filteredCommitIndices : Array < number > ,
@@ -40,6 +43,7 @@ type Props = {|
40
43
| } ;
41
44
42
45
export default function SnapshotCommitList ( {
46
+ commitData,
43
47
commitDurations,
44
48
commitTimes,
45
49
filteredCommitIndices,
@@ -51,6 +55,7 @@ export default function SnapshotCommitList({
51
55
< AutoSizer >
52
56
{ ( { height, width} ) => (
53
57
< List
58
+ commitData = { commitData }
54
59
commitDurations = { commitDurations }
55
60
commitTimes = { commitTimes }
56
61
height = { height }
@@ -66,6 +71,7 @@ export default function SnapshotCommitList({
66
71
}
67
72
68
73
type ListProps = { |
74
+ commitData : CommitDataFrontend ,
69
75
commitDurations : Array < number > ,
70
76
commitTimes : Array < number > ,
71
77
height : number ,
@@ -83,6 +89,7 @@ type DragState = {
83
89
} ;
84
90
85
91
function List ( {
92
+ commitData,
86
93
commitDurations,
87
94
selectedCommitIndex,
88
95
commitTimes,
@@ -200,15 +207,68 @@ function List({
200
207
201
208
let tooltipLabel = null ;
202
209
if ( hoveredCommitIndex !== null ) {
203
- const commitDuration = commitDurations [ hoveredCommitIndex ] ;
204
- const commitTime = commitTimes [ hoveredCommitIndex ] ;
205
- tooltipLabel = `${ formatDuration ( commitDuration ) } ms at ${ formatTime (
206
- commitTime ,
207
- ) } s`;
210
+ const {
211
+ duration,
212
+ effectDuration,
213
+ passiveEffectDuration,
214
+ priorityLevel,
215
+ timestamp,
216
+ } = commitData [ hoveredCommitIndex ] ;
217
+
218
+ // Only some React versions include commit durations.
219
+ // Show a richer tooltip only for builds that have that info.
220
+ if ( effectDuration > 0 || passiveEffectDuration > 0 ) {
221
+ tooltipLabel = (
222
+ < ul className = { styles . TooltipList } >
223
+ { priorityLevel !== null && (
224
+ < li className = { styles . TooltipListItem } >
225
+ < label className = { styles . TooltipLabel } > Priority</ label >
226
+ < span className = { styles . TooltipValue } > { priorityLevel } </ span >
227
+ </ li >
228
+ ) }
229
+ < li className = { styles . TooltipListItem } >
230
+ < label className = { styles . TooltipLabel } > Committed at</ label >
231
+ < span className = { styles . TooltipValue } >
232
+ { formatTime ( timestamp ) } s
233
+ </ span >
234
+ </ li >
235
+ < li className = { styles . TooltipListItem } >
236
+ < label className = { styles . TooltipLabel } > Render duration</ label >
237
+ < span className = { styles . TooltipValue } >
238
+ { formatDuration ( duration ) } ms
239
+ </ span >
240
+ </ li >
241
+ { effectDuration !== null && (
242
+ < li className = { styles . TooltipListItem } >
243
+ < label className = { styles . TooltipLabel } >
244
+ Layout effects duration
245
+ </ label >
246
+ < span className = { styles . TooltipValue } >
247
+ { formatDuration ( effectDuration ) } ms
248
+ </ span >
249
+ </ li >
250
+ ) }
251
+ { passiveEffectDuration !== null && (
252
+ < li className = { styles . TooltipListItem } >
253
+ < label className = { styles . TooltipLabel } >
254
+ Passive effects duration
255
+ </ label >
256
+ < span className = { styles . TooltipValue } >
257
+ { formatDuration ( passiveEffectDuration ) } ms
258
+ </ span >
259
+ </ li >
260
+ ) }
261
+ </ ul >
262
+ ) ;
263
+ } else {
264
+ tooltipLabel = `${ formatDuration ( duration ) } ms at ${ formatTime (
265
+ timestamp ,
266
+ ) } s`;
267
+ }
208
268
}
209
269
210
270
return (
211
- < Tooltip label = { tooltipLabel } >
271
+ < Tooltip className = { styles . Tooltip } label = { tooltipLabel } >
212
272
< div
213
273
ref = { divRef }
214
274
style = { { height, width} }
0 commit comments