diff --git a/apps/studio/components/interfaces/Support/AttachmentUpload.tsx b/apps/studio/components/interfaces/Support/AttachmentUpload.tsx index 36cd6ea6d41..9eb1042a789 100644 --- a/apps/studio/components/interfaces/Support/AttachmentUpload.tsx +++ b/apps/studio/components/interfaces/Support/AttachmentUpload.tsx @@ -1,5 +1,10 @@ +// End of third-party imports + +import { useGenerateAttachmentURLsMutation } from 'data/support/generate-attachment-urls-mutation' +import { uuidv4 } from 'lib/helpers' +import { useProfile } from 'lib/profile' import { compact } from 'lodash' -import { Plus, X } from 'lucide-react' +import { File, Plus, X } from 'lucide-react' import { useCallback, useEffect, @@ -10,12 +15,8 @@ import { type RefObject, } from 'react' import { toast } from 'sonner' -// End of third-party imports +import { cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui' -import { useGenerateAttachmentURLsMutation } from 'data/support/generate-attachment-urls-mutation' -import { uuidv4 } from 'lib/helpers' -import { useProfile } from 'lib/profile' -import { cn } from 'ui' import { createSupportStorageClient } from './support-storage-client' const MAX_ATTACHMENTS = 5 @@ -26,7 +27,7 @@ const uploadAttachments = async ({ userId, files }: { userId: string; files: Fil const filesToUpload = Array.from(files) const uploadedFiles = await Promise.all( filesToUpload.map(async (file) => { - const suffix = file.type.split('/')[1] + const suffix = file.name.endsWith('.har') ? 'har' : file.type.split('/')[1] const prefix = `${userId}/${uuidv4()}.${suffix}` const options = { cacheControl: '3600' } @@ -87,7 +88,13 @@ export function useAttachmentUpload() { useEffect(() => { if (!uploadedFiles) return - const objectUrls = uploadedFiles.map((file) => URL.createObjectURL(file)) + const objectUrls = uploadedFiles.map((file) => { + if (file.name.endsWith('.har')) { + return file.name + } else { + return URL.createObjectURL(file) + } + }) setUploadedDataUrls(objectUrls) return () => { @@ -160,8 +167,8 @@ export function AttachmentUploadDisplay({

Attachments

- Upload up to {MAX_ATTACHMENTS} screenshots that might be relevant to the issue that you're - facing + Upload up to {MAX_ATTACHMENTS} images or HAR files that might be relevant to the issue + that you're facing

- {uploadedDataUrls.map((url, idx) => ( -
- -
- ))} + {uploadedDataUrls.map((url, idx) => { + if (url.endsWith('.har')) { + return ( +
+ + e.preventDefault()}> +
+ +

HAR

+
+
+ {url} +
+ + +
+ ) + } else { + return ( +
+ +
+ ) + } + })} {!isFull && (