From bea6df88e0495624794472f99f45c22b273bc2f6 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 25 Jan 2017 16:33:00 +0000 Subject: [PATCH 1/2] Move BugReportDialog to riot-web --- src/components/structures/UserSettings.js | 3 + .../views/dialogs/BugReportDialog.js | 124 ------------------ 2 files changed, 3 insertions(+), 124 deletions(-) delete mode 100644 src/components/views/dialogs/BugReportDialog.js diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 99f3d9cd3c..cf4a63e2f7 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -391,6 +391,9 @@ module.exports = React.createClass({ _onBugReportClicked: function() { const BugReportDialog = sdk.getComponent("dialogs.BugReportDialog"); + if (!BugReportDialog) { + return; + } Modal.createDialog(BugReportDialog, {}); }, diff --git a/src/components/views/dialogs/BugReportDialog.js b/src/components/views/dialogs/BugReportDialog.js deleted file mode 100644 index e8a8b2b869..0000000000 --- a/src/components/views/dialogs/BugReportDialog.js +++ /dev/null @@ -1,124 +0,0 @@ -/* -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 '../../../index'; - -export default class BugReportDialog extends React.Component { - constructor(props, context) { - super(props, context); - this.state = { - sendLogs: true, - busy: false, - err: null, - text: "", - }; - this._onSubmit = this._onSubmit.bind(this); - this._onCancel = this._onCancel.bind(this); - this._onTextChange = this._onTextChange.bind(this); - this._onSendLogsChange = this._onSendLogsChange.bind(this); - } - - _onCancel(ev) { - this.props.onFinished(false); - } - - _onSubmit(ev) { - const sendLogs = this.state.sendLogs; - const userText = this.state.text; - if (!sendLogs && userText.trim().length === 0) { - this.setState({ - err: "Please describe the bug and/or send logs.", - }); - return; - } - // TODO: Make the HTTP hit - this.setState({ busy: true, err: null }); - setTimeout(() => { - this.setState({ busy: false, err: "No bug report endpoint." }); - }, 1000); - } - - _onTextChange(ev) { - this.setState({ text: ev.target.value }); - } - - _onSendLogsChange(ev) { - this.setState({ sendLogs: ev.target.checked }); - } - - render() { - const Loader = sdk.getComponent("elements.Spinner"); - - let error = null; - if (this.state.err) { - error =
- {this.state.err} -
; - } - - const okLabel = this.state.busy ? : 'Send'; - - let cancelButton = null; - if (!this.state.busy) { - cancelButton = ; - } - - return ( -
-
- Report a bug -
-
-

Please describe the bug. What did you do? - What did you expect to happen? - What actually happened?

-