diff --git a/js/src/features/particles/particle-attachments.tsx b/js/src/features/particles/particle-attachments.tsx index f4e02d1..5d59abc 100644 --- a/js/src/features/particles/particle-attachments.tsx +++ b/js/src/features/particles/particle-attachments.tsx @@ -1,8 +1,9 @@ -import { Download, FileIcon } from "lucide-react"; +import { Download, ExternalLink, FileIcon } from "lucide-react"; import type { Particle } from "@/api/types"; import { useDownloadUrl } from "@/hooks/use-download-url"; import { Skeleton } from "@/components/ui/skeleton"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; +import { Button } from "@/components/ui/button"; type FileParticle = Extract; @@ -23,22 +24,37 @@ function ImageAttachment({ particle }: { particle: FileParticle }) { return ; } + const handleDownload = (e: React.MouseEvent) => { + e.stopPropagation(); + e.preventDefault(); + const a = document.createElement("a"); + a.href = url; + a.download = particle.properties.filename; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + }; + return ( e.stopPropagation()} - className="group relative block h-20 w-20 shrink-0 overflow-hidden rounded-lg bg-white/10" + className="group relative block h-30 w-40 shrink-0 overflow-hidden rounded-lg bg-white/10" > {particle.properties.filename} -
- -
+
); } @@ -46,10 +62,30 @@ function ImageAttachment({ particle }: { particle: FileParticle }) { function FileAttachment({ particle }: { particle: FileParticle }) { const { data: url } = useDownloadUrl(particle.properties.object_id); - const inner = ( -
- -
+ const handleOpen = (e: React.MouseEvent) => { + e.stopPropagation(); + if (url) window.electronLink.openExternal(url); + }; + + const handleDownload = (e: React.MouseEvent) => { + e.stopPropagation(); + if (!url) return; + const a = document.createElement("a"); + a.href = url; + a.download = particle.properties.filename; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + }; + + return ( +
+
+ {particle.properties.filename} @@ -57,24 +93,28 @@ function FileAttachment({ particle }: { particle: FileParticle }) { {formatFileSize(particle.properties.size_bytes)}
- +
+ + +
); - - if (url) { - return ( - e.stopPropagation()} - > - {inner} - - ); - } - - return inner; } export function ParticleAttachments({ attachments }: ParticleAttachmentsProps) {