From ea9b6300828af0d58c46e4c5202e0e52a9a5e4e4 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 30 Oct 2017 12:44:50 +0000 Subject: [PATCH] Refactor and add Account Data stuffs Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/dialogs/DevtoolsDialog.js | 463 +++++++++++++----- src/i18n/strings/en_EN.json | 4 + .../views/dialogs/_DevtoolsDialog.scss | 103 ++++ 3 files changed, 457 insertions(+), 113 deletions(-) diff --git a/src/components/views/dialogs/DevtoolsDialog.js b/src/components/views/dialogs/DevtoolsDialog.js index 7760ea84..2c854f99 100644 --- a/src/components/views/dialogs/DevtoolsDialog.js +++ b/src/components/views/dialogs/DevtoolsDialog.js @@ -15,35 +15,24 @@ limitations under the License. */ import React from 'react'; +import PropTypes from 'prop-types'; import sdk from 'matrix-react-sdk'; import { _t } from 'matrix-react-sdk/lib/languageHandler'; import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg'; -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, +class DevtoolsComponent extends React.Component { + static contextTypes = { + roomId: PropTypes.string.isRequired, }; +} - static defaultProps = { - eventType: '', - evContent: '{\n\n}', - }; +class GenericEditor extends DevtoolsComponent { + // static propTypes = {onBack: PropTypes.func.isRequired}; constructor(props, context) { super(props, context); - this._send = this._send.bind(this); - this.onBack = this.onBack.bind(this); this._onChange = this._onChange.bind(this); - - this.state = { - message: null, - input_eventType: this.props.eventType, - input_evContent: this.props.evContent, - }; + this.onBack = this.onBack.bind(this); } onBack() { @@ -54,6 +43,10 @@ class SendCustomEvent extends React.Component { } } + _onChange(e) { + this.setState({[e.target.id]: e.target.type === 'checkbox' ? e.target.checked : e.target.value}); + } + _buttons() { return
{ JSON.stringify(this.state.event.event, null, 2) }@@ -234,11 +354,9 @@ class RoomStateExplorer extends React.Component { const rows = []; + const classes = 'mx_DevTools_RoomStateExplorer_button'; if (this.state.eventType === null) { Object.keys(this.roomStateEvents).forEach((evType) => { - // Skip this entry if does not contain search query - if (this.state.query && !evType.toLowerCase().includes(this.state.query.toLowerCase())) return; - const stateGroup = this.roomStateEvents[evType]; const stateKeys = Object.keys(stateGroup); @@ -249,7 +367,7 @@ class RoomStateExplorer extends React.Component { onClickFn = this.onViewSourceClick(stateGroup[stateKeys[0]]); } - rows.push(