Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 6618b0c

Browse files
committed
Merge pull request #251 from kassens/table
Update style Relay queries view
2 parents 7e8d6e7 + 0fe0b88 commit 6618b0c

File tree

2 files changed

+86
-61
lines changed

2 files changed

+86
-61
lines changed

plugins/Relay/Query.js

Lines changed: 56 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,43 @@
1313
import type {Map} from 'immutable';
1414

1515
var React = require('react');
16-
var assign = require('object-assign');
1716

1817
class 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+
6079
var 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

101114
module.exports = Query;

plugins/Relay/QueryList.js

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,46 @@ class QueryList {
2424
};
2525

2626
render() {
27+
if (!this.props.queries.count()) {
28+
return <div style={styles.empty}>No Relay Queries logged</div>;
29+
}
30+
var rows = this.props.queries.valueSeq().map((q, i) => (
31+
<Query
32+
data={q}
33+
isSelected={q.get('id') === this.props.selectedQuery}
34+
key={q.get('id')}
35+
oddRow={(i % 2) === 1}
36+
onSelect={() => this.props.selectQuery(q.get('id'))}
37+
/>
38+
)).toArray();
39+
2740
return (
28-
<ul style={styles.list}>
29-
{this.props.queries.valueSeq().map(q => (
30-
<Query
31-
data={q}
32-
key={q.get('id')}
33-
isSelected={q.get('id') === this.props.selectedQuery}
34-
onSelect={() => this.props.selectQuery(q.get('id'))}
35-
/>
36-
)).toArray()}
37-
{!this.props.queries.count() &&
38-
<li style={styles.empty}>No Relay Queries logged</li>}
39-
</ul>
41+
<div style={styles.container}>
42+
<table style={styles.table}>
43+
<tbody>
44+
{rows}
45+
</tbody>
46+
</table>
47+
</div>
4048
);
4149
}
4250
}
4351

4452
var styles = {
45-
list: {
46-
listStyle: 'none',
47-
padding: 0,
48-
margin: 0,
49-
overflow: 'auto',
50-
minHeight: 0,
53+
container: {
54+
position: 'relative',
5155
flex: 1,
56+
overflow: 'scroll',
57+
},
58+
59+
table: {
60+
flex: 1,
61+
borderCollapse: 'collapse',
62+
width: '100%',
5263
},
5364

5465
empty: {
66+
flex: 1,
5567
padding: 50,
5668
textAlign: 'center',
5769
},

0 commit comments

Comments
 (0)