Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit dde4284

Browse files
can't use ExpansionPanel as the click on the Inspector bubbles up
1 parent 7ce2d03 commit dde4284

File tree

2 files changed

+56
-20
lines changed

2 files changed

+56
-20
lines changed

src/components/Icons/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export { default as Error } from '@material-ui/icons/Error';
99
export { default as Info } from '@material-ui/icons/Info';
1010
export { default as Publish } from '@material-ui/icons/Publish';
1111
export { default as Settings } from '@material-ui/icons/Settings';
12+
export { default as Notes } from '@material-ui/icons/Notes';
1213
export { default as DeleteForever } from '@material-ui/icons/DeleteForever';
1314
export { default as FirstPage } from '@material-ui/icons/FirstPage';
1415
export { default as LastPage } from '@material-ui/icons/LastPage';

src/stream-store/views/StreamMessage.js

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React, { PureComponent } from 'react';
22
import { Observable as obs } from 'rxjs';
33
import {
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';
1112
import Inspector, {
@@ -14,7 +15,6 @@ import Inspector, {
1415
ObjectName,
1516
} from 'react-inspector';
1617
import uriTemplate from 'uri-template';
17-
import { Code } from '../../components/Icons';
1818
import {
1919
Table,
2020
TableBody,
@@ -23,6 +23,7 @@ import {
2323
TableCell,
2424
} from '../../components/StripeyTable';
2525
import { Hyperlink, StreamBrowser } from '../../components';
26+
import { Notes, Settings } from '../../components/Icons';
2627
import { createState, connect } from '../../reactive';
2728
import rels from '../rels';
2829
import { 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

243283
const 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

Comments
 (0)