From 146ef5aaeb4f23c473e63bf39ceed3642dc113b9 Mon Sep 17 00:00:00 2001
From: Jamie Pine
Date: Fri, 30 Jan 2026 17:06:12 -0800
Subject: [PATCH] Add delete confirmation dialogs in HistoryTable and
SampleList components
- Implemented delete confirmation dialogs for both HistoryTable and SampleList components to enhance user experience and prevent accidental deletions.
- Added state management for handling the selected item to be deleted and the visibility of the delete dialog.
- Refactored delete handling functions to utilize the new dialog confirmation flow, improving code clarity and maintainability.
---
app/src/components/History/HistoryTable.tsx | 46 +++++++++++++++-
.../components/VoiceProfiles/SampleList.tsx | 54 +++++++++++++++++--
2 files changed, 95 insertions(+), 5 deletions(-)
diff --git a/app/src/components/History/HistoryTable.tsx b/app/src/components/History/HistoryTable.tsx
index 67abe80d..38c4361e 100644
--- a/app/src/components/History/HistoryTable.tsx
+++ b/app/src/components/History/HistoryTable.tsx
@@ -45,6 +45,8 @@ export function HistoryTable() {
const fileInputRef = useRef(null);
const [importDialogOpen, setImportDialogOpen] = useState(false);
const [selectedFile, setSelectedFile] = useState(null);
+ const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
+ const [generationToDelete, setGenerationToDelete] = useState<{ id: string; name: string } | null>(null);
const limit = 20;
const { toast } = useToast();
@@ -167,6 +169,19 @@ export function HistoryTable() {
);
};
+ const handleDeleteClick = (generationId: string, profileName: string) => {
+ setGenerationToDelete({ id: generationId, name: profileName });
+ setDeleteDialogOpen(true);
+ };
+
+ const handleDeleteConfirm = () => {
+ if (generationToDelete) {
+ deleteGeneration.mutate(generationToDelete.id);
+ setDeleteDialogOpen(false);
+ setGenerationToDelete(null);
+ }
+ };
+
const handleImportConfirm = () => {
if (selectedFile) {
importGeneration.mutate(selectedFile, {
@@ -307,7 +322,7 @@ export function HistoryTable() {
Export Package
deleteGeneration.mutate(gen.id)}
+ onClick={() => handleDeleteClick(gen.id, gen.profile_name)}
disabled={deleteGeneration.isPending}
className="text-destructive focus:text-destructive"
>
@@ -338,6 +353,35 @@ export function HistoryTable() {
>
)}
+
+
+
+
);
}