From 63853d9de19fc45f8253fb41c465f8924c19008b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 30 Mar 2020 16:12:28 +0100 Subject: [PATCH] Add download logs button to BugReportDialog Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/dialogs/BugReportDialog.js | 34 ++++++++++++++++++- src/i18n/strings/en_EN.json | 2 ++ src/rageshake/submit-rageshake.js | 2 +- yarn.lock | 5 +++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/components/views/dialogs/BugReportDialog.js b/src/components/views/dialogs/BugReportDialog.js index 6e337d53dc..0916e680e0 100644 --- a/src/components/views/dialogs/BugReportDialog.js +++ b/src/components/views/dialogs/BugReportDialog.js @@ -23,7 +23,8 @@ import * as sdk from '../../../index'; import SdkConfig from '../../../SdkConfig'; import Modal from '../../../Modal'; import { _t } from '../../../languageHandler'; -import sendBugReport from '../../../rageshake/submit-rageshake'; +import sendBugReport, {downloadBugReport} from '../../../rageshake/submit-rageshake'; +import AccessibleButton from "../elements/AccessibleButton"; export default class BugReportDialog extends React.Component { constructor(props) { @@ -95,6 +96,32 @@ export default class BugReportDialog extends React.Component { }); } + _onDownload = async (ev) => { + this.setState({ busy: true, progress: null, err: null }); + this._sendProgressCallback(_t("Preparing to download logs")); + + try { + await downloadBugReport({ + sendLogs: true, + progressCallback: this._sendProgressCallback, + label: this.props.label, + }); + + this.setState({ + busy: false, + progress: null, + }); + } catch (err) { + if (!this._unmounted) { + this.setState({ + busy: false, + progress: null, + err: _t("Failed to send logs: ") + `${err.message}`, + }); + } + } + }; + _onTextChange(ev) { this.setState({ text: ev.target.value }); } @@ -165,6 +192,11 @@ export default class BugReportDialog extends React.Component { }, ) }

+ + + { _t("Click here to download your logs.") } + + create a GitHub issue to describe your problem.": "Before submitting logs, you must create a GitHub issue to describe your problem.", + "Click here to download your logs.": "Click here to download your logs.", "GitHub issue": "GitHub issue", "Notes": "Notes", "If there is additional context that would help in analysing the issue, such as what you were doing at the time, room IDs, user IDs, etc., please include those things here.": "If there is additional context that would help in analysing the issue, such as what you were doing at the time, room IDs, user IDs, etc., please include those things here.", diff --git a/src/rageshake/submit-rageshake.js b/src/rageshake/submit-rageshake.js index 1500130ffd..3e83cafbcd 100644 --- a/src/rageshake/submit-rageshake.js +++ b/src/rageshake/submit-rageshake.js @@ -195,7 +195,7 @@ export async function downloadBugReport(opts) { resolve(); }); reader.readAsArrayBuffer(e[1]); - })) + })); } else { metadata += `${e[0]} = ${e[1]}\n`; } diff --git a/yarn.lock b/yarn.lock index c5fc8268a1..6451879a5b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8189,6 +8189,11 @@ tapable@^1.0.0, tapable@^1.1.3: resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2" integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA== +tar-js@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/tar-js/-/tar-js-0.3.0.tgz#6949aabfb0ba18bb1562ae51a439fd0f30183a17" + integrity sha1-aUmqv7C6GLsVYq5RpDn9DzAYOhc= + terser-webpack-plugin@^1.4.3: version "1.4.3" resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.4.3.tgz#5ecaf2dbdc5fb99745fd06791f46fc9ddb1c9a7c"