diff options
author | Michael Foiani <sotech117@michaels-mbp-5.devices.brown.edu> | 2022-08-03 15:04:47 -0400 |
---|---|---|
committer | Michael Foiani <sotech117@michaels-mbp-5.devices.brown.edu> | 2022-08-03 15:04:47 -0400 |
commit | 6050255dbf953b6e18a453f4feb7c0896b750793 (patch) | |
tree | 42016d69043f8e08a541b77c63f9d264d4b2cdf7 /src/client/util/ReportManager.tsx | |
parent | b91fe8270c2c4445bff5d1e30d4b1d0901e68f77 (diff) |
fix title bug and api key removed
Diffstat (limited to 'src/client/util/ReportManager.tsx')
-rw-r--r-- | src/client/util/ReportManager.tsx | 20 |
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(); } |