From 357ab739bf6d489a965e44352fbba1776a525461 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Wed, 24 Sep 2025 13:56:47 -0300 Subject: [PATCH] implemented dropdown menu on conversations --- frontend/components/navigation.tsx | 84 +++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 18 deletions(-) diff --git a/frontend/components/navigation.tsx b/frontend/components/navigation.tsx index 5f7d4fda..339b7d22 100644 --- a/frontend/components/navigation.tsx +++ b/frontend/components/navigation.tsx @@ -1,9 +1,11 @@ "use client"; import { + EllipsisVertical, FileText, Library, MessageSquare, + MoreHorizontal, Plus, Settings2, Trash2, @@ -13,6 +15,12 @@ import { usePathname } from "next/navigation"; import { useEffect, useRef, useState } from "react"; import { toast } from "sonner"; import { useDeleteSessionMutation } from "@/app/api/queries/useDeleteSessionMutation"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; import { type EndpointType, useChat } from "@/contexts/chat-context"; import { useKnowledgeFilter } from "@/contexts/knowledge-filter-context"; import { cn } from "@/lib/utils"; @@ -236,14 +244,30 @@ export function Navigation({ const handleDeleteConversation = ( conversation: ChatConversation, - event: React.MouseEvent, + event?: React.MouseEvent, ) => { - event.preventDefault(); - event.stopPropagation(); + if (event) { + event.preventDefault(); + event.stopPropagation(); + } setConversationToDelete(conversation); setDeleteModalOpen(true); }; + const handleContextMenuAction = ( + action: string, + conversation: ChatConversation, + ) => { + switch (action) { + case "delete": + handleDeleteConversation(conversation); + break; + // Add more actions here in the future (rename, duplicate, etc.) + default: + break; + } + }; + const confirmDeleteConversation = () => { if (conversationToDelete) { deleteSessionMutation.mutate({ @@ -409,7 +433,7 @@ export function Navigation({ + + + + + e.stopPropagation()} + > + { + e.stopPropagation(); + handleContextMenuAction( + "delete", + conversation, + ); + }} + className="cursor-pointer text-destructive focus:text-destructive" + > + + Delete conversation + + + ))