Add delete button to history items
Adds a Trash2 icon button to each conversation in the test prompt history to delete conversations via handleDeleteConversation, updating TestPrompt.tsx accordingly.
This commit is contained in:
@@ -4,7 +4,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Send, Bot, User, RotateCcw, MessageSquare, Plus } from "lucide-react";
|
||||
import { Send, Bot, User, RotateCcw, MessageSquare, Plus, Trash2 } from "lucide-react";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import {
|
||||
Select,
|
||||
@@ -188,16 +188,19 @@ export default function TestPrompt() {
|
||||
</div>
|
||||
) : (
|
||||
conversations.map((conversation) => (
|
||||
<button
|
||||
<div
|
||||
key={conversation.id}
|
||||
onClick={() => handleSelectConversation(conversation.id)}
|
||||
className={`w-full text-left p-3 rounded-lg transition-colors ${
|
||||
className={`group relative rounded-lg transition-colors ${
|
||||
currentConversationId === conversation.id
|
||||
? "bg-primary/10 border border-primary/20"
|
||||
: "hover:bg-muted"
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-start gap-2">
|
||||
<button
|
||||
onClick={() => handleSelectConversation(conversation.id)}
|
||||
className="w-full text-left p-3"
|
||||
>
|
||||
<div className="flex items-start gap-2 pr-8">
|
||||
<MessageSquare className="h-4 w-4 mt-1 flex-shrink-0 text-muted-foreground" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-sm font-medium text-foreground truncate">
|
||||
@@ -214,6 +217,18 @@ export default function TestPrompt() {
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleDeleteConversation(conversation.id);
|
||||
}}
|
||||
className="absolute right-2 top-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity"
|
||||
>
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
</Button>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user