diff options
-rw-r--r-- | src/client/util/ReportManager.tsx | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/client/util/ReportManager.tsx b/src/client/util/ReportManager.tsx index b36e7e063..d680b47ac 100644 --- a/src/client/util/ReportManager.tsx +++ b/src/client/util/ReportManager.tsx @@ -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_l.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)}`; + 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, |