From 6bfdd692790becbd1b9560c82a1279aac8e322ab Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 31 Jul 2017 12:08:41 +0100 Subject: [PATCH 01/11] add devtools dialog --- .../views/dialogs/DevtoolsDialog.js | 206 ++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 src/components/views/dialogs/DevtoolsDialog.js diff --git a/src/components/views/dialogs/DevtoolsDialog.js b/src/components/views/dialogs/DevtoolsDialog.js new file mode 100644 index 00000000..c4248fa9 --- /dev/null +++ b/src/components/views/dialogs/DevtoolsDialog.js @@ -0,0 +1,206 @@ +/* +Copyright 2017 OpenMarket Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import React from 'react'; +import sdk from 'matrix-react-sdk'; +import Modal from 'matrix-react-sdk/lib/Modal'; +import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg'; + +class SendCustomEvent extends React.Component { + static propTypes = { + roomId: React.PropTypes.string.isRequired, + onFinished: React.PropTypes.func.isRequired, + }; + + constructor(props, context) { + super(props, context); + this._send = this._send.bind(this); + this.onCancel = this.onCancel.bind(this); + } + + async _send() { + try { + const content = JSON.parse(this.refs.evContent.value); + await MatrixClientPeg.get().sendEvent(this.refs.roomId.value, this.refs.eventType.value, content); + this.props.onFinished(true); + } catch (e) { + this.props.onFinished(false); + const ErrorDialog = sdk.getComponent('dialogs.ErrorDialog'); + Modal.createDialog(ErrorDialog, { + title: 'Failed to send custom event', + description: e.toString(), + }); + } + } + + onCancel() { + this.props.onFinished(false); + } + + render() { + return
+
+
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+