@@ -10,6 +10,7 @@ import {
1010 IconButton ,
1111 Menu ,
1212 MenuItem ,
13+ Box ,
1314} from "@material-ui/core" ;
1415import { MoreVert } from "@material-ui/icons" ;
1516import { useHistory } from "react-router-dom" ;
@@ -22,11 +23,13 @@ import {
2223 deleteTestRun ,
2324 selectTestRun ,
2425} from "../contexts" ;
26+ import { Skeleton } from "@material-ui/lab" ;
27+ import { SkeletonList } from "./SkeletonList" ;
2528
2629const TestRunList : React . FunctionComponent < {
2730 items : TestRun [ ] ;
2831} > = ( { items } ) => {
29- const { selectedTestRunId } = useTestRunState ( ) ;
32+ const { selectedTestRunId, loading } = useTestRunState ( ) ;
3033 const testRunDispatch = useTestRunDispatch ( ) ;
3134 const history = useHistory ( ) ;
3235 const [ anchorEl , setAnchorEl ] = React . useState < null | HTMLElement > ( null ) ;
@@ -49,59 +52,72 @@ const TestRunList: React.FunctionComponent<{
4952
5053 return (
5154 < React . Fragment >
52- < TableContainer >
53- < Table >
54- < TableHead >
55- < TableRow >
56- < TableCell > Name</ TableCell >
57- < TableCell > OS</ TableCell >
58- < TableCell > Device</ TableCell >
59- < TableCell > Browser</ TableCell >
60- < TableCell > Viewport</ TableCell >
61- < TableCell > Status</ TableCell >
62- < TableCell > </ TableCell >
63- </ TableRow >
64- </ TableHead >
65- < TableBody >
66- { items . map ( ( test ) => (
67- < TableRow
68- key = { test . id }
69- hover
70- selected = { test . id === selectedTestRunId }
71- >
72- < TableCell
73- onClick = { ( ) => {
74- history . push ( buildTestRunLocation ( test ) ) ;
75- selectTestRun ( testRunDispatch , test . id )
76- } }
77- >
78- < Typography > { test . name } </ Typography >
79- </ TableCell >
80- < TableCell >
81- < Typography > { test . os } </ Typography >
82- </ TableCell >
83- < TableCell >
84- < Typography > { test . device } </ Typography >
85- </ TableCell >
86- < TableCell >
87- < Typography > { test . browser } </ Typography >
88- </ TableCell >
89- < TableCell >
90- < Typography > { test . viewport } </ Typography >
91- </ TableCell >
92- < TableCell >
93- < TestStatusChip status = { test . status } />
94- </ TableCell >
95- < TableCell >
96- < IconButton onClick = { ( event ) => handleClick ( event , test ) } >
97- < MoreVert />
98- </ IconButton >
99- </ TableCell >
55+ { loading ? (
56+ < SkeletonList />
57+ ) : (
58+ < TableContainer >
59+ < Table >
60+ < TableHead >
61+ < TableRow >
62+ < TableCell > Name</ TableCell >
63+ < TableCell > OS</ TableCell >
64+ < TableCell > Device</ TableCell >
65+ < TableCell > Browser</ TableCell >
66+ < TableCell > Viewport</ TableCell >
67+ < TableCell > Status</ TableCell >
68+ < TableCell > </ TableCell >
10069 </ TableRow >
101- ) ) }
102- </ TableBody >
103- </ Table >
104- </ TableContainer >
70+ </ TableHead >
71+ { loading ? (
72+ [ ...Array ( 10 ) ] . map ( ( i ) => (
73+ < Box p = { 0.5 } >
74+ < Skeleton variant = "rect" height = { 100 } />
75+ </ Box >
76+ ) )
77+ ) : (
78+ < TableBody >
79+ { items . map ( ( test ) => (
80+ < TableRow
81+ key = { test . id }
82+ hover
83+ selected = { test . id === selectedTestRunId }
84+ >
85+ < TableCell
86+ onClick = { ( ) => {
87+ history . push ( buildTestRunLocation ( test ) ) ;
88+ selectTestRun ( testRunDispatch , test . id ) ;
89+ } }
90+ >
91+ < Typography > { test . name } </ Typography >
92+ </ TableCell >
93+ < TableCell >
94+ < Typography > { test . os } </ Typography >
95+ </ TableCell >
96+ < TableCell >
97+ < Typography > { test . device } </ Typography >
98+ </ TableCell >
99+ < TableCell >
100+ < Typography > { test . browser } </ Typography >
101+ </ TableCell >
102+ < TableCell >
103+ < Typography > { test . viewport } </ Typography >
104+ </ TableCell >
105+ < TableCell >
106+ < TestStatusChip status = { test . status } />
107+ </ TableCell >
108+ < TableCell >
109+ < IconButton onClick = { ( event ) => handleClick ( event , test ) } >
110+ < MoreVert />
111+ </ IconButton >
112+ </ TableCell >
113+ </ TableRow >
114+ ) ) }
115+ </ TableBody >
116+ ) }
117+ </ Table >
118+ </ TableContainer >
119+ ) }
120+
105121 { selectedTestRun && (
106122 < Menu
107123 anchorEl = { anchorEl }
0 commit comments