11import React , { PureComponent } from 'react' ;
22import { Observable as obs } from 'rxjs' ;
33import {
4+ Card ,
5+ CardActions ,
6+ CardContent ,
47 Popover ,
5- Typography ,
6- ExpansionPanel ,
7- ExpansionPanelSummary ,
8- ExpansionPanelDetails ,
8+ Tab ,
9+ Tabs ,
910 withStyles ,
1011} from '@material-ui/core' ;
1112import Inspector , {
@@ -14,7 +15,6 @@ import Inspector, {
1415 ObjectName ,
1516} from 'react-inspector' ;
1617import uriTemplate from 'uri-template' ;
17- import { Code } from '../../components/Icons' ;
1818import {
1919 Table ,
2020 TableBody ,
@@ -23,6 +23,7 @@ import {
2323 TableCell ,
2424} from '../../components/StripeyTable' ;
2525import { Hyperlink , StreamBrowser } from '../../components' ;
26+ import { Notes , Settings } from '../../components/Icons' ;
2627import { createState , connect } from '../../reactive' ;
2728import rels from '../rels' ;
2829import { http } from '../../utils' ;
@@ -179,14 +180,14 @@ const StreamMessageJson = withStyles({
179180 < span >
180181 < ObjectName name = { name } dimmed = { isNonEnumerable } />
181182 < span > : </ span >
182- < span
183+ < a
183184 className = { this . props . classes . streamId }
184185 onClick = { e =>
185186 this . _handlePotentialStreamIdClick ( e , data )
186187 }
187188 >
188189 { data }
189- </ span >
190+ </ a >
190191 </ span >
191192 ) : (
192193 < ObjectLabel
@@ -232,13 +233,52 @@ const StreamMessageJson = withStyles({
232233 } ,
233234) ;
234235
235- const StreamMessageData = ( { payload, ...props } ) => (
236- < StreamMessageJson title = { 'Data' } json = { payload } { ...props } />
237- ) ;
236+ class StreamMessageTabs extends PureComponent {
237+ state = {
238+ value : 0 ,
239+ } ;
238240
239- const StreamMessageMetadata = ( { payload, ...props } ) => (
240- < StreamMessageJson title = { 'Metadata' } json = { payload } { ...props } />
241- ) ;
241+ _handleChange = ( e , value ) => this . setState ( { value } ) ;
242+
243+ render ( ) {
244+ const {
245+ message : { payload, metadata } ,
246+ links,
247+ onNavigate,
248+ } = this . props ;
249+ const { value } = this . state ;
250+ return (
251+ < Card >
252+ < CardActions >
253+ < Tabs
254+ value = { value }
255+ onChange = { this . _handleChange }
256+ indicatorColor = { 'primary' }
257+ >
258+ < Tab label = { 'Data' } icon = { < Notes /> } />
259+ < Tab label = { 'Metadata' } icon = { < Settings /> } />
260+ </ Tabs >
261+ </ CardActions >
262+ < CardContent >
263+ { value === 0 && (
264+ < StreamMessageJson
265+ json = { payload }
266+ onNavigate = { onNavigate }
267+ links = { links }
268+ />
269+ ) }
270+ { value === 1 && (
271+ < StreamMessageJson
272+ json = { metadata }
273+ onNavigate = { onNavigate }
274+ links = { links }
275+ />
276+ ) }
277+ </ CardContent >
278+ </ Card >
279+ ) ;
280+ }
281+ }
242282
243283const StreamMessage = ( { message, links, onNavigate } ) => (
244284 < section >
@@ -254,13 +294,8 @@ const StreamMessage = ({ message, links, onNavigate }) => (
254294 />
255295 </ TableBody >
256296 </ Table >
257- < StreamMessageData
258- payload = { message . payload }
259- onNavigate = { onNavigate }
260- links = { links }
261- />
262- < StreamMessageMetadata
263- payload = { message . metadata }
297+ < StreamMessageTabs
298+ message = { message }
264299 onNavigate = { onNavigate }
265300 links = { links }
266301 />
0 commit comments