From a41d3546cbf34313b1d0a2caa7050fd04e7eee0f Mon Sep 17 00:00:00 2001 From: Michael Foiani Date: Thu, 18 Aug 2022 00:47:30 +0200 Subject: add button to create an issue - also can upload files. --- src/client/util/ReportManager.scss | 14 ++++++ src/client/util/ReportManager.tsx | 95 +++++++++++++++++++++++++++++--------- 2 files changed, 86 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/client/util/ReportManager.scss b/src/client/util/ReportManager.scss index 1f008a426..4bcbdc566 100644 --- a/src/client/util/ReportManager.scss +++ b/src/client/util/ReportManager.scss @@ -53,3 +53,17 @@ display: block; max-width: 100%; } + +.report-issue-fab { + position: fixed; + bottom: 20px; + right: 20px; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; +} + +.loading-center { + margin: auto 0; +} diff --git a/src/client/util/ReportManager.tsx b/src/client/util/ReportManager.tsx index fa9a0513b..75102ec8e 100644 --- a/src/client/util/ReportManager.tsx +++ b/src/client/util/ReportManager.tsx @@ -37,9 +37,11 @@ export class ReportManager extends React.Component<{}> { @observable public issues: any[] = []; @action setIssues = action((issues: any[]) => { this.issues = issues; }); - @observable public selectedIssue: any = null; + // undefined is the default - null is if the user is making an issue + @observable public selectedIssue: any = undefined; @action setSelectedIssue = action((issue: any) => { this.selectedIssue = issue; }); + // only get the open issues @observable public shownIssues = this.issues.filter(issue => issue.state === 'open'); public updateIssueSearch = action((query: string = '') => { @@ -98,11 +100,12 @@ export class ReportManager extends React.Component<{}> { public async reportIssue() { if (this.toGithub) { + const req = await this.octokit.request('POST /repos/{owner}/{repo}/issues', { owner: 'brown-dash', repo: 'Dash-Web', title: this.formatTitle(this.bugTitle, Doc.CurrentUserEmail), - body: this.bugDescription, + body: `${this.bugDescription} \n\nfileLinks:\n${(this.fileLinks ?? []).join('\n')}`, labels: [ 'from-dash-app', ] @@ -123,31 +126,85 @@ export class ReportManager extends React.Component<{}> { this.bugTitle = ''; this.bugDescription = ''; this.toGithub = false; + this.setFileLinks([]) this.close(); } + @observable public fileLinks: any = []; + @action setFileLinks = action((links: any) => { this.fileLinks = links; }); + + private getServerPath = (link: any) => { return link.result.accessPaths.agnostic.server } + + private uploadFiles = (input: any) => { + this.setFileLinks(null); + // upload the files to the server + if (input.files && input.files.length !== 0) { + const fileArray: File[] = Array.from(input.files); + Networking.UploadFilesToServer(fileArray).then(links => { + console.log('finshed uploading', links.map(this.getServerPath)); + this.setFileLinks(links.map(this.getServerPath)); + }) + } + + } + + private renderIssue = (issue: any) => { - const { title, body, number, html_url } = issue; - return ( + const isReportingIssue = issue === null; + + return isReportingIssue ? + // report issue + (
+

Report an Issue

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