From d85883164f2a0883c8053d72b7c68a3754e9e49a Mon Sep 17 00:00:00 2001 From: Oleksii Nazarenko Date: Mon, 2 Dec 2024 15:45:59 +0000 Subject: [PATCH] improved copy context menu --- .../quickLink/QuickLinkContextMenuContent.tsx | 2 +- .../contextMenuItems/CopyTextMenuItem.tsx | 6 ++- .../fileCard/contextMenu/CopyMenuSub.tsx | 38 +++++++++++++++++++ .../contextMenu/FileCardContextMenu.tsx | 6 +-- 4 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 src/features/table/fileCard/contextMenu/CopyMenuSub.tsx diff --git a/src/features/quickLinks/components/quickLink/QuickLinkContextMenuContent.tsx b/src/features/quickLinks/components/quickLink/QuickLinkContextMenuContent.tsx index 6ab7bc0..2fb9cc2 100644 --- a/src/features/quickLinks/components/quickLink/QuickLinkContextMenuContent.tsx +++ b/src/features/quickLinks/components/quickLink/QuickLinkContextMenuContent.tsx @@ -64,7 +64,7 @@ export const QuickLinkContextMenuContent = forwardRef< Edit - + { diff --git a/src/features/shared/contextMenuItems/CopyTextMenuItem.tsx b/src/features/shared/contextMenuItems/CopyTextMenuItem.tsx index 6b9de20..9922e7e 100644 --- a/src/features/shared/contextMenuItems/CopyTextMenuItem.tsx +++ b/src/features/shared/contextMenuItems/CopyTextMenuItem.tsx @@ -1,13 +1,16 @@ import { ContextMenuItem } from "@src/components/ui/context-menu" import { useToast } from "@src/components/ui/use-toast" import { CopyIcon } from "lucide-react" +import React from "react" interface CopyTextMenuItemProps { + icon?: React.ReactNode textToCopy: string name: string } export default function CopyTextMenuItem({ + icon, textToCopy, name, }: CopyTextMenuItemProps) { @@ -24,7 +27,8 @@ export default function CopyTextMenuItem({ return ( - Copy {name} + {icon || } + {name} ) } diff --git a/src/features/table/fileCard/contextMenu/CopyMenuSub.tsx b/src/features/table/fileCard/contextMenu/CopyMenuSub.tsx new file mode 100644 index 0000000..275a5d6 --- /dev/null +++ b/src/features/table/fileCard/contextMenu/CopyMenuSub.tsx @@ -0,0 +1,38 @@ +import { + ContextMenuSub, + ContextMenuSubContent, + ContextMenuSubTrigger, +} from "@src/components/ui/context-menu" +import { FullFileLink } from "@src/features/parser" +import CopyTextMenuItem from "@src/features/shared/contextMenuItems/CopyTextMenuItem" +import { CopyIcon, FileTextIcon, LinkIcon, TerminalIcon } from "lucide-react" + +export function CopyMenuSub({ fileLink }: { fileLink: FullFileLink }) { + return ( + + + Copy + + + } + name="URL" + textToCopy={fileLink.href} + /> + } + name="Name" + textToCopy={fileLink.fullName} + /> + } + name="Path" + textToCopy={ + "/cs/studres/_this_session/" + + fileLink.urlSegments.join("/") + } + /> + + + ) +} diff --git a/src/features/table/fileCard/contextMenu/FileCardContextMenu.tsx b/src/features/table/fileCard/contextMenu/FileCardContextMenu.tsx index bc798bb..2f675e3 100644 --- a/src/features/table/fileCard/contextMenu/FileCardContextMenu.tsx +++ b/src/features/table/fileCard/contextMenu/FileCardContextMenu.tsx @@ -10,9 +10,9 @@ import { } from "@src/features/files" import { FullFileLink } from "@src/features/parser" import useSmoothRouter from "@src/features/router/useSmoothRouter" -import CopyTextMenuItem from "@src/features/shared/contextMenuItems/CopyTextMenuItem" import { AddNoteContextMenuItem } from "@src/features/table/fileCard/contextMenu/AddNoteContextMenuItem" import { AddQuickLinkMenuItem } from "@src/features/table/fileCard/contextMenu/AddQuickLinkMenuItem" +import { CopyMenuSub } from "@src/features/table/fileCard/contextMenu/CopyMenuSub" import DownloadUsingScpContextMenuItem from "@src/features/table/fileCard/contextMenu/DownloadUsingScpContextMenuItem" import { FolderIcon, FolderRootIcon } from "lucide-react" import { forwardRef } from "react" @@ -62,8 +62,8 @@ const FileCardContextMenuContent = forwardRef< - - + +