Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

feat(web): add bookmark options menu to the preview action bar

Mohamed Bassem24fb655cf1e3
diff --git a/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx b/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx
index 2006eb15..1ed6a5ac 100644
--- a/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx
+++ b/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx
@@ -87,7 +87,16 @@ function isSubsectionItem(item: ActionItemType): item is SubsectionItem {
return "items" in item;
}
-export default function BookmarkOptions({ bookmark }: { bookmark: ZBookmark }) {
+export default function BookmarkOptions({
+ bookmark,
+ hiddenActions,
+ trigger,
+}: {
+ bookmark: ZBookmark;
+ // Ids of top-level actions to leave out of the menu
+ hiddenActions?: string[];
+ trigger?: React.ReactNode;
+}) {
const { t } = useTranslation();
const linkId = bookmark.id;
const { data: session } = useSession();
@@ -481,6 +490,9 @@ export default function BookmarkOptions({ bookmark }: { bookmark: ZBookmark }) {
const visibleGroups = actionGroups
.map((group) =>
group.filter((item) => {
+ if (hiddenActions?.includes(item.id)) {
+ return false;
+ }
if (isSubsectionItem(item)) {
return item.visible && item.items.some((subItem) => subItem.visible);
}
@@ -514,12 +526,14 @@ export default function BookmarkOptions({ bookmark }: { bookmark: ZBookmark }) {
/>
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button
- variant="ghost"
- className="px-1 focus-visible:ring-0 has-[>svg]:px-1"
- >
- <MoreHorizontal className="size-6" />
- </Button>
+ {trigger ?? (
+ <Button
+ variant="ghost"
+ className="px-1 focus-visible:ring-0 has-[>svg]:px-1"
+ >
+ <MoreHorizontal className="size-6" />
+ </Button>
+ )}
</DropdownMenuTrigger>
<DropdownMenuContent
className="min-w-44"
diff --git a/apps/web/components/dashboard/preview/ActionBar.tsx b/apps/web/components/dashboard/preview/ActionBar.tsx
index 9b582981..c5f76e98 100644
--- a/apps/web/components/dashboard/preview/ActionBar.tsx
+++ b/apps/web/components/dashboard/preview/ActionBar.tsx
@@ -1,6 +1,6 @@
import { useState } from "react";
import { ActionButton } from "@/components/ui/action-button";
-import { Button } from "@/components/ui/button";
+import { Button, ButtonWithTooltip } from "@/components/ui/button";
import { toast } from "@/components/ui/sonner";
import {
Tooltip,
@@ -8,11 +8,12 @@ import {
TooltipTrigger,
} from "@/components/ui/tooltip";
import { useTranslation } from "@/lib/i18n/client";
-import { Pencil, Trash2 } from "lucide-react";
+import { MoreHorizontal, Pencil, Trash2 } from "lucide-react";
import type { ZBookmark } from "@karakeep/shared/types/bookmarks";
import { useUpdateBookmark } from "@karakeep/shared-react/hooks/bookmarks";
+import BookmarkOptions from "../bookmarks/BookmarkOptions";
import DeleteBookmarkConfirmationDialog from "../bookmarks/DeleteBookmarkConfirmationDialog";
import { EditBookmarkDialog } from "../bookmarks/EditBookmarkDialog";
import { ArchivedActionIcon, FavouritedActionIcon } from "../bookmarks/icons";
@@ -144,6 +145,22 @@ export default function ActionBar({ bookmark }: { bookmark: ZBookmark }) {
</TooltipTrigger>
<TooltipContent side="bottom">{t("actions.delete")}</TooltipContent>
</Tooltip>
+ <BookmarkOptions
+ bookmark={bookmark}
+ // Already available as buttons in this bar (or irrelevant outside the grid)
+ hiddenActions={["select", "edit", "favorite", "archive", "delete"]}
+ trigger={
+ <ButtonWithTooltip
+ tooltip={t("actions.more")}
+ delayDuration={0}
+ variant="ghost"
+ size="none"
+ className="size-8 rounded-md"
+ >
+ <MoreHorizontal className="size-[18px]" strokeWidth={1.5} />
+ </ButtonWithTooltip>
+ }
+ />
</div>
);
}