@@ -78,7 +78,7 @@ var FrameList = React.createClass({
7878 // Render all frames.
7979 for ( var i in frames ) {
8080 var frame = frames [ i ] ;
81- output . push ( FrameBubble ( {
81+ output . push ( this . getFrameTag ( frame ) ( {
8282 key : "frame-" + frame . id ,
8383 frame : frame ,
8484 selection : this . props . selection ,
@@ -99,6 +99,15 @@ var FrameList = React.createClass({
9999 div ( { } , output )
100100 )
101101 ) ;
102+ } ,
103+
104+ getFrameTag : function ( frame ) {
105+ switch ( frame . type ) {
106+ case "event" :
107+ return EventBubble ;
108+ case "frame" :
109+ return FrameBubble ;
110+ }
102111 }
103112} ) ;
104113
@@ -219,6 +228,77 @@ var FrameBubble = React.createFactory(React.createClass({
219228 } ,
220229} ) ) ;
221230
231+ /**
232+ * Template for WS events (connect and disconnect) displayed in the
233+ * frame list (list view)
234+ */
235+ var EventBubble = React . createFactory ( React . createClass ( {
236+ /** @lends FrameBubble */
237+
238+ displayName : "FrameBubble" ,
239+
240+ /**
241+ * Frames need to be re-rendered only if the selection changes.
242+ * This is an optimization that makes the list rendering a lot faster.
243+ */
244+ shouldComponentUpdate : function ( nextProps , nextState ) {
245+ return this . props . frame == nextProps . selection ||
246+ this . props . frame == this . props . selection ;
247+ } ,
248+
249+ // Event Handlers
250+
251+ onClick : function ( event ) {
252+ var target = event . target ;
253+
254+ event . stopPropagation ( ) ;
255+ event . preventDefault ( ) ;
256+
257+ // If a 'memberLabel' is clicked inside the inline preview
258+ // tree, let's process it by the tree, so expansion and
259+ // collapsing works. Otherwise just select the frame.
260+ if ( ! target . classList . contains ( "memberLabel" ) ) {
261+ if ( this . props . frame != this . props . selection ) {
262+ this . props . dispatch ( selectFrame ( this . props . frame ) ) ;
263+ }
264+ }
265+ } ,
266+
267+ render : function ( ) {
268+ var frame = this . props . frame ;
269+
270+ // Frame classes
271+ var classNames = [ "frameBubble" , "eventBubble" , frame . type ] ;
272+ if ( this . props . selection == frame ) {
273+ classNames . push ( "selected" ) ;
274+ }
275+
276+ var label = frame . uri ?
277+ Locale . $STR ( "websocketmonitor.event.connected" ) :
278+ Locale . $STR ( "websocketmonitor.event.disconnected" ) ;
279+
280+ var uri = frame . uri ? frame . uri :
281+ Locale . $STR ( "websocketmonitor.event.code" ) + " " + frame . code ;
282+
283+ var socketIdLabel = Locale . $STR ( "websocketmonitor.SocketID" ) +
284+ ": " + frame . webSocketSerialID ;
285+
286+ return (
287+ div ( { className : classNames . join ( " " ) , onClick : this . onClick } ,
288+ div ( { className : "frameBox" } ,
289+ div ( { className : "frameContent" } ,
290+ div ( { className : "body" } ,
291+ div ( { className : "text" } , label ) ,
292+ div ( { className : "uri" } , uri ) ,
293+ div ( { className : "socketId" } , socketIdLabel )
294+ )
295+ )
296+ )
297+ )
298+ ) ;
299+ }
300+ } ) ) ;
301+
222302/**
223303 * @template This template is responsible for rendering a message
224304 * at the top of the frame list that informs the user about reaching
0 commit comments