1313import type { Map } from 'immutable' ;
1414
1515var React = require ( 'react' ) ;
16- var assign = require ( 'object-assign' ) ;
1716
1817class Query extends React . Component {
1918 props : {
2019 data : Map ,
20+ oddRow : boolean ,
2121 onSelect : ( ) => void ,
2222 } ;
2323 render ( ) : ReactElement {
2424 var data = this . props . data ;
2525 var containerStyle = styles . container ;
2626 if ( this . props . isSelected ) {
27- containerStyle = {
28- ...styles . container ,
29- ...styles . selectedContainer ,
30- } ;
27+ containerStyle = styles . containerSelected ;
28+ } else if ( this . props . oddRow ) {
29+ containerStyle = styles . containeroOddRow ;
3130 }
32- var statusStyle = assign ( { } , styles . status , {
33- backgroundColor : statusColors [ data . get ( 'status' ) ] || statusColors . error ,
34- } ) ;
31+
32+ var status = data . get ( 'status' ) ;
33+ var statusStyle = {
34+ ...styles . status ,
35+ backgroundColor : statusColors [ status ] || statusColors . error ,
36+ } ;
3537
3638 return (
37- < li onClick = { this . props . onSelect } style = { containerStyle } >
38- < div style = { statusStyle } />
39- < div style = { styles . name } >
39+ < tr onClick = { this . props . onSelect } style = { containerStyle } >
40+ < td style = { styles . tdFirst } >
41+ < span style = { statusStyle } title = { status } />
42+ </ td >
43+ < td style = { styles . tdName } >
4044 { data . get ( 'name' ) }
41- </ div >
42- < div style = { styles . time } >
45+ </ td >
46+ < td style = { styles . td } >
4347 { new Date ( data . get ( 'start' ) ) . toLocaleTimeString ( ) }
44- </ div >
45- < div style = { styles . duration } >
48+ </ td >
49+ < td style = { styles . td } >
4650 { data . get ( 'end' ) - data . get ( 'start' ) } ms
47- </ div >
48- </ li >
51+ </ td >
52+ </ tr >
4953 ) ;
5054 }
5155}
@@ -57,45 +61,54 @@ var statusColors = {
5761 error : '#aaa' ,
5862} ;
5963
64+ var baseContainer = {
65+ cursor : 'pointer' ,
66+ fontSize : 11 ,
67+ height : 21 ,
68+ lineHeight : '21px' ,
69+ fontFamily : "'Lucida Grande', sans-serif" ,
70+ } ;
71+
72+ var baseTD = {
73+ whiteSpace : 'nowrap' ,
74+ 'padding' : '1px 4px' ,
75+ 'lineHeight' : '17px' ,
76+ 'borderLeft' : '1px solid #e1e1e1' ,
77+ } ;
78+
6079var styles = {
61- container : {
62- padding : '10px 20px' ,
63- cursor : 'pointer' ,
64- display : 'flex' ,
65- fontSize : 14 ,
66- } ,
80+ container : baseContainer ,
6781
68- selectedContainer : {
69- backgroundColor : '#eef' ,
82+ containerSelected : {
83+ ...baseContainer ,
84+ backgroundColor : '#3879d9' ,
85+ color : 'white' ,
7086 } ,
7187
72- name : {
73- flex : 1 ,
74- fontSize : 16 ,
75- padding : 10 ,
88+ containeroOddRow : {
89+ ...baseContainer ,
90+ backgroundColor : '#f5f5f5' ,
7691 } ,
7792
78- time : {
79- padding : 10 ,
93+ td : baseTD ,
94+
95+ tdFirst : {
96+ ...baseTD ,
97+ borderLeft : '' ,
8098 } ,
8199
82- duration : {
83- padding : 10 ,
100+ tdName : {
101+ ...baseTD ,
102+ width : '100%' ,
84103 } ,
85104
86105 status : {
87- width : 20 ,
88- height : 20 ,
89- margin : 10 ,
90- borderRadius : 25 ,
106+ display : 'inline-block' ,
107+ width : 11 ,
108+ height : 11 ,
109+ borderRadius : 6 ,
91110 backgroundColor : '#aaa' ,
92111 } ,
93-
94- text : {
95- whiteSpace : 'pre' ,
96- fontFamily : 'monospace' ,
97- flex : 1 ,
98- } ,
99112} ;
100113
101114module . exports = Query ;
0 commit comments