From 3207264fc13c275d6dcfbd2628cc6b3974ceeaed Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Mon, 7 Apr 2025 01:03:26 +0100 Subject: feat: Allow editing bookmark details --- .../web/components/dashboard/preview/ActionBar.tsx | 25 ++++++++- .../dashboard/preview/BookmarkPreview.tsx | 10 +++- .../components/dashboard/preview/EditableTitle.tsx | 60 ---------------------- 3 files changed, 32 insertions(+), 63 deletions(-) delete mode 100644 apps/web/components/dashboard/preview/EditableTitle.tsx (limited to 'apps/web/components/dashboard/preview') diff --git a/apps/web/components/dashboard/preview/ActionBar.tsx b/apps/web/components/dashboard/preview/ActionBar.tsx index 86c86d5a..62d9c849 100644 --- a/apps/web/components/dashboard/preview/ActionBar.tsx +++ b/apps/web/components/dashboard/preview/ActionBar.tsx @@ -8,12 +8,13 @@ import { } from "@/components/ui/tooltip"; import { toast } from "@/components/ui/use-toast"; import { useTranslation } from "@/lib/i18n/client"; -import { Trash2 } from "lucide-react"; +import { Pencil, Trash2 } from "lucide-react"; import type { ZBookmark } from "@hoarder/shared/types/bookmarks"; import { useUpdateBookmark } from "@hoarder/shared-react/hooks/bookmarks"; import DeleteBookmarkConfirmationDialog from "../bookmarks/DeleteBookmarkConfirmationDialog"; +import { EditBookmarkDialog } from "../bookmarks/EditBookmarkDialog"; import { ArchivedActionIcon, FavouritedActionIcon } from "../bookmarks/icons"; export default function ActionBar({ bookmark }: { bookmark: ZBookmark }) { @@ -21,6 +22,8 @@ export default function ActionBar({ bookmark }: { bookmark: ZBookmark }) { const [deleteBookmarkDialogOpen, setDeleteBookmarkDialogOpen] = useState(false); + const [isEditBookmarkDialogOpen, setEditBookmarkDialogOpen] = useState(false); + const onError = () => { toast({ variant: "destructive", @@ -48,6 +51,26 @@ export default function ActionBar({ bookmark }: { bookmark: ZBookmark }) { return (
+ + + + + + + {t("actions.edit")} + @@ -116,7 +118,11 @@ export default function BookmarkPreview({
- +
+

+ {title === undefined || title === "" ? "Untitled" : title} +

+
{sourceUrl && ( { - toast({ - description: "Title updated!", - }); - }, - }); - - let title: string | null = null; - switch (bookmark.content.type) { - case BookmarkTypes.LINK: - title = bookmark.content.title ?? bookmark.content.url; - break; - case BookmarkTypes.TEXT: - title = null; - break; - case BookmarkTypes.ASSET: - title = bookmark.content.fileName ?? null; - break; - } - - title = bookmark.title ?? title; - if (title == "") { - title = null; - } - - return ( - { - updateBookmark( - { - bookmarkId: bookmark.id, - title: newTitle, - }, - { - onError: () => { - toast({ - description: "Something went wrong", - variant: "destructive", - }); - }, - }, - ); - }} - isSaving={isPending} - /> - ); -} -- cgit v1.2.3-70-g09d2