A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat: different icons
dextmorgn8f1df3ecef46
diff --git a/flowsint-web/src/components/projects/documents-list.tsx b/flowsint-web/src/components/projects/documents-list.tsxindex bc8b76bb..e34cb49c 100644--- a/flowsint-web/src/components/projects/documents-list.tsx+++ b/flowsint-web/src/components/projects/documents-list.tsx@@ -1,9 +1,9 @@"use client"-import { useState } from "react"+import { JSX, useState } from "react"import { useQuery } from "@tanstack/react-query"import { format, formatDistanceToNow } from "date-fns"-import { FileIcon, MoreHorizontal } from "lucide-react"+import { FileIcon, ImageIcon, MoreHorizontal } from "lucide-react"import { useParams } from "next/navigation"import { Button } from "@/components/ui/button"@@ -26,6 +26,11 @@ interface Document {}}+const icons: Record<string, JSX.Element> = {+ "png": <ImageIcon className="h-5 w-5 text-primary" />,+ "other": <FileIcon className="h-5 w-5 text-primary" />,+}+export function DocumentList() {const { project_id } = useParams<{ project_id: string }>()const [searchQuery, setSearchQuery] = useState("")@@ -83,7 +88,6 @@ export function DocumentList() {console.error("Error downloading file:", error)}}-if (isLoading) return (<>{Array.from({ length: 3 }).map((_, index) => (@@ -115,9 +119,9 @@ export function DocumentList() {<TableCell><buttononClick={() => isPreviewable(doc.type) && previewFile(doc.url, doc.type)}- className="flex items-center gap-2 hover:underline"+ className="flex cursor-pointer truncate text-ellipsis items-center gap-2 hover:underline">- <FileIcon className="h-5 w-5 text-primary" />+ {icons[doc.type.split("/")[1]] || <FileIcon className="h-5 w-5 text-primary" />}<span>{doc.name}</span></button></TableCell>@@ -156,7 +160,7 @@ export function DocumentList() {</TableRow>))}<Dialog open={!!previewUrl} onOpenChange={(open) => !open && setPreviewUrl(null)}>- <DialogContent className="max-w-8xl w-[90vw]">+ <DialogContent className="max-w-4xl w-[90vw]"><DialogHeader><DialogTitle>File Preview</DialogTitle><DialogDescription>Preview of your document</DialogDescription>diff --git a/flowsint-web/src/components/projects/file-upload.tsx b/flowsint-web/src/components/projects/file-upload.tsxindex 98df6d03..1498d07a 100644--- a/flowsint-web/src/components/projects/file-upload.tsx+++ b/flowsint-web/src/components/projects/file-upload.tsx@@ -5,6 +5,7 @@ import type React from "react"import { useState, useRef } from "react"import { supabase } from "@/lib/supabase/client"import { Upload, X, FileText, CheckCircle, AlertCircle } from "lucide-react"+import { sanitize } from '@/lib/utils'import { cn } from "@/lib/utils"import { Button } from "@/components/ui/button"@@ -88,7 +89,8 @@ export default function FileUploadDialog() {setFiles((prev) => prev.map((file, idx) => (idx === i ? { ...file, status: "uploading" } : file)))try {const file = files[i].file- const filePath = `${project_id}/${file.name}`+ const safeName = sanitize(file.name)+ const filePath = `${project_id}/${safeName}`// Upload file to Supabaseconst { error } = await supabase.storage.from("documents").upload(filePath, file)// Simulate progress tracking (if needed)diff --git a/flowsint-web/src/lib/utils.ts b/flowsint-web/src/lib/utils.tsindex e91b21fb..ddc0e9aa 100644--- a/flowsint-web/src/lib/utils.ts+++ b/flowsint-web/src/lib/utils.ts@@ -206,3 +206,13 @@ export const getLayoutedElements = (export default getLayoutedElements++export const sanitize = (name: string) => {+ return name+ .normalize("NFKD") // Decompose special characters (e.g., accents)+ .replace(/[\u0300-\u036f]/g, "") // Remove accent marks+ .replace(/[^a-zA-Z0-9.\-_]/g, "_") // Replace invalid characters with underscores+ .replace(/_{2,}/g, "_") // Replace multiple underscores with a single one+ .replace(/^_|_$/g, "") // Trim leading or trailing underscores+ .toLowerCase(); // Convert to lowercase for consistency+};\ No newline at end of file