diff options
Diffstat (limited to 'src/client/util/ReportManager.tsx')
-rw-r--r-- | src/client/util/ReportManager.tsx | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/client/util/ReportManager.tsx b/src/client/util/ReportManager.tsx index 55c5ca87f..51742d455 100644 --- a/src/client/util/ReportManager.tsx +++ b/src/client/util/ReportManager.tsx @@ -57,7 +57,7 @@ export class ReportManager extends React.Component<{}> { ReportManager.Instance = this; this.octokit = new Octokit({ - auth: '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' + auth: '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' }); } @@ -104,6 +104,20 @@ export class ReportManager extends React.Component<{}> { } } + // turns an upload link into a servable link + // ex: + // C: /Users/dash/Documents/GitHub/Dash-Web/src/server/public/files/images/upload_8008dbc4b6424fbff14da7345bb32eb2.png + // -> http://localhost:1050/files/images/upload_8008dbc4b6424fbff14da7345bb32eb2_l.png + private fileLinktoServerLink = (fileLink: string) => { + const serverUrl = 'https://browndash.com/'; + + const regex = 'public' + const publicIndex = fileLink.indexOf(regex) + regex.length; + + const finalUrl = `${serverUrl}${fileLink.substring(publicIndex + 1).replace('.', '_l.')}`; + return finalUrl; + } + public async reportIssue() { if (this.bugTitle === '' || this.bugDescription === '' || this.bugType === '' || this.bugPriority === '') { @@ -111,14 +125,15 @@ export class ReportManager extends React.Component<{}> { return; } - if (this.toGithub) { + const formattedLinks = (this.fileLinks ?? []).map(this.fileLinktoServerLink) + 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} \n\nfiles:\n${(this.fileLinks ?? []).join('\n')}`, + body: `${this.bugDescription} \n\nfiles:\n${formattedLinks.join('\n')}`, labels: [ 'from-dash-app', this.bugType, @@ -140,7 +155,7 @@ export class ReportManager extends React.Component<{}> { // if we're down here, then we're good to go. reset the fields. this.setBugTitle(''); this.setBugDescription(''); - this.toGithub = false; + // this.toGithub = false; this.setFileLinks([]); this.setBugType(''); this.setBugPriority(''); @@ -176,10 +191,10 @@ export class ReportManager extends React.Component<{}> { (<div className="settings-content"> <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} required/> + <input type="text" placeholder='title' onChange={(e) => this.setBugTitle(e.target.value)} required/> <br /> <label>Please leave a description for the bug and how it can be recreated.</label> - <textarea placeholder='description' onChange={(e) => this.bugDescription = e.target.value} required/> + <textarea placeholder='description' onChange={(e) => this.setBugDescription(e.target.value)} required/> <br /> {/* {<label>Send to github issues? </label> <input type="checkbox" onChange={(e) => this.toGithub = e.target.checked} /> @@ -187,14 +202,14 @@ export class ReportManager extends React.Component<{}> { <label>Please label the issue</label> <div className='flex-select'> - <select name="bugType"> + <select name="bugType" onChange={e => this.bugType = e.target.value}> <option value="" disabled selected>Type</option> <option value="bug">Bug</option> <option value="cosmetic">Poor Design or Cosmetic</option> <option value="documentation">Poor Documentation</option> </select> - <select name="bigPriority"> + <select name="bigPriority" onChange={e => this.bugPriority = e.target.value}> <option value="" disabled selected>Priority</option> <option value="priority-low">Low</option> <option value="priority-medium">Medium</option> @@ -205,7 +220,7 @@ export class ReportManager extends React.Component<{}> { <div> <label>Upload media that shows the bug (optional)</label> - <input type="file" name="file" multiple accept='audio/*, video/*' onChange={e => this.uploadFiles(e.target)}/> + <input type="file" name="file" multiple accept='audio/*, video/*, image/*' onChange={e => this.uploadFiles(e.target)}/> </div> <br /> |