diff --git a/src/components/views/dialogs/DevtoolsDialog.js b/src/components/views/dialogs/DevtoolsDialog.js index 22fd712d..6f9d6316 100644 --- a/src/components/views/dialogs/DevtoolsDialog.js +++ b/src/components/views/dialogs/DevtoolsDialog.js @@ -23,6 +23,14 @@ class SendCustomEvent extends React.Component { static propTypes = { roomId: React.PropTypes.string.isRequired, onBack: React.PropTypes.func.isRequired, + + eventType: React.PropTypes.string.isRequired, + evContent: React.PropTypes.string.isRequired, + }; + + static defaultProps = { + eventType: '', + evContent: '{\n\n}', }; constructor(props, context) { @@ -33,8 +41,8 @@ class SendCustomEvent extends React.Component { this.state = { message: null, - input_eventType: '', - input_evContent: '{\n\n}', + input_eventType: this.props.eventType, + input_evContent: this.props.evContent, }; } @@ -115,9 +123,24 @@ class SendCustomEvent extends React.Component { } class SendCustomStateEvent extends SendCustomEvent { + static propTypes = { + roomId: React.PropTypes.string.isRequired, + onBack: React.PropTypes.func.isRequired, + + eventType: React.PropTypes.string.isRequired, + evContent: React.PropTypes.string.isRequired, + stateKey: React.PropTypes.string.isRequired, + }; + + static defaultProps = { + eventType: '', + evContent: '{\n\n}', + stateKey: '', + }; + constructor(props, context) { super(props, context); - this.state['input_stateKey'] = ''; + this.state['input_stateKey'] = this.props.stateKey; } send(content) { @@ -139,6 +162,7 @@ class SendCustomStateEvent extends SendCustomEvent { class RoomStateExplorer extends React.Component { static propTypes = { + setMode: React.PropTypes.func.isRequired, roomId: React.PropTypes.string.isRequired, onBack: React.PropTypes.func.isRequired, }; @@ -150,6 +174,7 @@ class RoomStateExplorer extends React.Component { this.roomStateEvents = room.currentState.events; this.onBack = this.onBack.bind(this); + this.editEv = this.editEv.bind(this); } state = { @@ -165,7 +190,7 @@ class RoomStateExplorer extends React.Component { onViewSourceClick(event) { return () => { - this.setState({ event: event.event }); + this.setState({ event }); }; } @@ -179,14 +204,24 @@ class RoomStateExplorer extends React.Component { } } + editEv() { + const ev = this.state.event; + this.props.setMode(SendCustomStateEvent, { + eventType: ev.getType(), + evContent: JSON.stringify(ev.getContent(), null, '\t'), + stateKey: ev.getStateKey(), + }); + } + render() { if (this.state.event) { return
{JSON.stringify(this.state.event, null, 2)}+
{JSON.stringify(this.state.event.event, null, 2)}