aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/util/ReportManager.tsx48
1 files changed, 44 insertions, 4 deletions
diff --git a/src/client/util/ReportManager.tsx b/src/client/util/ReportManager.tsx
index b156d7981..86be06676 100644
--- a/src/client/util/ReportManager.tsx
+++ b/src/client/util/ReportManager.tsx
@@ -16,6 +16,8 @@ import { DragManager } from './DragManager';
import { GroupManager } from './GroupManager';
import './SettingsManager.scss';
import { undoBatch } from './UndoManager';
+import { Octokit } from "@octokit/core";
+import { CheckBox } from '../views/search/CheckBox';
const higflyout = require('@hig/flyout');
export const { anchorPoints } = higflyout;
export const Flyout = higflyout.default;
@@ -35,9 +37,40 @@ export class ReportManager extends React.Component<{}> {
private bugTitle = '';
private bugDescription = '';
+ private toGithub = false;
- public reportBug() {
+ private formatTitle = (title: string, userEmail: string) => `${this.bugTitle} - ${Doc.CurrentUserEmail.replace('@brown.edu', '')}`;
+
+ public async reportBug() {
console.log('Reporting bug', this.bugTitle, this.bugDescription);
+
+ const octokit = new Octokit({
+ auth: 'personal auth key'
+ });
+
+ if (this.toGithub) {
+ const req = await octokit.request('POST /repos/{owner}/{repo}/issues', {
+ owner: 'brown-dash',
+ repo: 'Dash-Web',
+ title: this.formatTitle(this.bugTitle, Doc.CurrentUserEmail),
+ body: this.bugDescription,
+ labels: [
+ 'from-dash-app',
+ ]
+ });
+
+ if (req.status !== 201) {
+ alert('Error creating issue on github.');
+ return;
+ }
+ }
+
+ // if we're down here, then we're good to go.
+ this.bugTitle = '';
+ this.bugDescription = '';
+ this.toGithub = false;
+
+ this.close();
}
private get reportInterface() {
@@ -49,13 +82,20 @@ export class ReportManager extends React.Component<{}> {
</div>
<div className="settings-content">
- <h3 style={{ 'textDecoration': 'underline'}}>Report a Bug</h3>
+ <h3 style={{ 'textDecoration': 'underline'}}>Report an Issue</h3>
<label>Please leave a title for the bug.</label><br />
- <input type="text" placeholder='title' onChange={(e) => this.bugTitle = e.target.value}/> <br />
+ <input type="text" placeholder='title' onChange={(e) => this.bugTitle = e.target.value} />
+ <br />
<label>Please leave a description for the bug and how it can be reacreated.</label>
- <textarea placeholder='description' onChange={(e) => this.bugDescription = e.target.value}/> <br /><br />
+ <textarea placeholder='description' onChange={(e) => this.bugDescription = e.target.value}/>
+ <br /><br />
+ <label>Send to github issues? </label>
+ <input type="checkbox" onChange={(e) => this.toGithub = e.target.checked} />
+ <br />
<button onClick={() => this.reportBug()}>Submit</button>
</div>
+
+
</div>
);
}