From 006a1467708fb754886f89afef1f89c4e91d9f6c Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Fri, 30 May 2025 07:23:52 +0400 Subject: [PATCH] feat: show confirmation dialog on profile deletion --- src/components/profile-data-table.tsx | 94 ++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/src/components/profile-data-table.tsx b/src/components/profile-data-table.tsx index 07610f0..bb8e07d 100644 --- a/src/components/profile-data-table.tsx +++ b/src/components/profile-data-table.tsx @@ -78,6 +78,11 @@ export function ProfilesDataTable({ React.useState(null); const [newProfileName, setNewProfileName] = React.useState(""); const [renameError, setRenameError] = React.useState(null); + const [profileToDelete, setProfileToDelete] = + React.useState(null); + const [deleteConfirmationName, setDeleteConfirmationName] = + React.useState(""); + const [deleteError, setDeleteError] = React.useState(null); const [isClient, setIsClient] = React.useState(false); // Ensure we're on the client side to prevent hydration mismatches @@ -117,6 +122,26 @@ export function ProfilesDataTable({ } }; + const handleDelete = async () => { + if (!profileToDelete || !deleteConfirmationName.trim()) return; + + if (deleteConfirmationName.trim() !== profileToDelete.name) { + setDeleteError( + "Profile name doesn't match. Please type the exact name to confirm deletion.", + ); + return; + } + + try { + await onDeleteProfile(profileToDelete); + setProfileToDelete(null); + setDeleteConfirmationName(""); + setDeleteError(null); + } catch (err) { + setDeleteError(err as string); + } + }; + const columns: ColumnDef[] = React.useMemo( () => [ { @@ -379,7 +404,10 @@ export function ProfilesDataTable({ Rename profile void onDeleteProfile(profile)} + onClick={() => { + setProfileToDelete(profile); + setDeleteConfirmationName(""); + }} className="text-red-600" disabled={!isClient || isRunning || isBrowserUpdating} > @@ -400,7 +428,6 @@ export function ProfilesDataTable({ onLaunchProfile, onKillProfile, onProxySettings, - onDeleteProfile, onChangeVersion, ], ); @@ -514,6 +541,69 @@ export function ProfilesDataTable({ + + { + if (!open) { + setProfileToDelete(null); + setDeleteConfirmationName(""); + setDeleteError(null); + } + }} + > + + + Delete Profile + + This action cannot be undone. This will permanently delete the + profile "{profileToDelete?.name}" and all its associated + data. + + +
+
+ + { + setDeleteConfirmationName(e.target.value); + setDeleteError(null); + }} + placeholder="Type the profile name here" + /> +
+ {deleteError && ( +

{deleteError}

+ )} +
+ + + + +
+
); }