From b91fe8270c2c4445bff5d1e30d4b1d0901e68f77 Mon Sep 17 00:00:00 2001 From: Michael Foiani Date: Wed, 3 Aug 2022 14:58:54 -0400 Subject: got the label and resetting form to work for issue feature. --- src/client/util/ReportManager.tsx | 48 +++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'src') 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<{}> {
-

Report a Bug

+

Report an Issue


- this.bugTitle = e.target.value}/>
+ this.bugTitle = e.target.value} /> +
-