From 7d0b414f1f5681dcc73254fe97cb67de4c0cb748 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 28 Sep 2025 17:49:20 +0100 Subject: feat: recursive list delete (#1989) --- .../lists/DeleteListConfirmationDialog.tsx | 44 +++++++++++++++++++--- apps/web/lib/i18n/locales/en/translation.json | 6 +++ 2 files changed, 45 insertions(+), 5 deletions(-) (limited to 'apps') diff --git a/apps/web/components/dashboard/lists/DeleteListConfirmationDialog.tsx b/apps/web/components/dashboard/lists/DeleteListConfirmationDialog.tsx index 7eb25e6d..4996ddf1 100644 --- a/apps/web/components/dashboard/lists/DeleteListConfirmationDialog.tsx +++ b/apps/web/components/dashboard/lists/DeleteListConfirmationDialog.tsx @@ -1,7 +1,11 @@ +import React from "react"; import { usePathname, useRouter } from "next/navigation"; import { ActionButton } from "@/components/ui/action-button"; import ActionConfirmingDialog from "@/components/ui/action-confirming-dialog"; +import { Label } from "@/components/ui/label"; +import { Switch } from "@/components/ui/switch"; import { toast } from "@/components/ui/use-toast"; +import { useTranslation } from "@/lib/i18n/client"; import type { ZBookmarkList } from "@karakeep/shared/types/lists"; import { useDeleteBookmarkList } from "@karakeep/shared-react/hooks/lists"; @@ -17,13 +21,15 @@ export default function DeleteListConfirmationDialog({ open: boolean; setOpen: (v: boolean) => void; }) { + const { t } = useTranslation(); const currentPath = usePathname(); const router = useRouter(); + const [deleteChildren, setDeleteChildren] = React.useState(false); const { mutate: deleteList, isPending } = useDeleteBookmarkList({ onSuccess: () => { toast({ - description: `List "${list.icon} ${list.name}" is deleted!`, + description: `List "${list.icon} ${list.name}" ${deleteChildren ? "and all its children are " : "is "} deleted!`, }); setOpen(false); if (currentPath.includes(list.id)) { @@ -42,16 +48,44 @@ export default function DeleteListConfirmationDialog({ +

+ Are you sure you want to delete {list.icon} {list.name}? +

+

+ {t("lists.delete_list.description")} +

+ +
+
+ +

+ {t("lists.delete_list.delete_children_description")} +

+
+ +
+ + } actionButton={() => ( deleteList({ listId: list.id })} + onClick={() => deleteList({ listId: list.id, deleteChildren })} > - Delete + {t("actions.delete")} )} > diff --git a/apps/web/lib/i18n/locales/en/translation.json b/apps/web/lib/i18n/locales/en/translation.json index ce8d2839..ab1306be 100644 --- a/apps/web/lib/i18n/locales/en/translation.json +++ b/apps/web/lib/i18n/locales/en/translation.json @@ -428,6 +428,12 @@ "search_query": "Search Query", "search_query_help": "Learn more about the search query language.", "description": "Description (Optional)", + "delete_list": { + "title": "Delete List", + "description": "Deleting a list doesn't delete any bookmarks in that list.", + "delete_children": "Delete children lists (recursively)", + "delete_children_description": "If not checked, all direct children lists will become root lists" + }, "rss": { "title": "RSS Feed", "description": "Enable an RSS feed for this list", -- cgit v1.2.3-70-g09d2