aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package-lock.json23
-rw-r--r--src/client/util/reportManager/ReportManager.tsx16
-rw-r--r--src/client/util/reportManager/ReportManagerComponents.tsx21
-rw-r--r--src/client/util/reportManager/reportManagerUtils.ts7
4 files changed, 43 insertions, 24 deletions
diff --git a/package-lock.json b/package-lock.json
index c22c34b26..3e93d4c20 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4,15 +4,6 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
- "@ampproject/remapping": {
- "version": "2.2.1",
- "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz",
- "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==",
- "requires": {
- "@jridgewell/gen-mapping": "^0.3.0",
- "@jridgewell/trace-mapping": "^0.3.9"
- }
- },
"@azure/abort-controller": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz",
@@ -129,6 +120,20 @@
}
},
"@babel/code-frame": {
+ "version": "7.18.6",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz",
+ "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==",
+ "@ampproject/remapping": {
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz",
+ "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg=="
+ },
+ "requires": {
+ "@jridgewell/gen-mapping": "^0.3.0",
+ "@jridgewell/trace-mapping": "^0.3.9"
+ }
+ },
+ "@babel/code-frame": {
"version": "7.22.5",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.5.tgz",
"integrity": "sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==",
diff --git a/src/client/util/reportManager/ReportManager.tsx b/src/client/util/reportManager/ReportManager.tsx
index f20c2baaa..e684bd637 100644
--- a/src/client/util/reportManager/ReportManager.tsx
+++ b/src/client/util/reportManager/ReportManager.tsx
@@ -124,15 +124,13 @@ export class ReportManager extends React.Component<{}> {
alert('Please fill out all required fields to report an issue.');
return;
}
- let formattedLinks: string[] = [];
this.setSubmitting(true);
+ let formattedLinks: string[] = [];
if (this.formData.mediaFiles.length > 0) {
const links = await uploadFilesToServer(this.formData.mediaFiles);
- console.log(links);
- if (!links) {
- return;
+ if (links) {
+ formattedLinks = links;
}
- formattedLinks = links;
}
const req = await this.octokit.request('POST /repos/{owner}/{repo}/issues', {
@@ -146,14 +144,12 @@ export class ReportManager extends React.Component<{}> {
// 201 status means success
if (req.status !== 201) {
alert('Error creating issue on github.');
- return;
+ } else {
+ await this.updateIssues();
+ alert('Successfully submitted issue.');
}
-
- // Reset fields
this.setFormData(emptyReportForm);
this.setSubmitting(false);
- await this.updateIssues();
- alert('Successfully submitted issue.');
}
/**
diff --git a/src/client/util/reportManager/ReportManagerComponents.tsx b/src/client/util/reportManager/ReportManagerComponents.tsx
index 8f882c7f2..e870c073d 100644
--- a/src/client/util/reportManager/ReportManagerComponents.tsx
+++ b/src/client/util/reportManager/ReportManagerComponents.tsx
@@ -120,6 +120,7 @@ export const IssueView = ({ issue }: IssueViewProps) => {
const audioTagRegex = /<audio\b[^>]*\/?>/;
const fileRegex = /https:\/\/browndash\.com\/files/;
+ const localRegex = /http:\/\/localhost:1050\/files/;
const parts = body.split('\n');
const modifiedParts = await Promise.all(
@@ -129,6 +130,9 @@ export const IssueView = ({ issue }: IssueViewProps) => {
} else if (fileRegex.test(part)) {
const tag = await parseDashFiles(part);
return tag;
+ } else if (localRegex.test(part)) {
+ const tag = await parseLocalFiles(part);
+ return tag;
} else {
return part;
}
@@ -189,6 +193,23 @@ export const IssueView = ({ issue }: IssueViewProps) => {
}
};
+ // Returns the corresponding HTML tag for a src url
+ const parseLocalFiles = async (url: string) => {
+ const imgRegex = /http:\/\/localhost:1050\/files[/\\]images/;
+ const dashVideoRegex = /http:\/\/localhost:1050\.com\/files[/\\]videos/;
+ const dashAudioRegex = /http:\/\/localhost:1050\.com\/files[/\\]audio/;
+
+ if (imgRegex.test(url)) {
+ return await getDisplayedFile(url, 'image');
+ } else if (dashVideoRegex.test(url)) {
+ return await getDisplayedFile(url, 'video');
+ } else if (dashAudioRegex.test(url)) {
+ return await getDisplayedFile(url, 'audio');
+ } else {
+ return url;
+ }
+ };
+
const getDisplayedFile = async (url: string, fileType: 'image' | 'video' | 'audio'): Promise<string> => {
switch (fileType) {
case 'image':
diff --git a/src/client/util/reportManager/reportManagerUtils.ts b/src/client/util/reportManager/reportManagerUtils.ts
index d8344220f..b95417aa1 100644
--- a/src/client/util/reportManager/reportManagerUtils.ts
+++ b/src/client/util/reportManager/reportManagerUtils.ts
@@ -84,7 +84,7 @@ export const formatTitle = (title: string, userEmail: string): string => `${titl
// C: /Users/dash/Documents/GitHub/Dash-Web/src/server/public/files/images/upload_8008dbc4b6424fbff14da7345bb32eb2.png
// -> https://browndash.com/files/images/upload_8008dbc4b6424fbff14da7345bb32eb2_l.png
export const fileLinktoServerLink = (fileLink: string): string => {
- const serverUrl = 'https://browndash.com/';
+ const serverUrl = window.location.href.includes('browndash') ? 'https://browndash.com/' : 'http://localhost:1050/';
const regex = 'public';
const publicIndex = fileLink.indexOf(regex) + regex.length;
@@ -110,10 +110,7 @@ export const getServerPath = (link: any): string => {
export const uploadFilesToServer = async (mediaFiles: FileData[]): Promise<string[] | undefined> => {
try {
// need to always upload to browndash
- const links = await Networking.UploadFilesToServer(
- mediaFiles.map(file => ({ file: file.file })),
- true
- );
+ const links = await Networking.UploadFilesToServer(mediaFiles.map(file => ({ file: file.file })));
return (links ?? []).map(getServerPath).map(fileLinktoServerLink);
} catch (err) {
if (err instanceof Error) {