Skip to content
This repository was archived by the owner on Aug 13, 2018. It is now read-only.

Commit 7560d7d

Browse files
committed
Merge branch 'esphen-issue5'
2 parents 1b704ca + a982a50 commit 7560d7d

File tree

2 files changed

+85
-33
lines changed

2 files changed

+85
-33
lines changed

data/components/frame-table.js

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,40 @@ var FrameRow = React.createFactory(React.createClass({
120120

121121
displayName: "FrameRow",
122122

123+
getInitialState() {
124+
return {};
125+
},
126+
127+
/**
128+
* Create TreeView sub-components in lifecycle methods so we
129+
* only generate them once and don't run into state issues
130+
* with the TreeView component.
131+
*/
132+
componentWillMount() {
133+
if (this.props.frame) {
134+
this.setState({ payload: this.buildPayload(this.props.frame) });
135+
}
136+
},
137+
138+
/**
139+
* Create TreeView sub-components in lifecycle methods so we
140+
* only generate them once and don't run into state issues
141+
* with the TreeView component.
142+
*/
143+
componentWillReceiveProps({ frame }) {
144+
if (frame !== this.props.frame) {
145+
this.setState({ payload: this.buildPayload(this.props.frame) });
146+
}
147+
},
148+
123149
/**
124150
* Frames need to be re-rendered only if the selection changes.
125151
* This is an optimization that makes the list rendering a lot faster.
126152
*/
127153
shouldComponentUpdate: function(nextProps, nextState) {
128-
return this.props.frame == nextProps.selection ||
129-
this.props.frame == this.props.selection;
154+
return nextProps.selection !== this.props.selection && (
155+
this.props.frame == nextProps.selection ||
156+
this.props.frame == this.props.selection);
130157
},
131158

132159
onClick: function() {
@@ -135,8 +162,35 @@ var FrameRow = React.createFactory(React.createClass({
135162
}
136163
},
137164

165+
buildPayload(frame) {
166+
var payload;
167+
168+
// Test support for inline previews.
169+
if (frame.socketIo) {
170+
payload = TreeView({
171+
key: "preview-socketio",
172+
data: {"Socket IO": frame.socketIo},
173+
});
174+
} else if (frame.sockJs) {
175+
payload = TreeView({
176+
key: "preview-sockjs",
177+
data: {"SockJS": frame.sockJs},
178+
});
179+
} else if (frame.json) {
180+
payload = TreeView({
181+
key: "preview-json",
182+
data: {"JSON": frame.json},
183+
});
184+
} else {
185+
// Fall back to showing a string
186+
payload = Str.cropString(frame.data.payload, 50);
187+
}
188+
return payload;
189+
},
190+
138191
render: function() {
139192
var frame = this.props.frame;
193+
var payload = this.state.payload;
140194
var data = frame.data;
141195

142196
var className = "frameRow " + (frame.sent ? "send" : "receive");
@@ -146,19 +200,11 @@ var FrameRow = React.createFactory(React.createClass({
146200
className += " selected";
147201
}
148202

149-
var payload = Str.cropString(data.payload, 50);
150-
var size = Str.formatSize(data.payload.length);
203+
var size = Str.formatSize(data.payload.length);
151204
var time = new Date(data.timeStamp / 1000);
152205
var timeText = time.getHours() + ":" + time.getMinutes() +
153206
":" + time.getSeconds() + "." + time.getMilliseconds();
154207

155-
// Test support for inline previews. The problem is the
156-
// state of the TreeView component.
157-
/*if (frame.socketIo) {
158-
var data = { payload: frame.socketIo };
159-
payload = TreeView({key: "detailsTabTree", data: data})
160-
}*/
161-
162208
return (
163209
tr({className: className, onClick: this.onClick},
164210
td({className: "direction"},

data/css/frame-table.css

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,27 @@
6060
padding: 1px;
6161
}
6262

63+
/******************************************************************************/
64+
/* Inline Packet Details Preview */
65+
66+
.frameRow .preview {
67+
overflow: auto;
68+
width: 100%;
69+
max-height: 200px;
70+
}
71+
72+
.frameRow .memberRow:hover {
73+
background-color: transparent;
74+
}
75+
76+
.frameRow .domTable {
77+
width: auto;
78+
}
79+
80+
.frameRow .domTable > tbody > tr > td {
81+
border-bottom: transparent;
82+
}
83+
6384
/******************************************************************************/
6485
/* Events */
6586

@@ -148,21 +169,6 @@
148169
padding-right: 3px;
149170
}
150171

151-
/******************************************************************************/
152-
/* Frame Row Selection */
153-
154-
.frameRow:not(.selected):hover td {
155-
background: #EFEFEF;
156-
}
157-
158-
.eventRow.selected .text,
159-
.eventRow.selected .uri,
160-
.frameRow.selected td.opcode,
161-
.frameRow.selected td {
162-
background: #3399ff;
163-
color: white;
164-
}
165-
166172
/******************************************************************************/
167173
/* Summary */
168174

@@ -206,15 +212,15 @@
206212
border-bottom: none;
207213
}
208214

209-
.theme-light .frameRow:hover td,
210-
.theme-dark .frameRow:hover td {
211-
background-color: var(--theme-selection-background-semitransparent);
215+
.theme-light .frameRow:hover>td,
216+
.theme-dark .frameRow:hover>td {
217+
background-color: var(--theme-toolbar-background);
212218
}
213219

214-
.theme-light .frameRow.selected td,
215-
.theme-dark .frameRow.selected td {
216-
color: var(--theme-selection-color);
217-
background-color: var(--theme-selection-background);
220+
.theme-light .frameRow.selected>td,
221+
.theme-dark .frameRow.selected>td {
222+
/* JSON text (blue) must be visible, so we can't use --theme-selection-background */
223+
background-color: var(--theme-selection-background-semitransparent);
218224
}
219225

220226
.theme-light .frameTHead th,

0 commit comments

Comments
 (0)