aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/ReportManager.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/util/ReportManager.tsx')
-rw-r--r--src/client/util/ReportManager.tsx20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/client/util/ReportManager.tsx b/src/client/util/ReportManager.tsx
index 86be06676..54208db84 100644
--- a/src/client/util/ReportManager.tsx
+++ b/src/client/util/ReportManager.tsx
@@ -27,9 +27,15 @@ export class ReportManager extends React.Component<{}> {
public static Instance: ReportManager;
@observable private isOpen = false;
+ private octokit: Octokit;
+
constructor(props: {}) {
super(props);
ReportManager.Instance = this;
+
+ this.octokit = new Octokit({
+ auth: ''
+ });
}
public close = action(() => (this.isOpen = false));
@@ -39,17 +45,13 @@ export class ReportManager extends React.Component<{}> {
private bugDescription = '';
private toGithub = false;
- private formatTitle = (title: string, userEmail: string) => `${this.bugTitle} - ${Doc.CurrentUserEmail.replace('@brown.edu', '')}`;
+ private formatTitle = (title: string, userEmail: string) => `${title} - ${userEmail.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', {
+ const req = await this.octokit.request('POST /repos/{owner}/{repo}/issues', {
owner: 'brown-dash',
repo: 'Dash-Web',
title: this.formatTitle(this.bugTitle, Doc.CurrentUserEmail),
@@ -59,17 +61,21 @@ export class ReportManager extends React.Component<{}> {
]
});
+ // 201 status means success
if (req.status !== 201) {
alert('Error creating issue on github.');
+ // on error, don't close the modal
return;
}
}
+ else {
+ // if not going to github, not sure what to do yet...
+ }
// if we're down here, then we're good to go.
this.bugTitle = '';
this.bugDescription = '';
this.toGithub = false;
-
this.close();
}