From 42a897d0bb0068842b5d5c1532746bc4c6da2541 Mon Sep 17 00:00:00 2001 From: Ahmet Kilinc Date: Thu, 22 May 2025 01:16:34 +0100 Subject: [PATCH] adds context menu back --- .../context/label-sidebar-context.tsx | 5 ++- apps/mail/components/ui/nav-main.tsx | 19 +++++++++-- apps/mail/components/ui/recursive-folder.tsx | 34 ++++++++++--------- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/apps/mail/components/context/label-sidebar-context.tsx b/apps/mail/components/context/label-sidebar-context.tsx index c85611b58..1144b5d29 100644 --- a/apps/mail/components/context/label-sidebar-context.tsx +++ b/apps/mail/components/context/label-sidebar-context.tsx @@ -34,9 +34,10 @@ interface LabelAction { interface LabelSidebarContextMenuProps { children: ReactNode; labelId: string; + hide?: boolean; } -export function LabelSidebarContextMenu({ children, labelId }: LabelSidebarContextMenuProps) { +export function LabelSidebarContextMenu({ children, labelId, hide }: LabelSidebarContextMenuProps) { const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); const t = useTranslations(); const trpc = useTRPC(); @@ -54,6 +55,8 @@ export function LabelSidebarContextMenu({ children, labelId }: LabelSidebarConte }); }; + if (hide) return children; + return ( <> diff --git a/apps/mail/components/ui/nav-main.tsx b/apps/mail/components/ui/nav-main.tsx index 8a3d62f71..b85a81106 100644 --- a/apps/mail/components/ui/nav-main.tsx +++ b/apps/mail/components/ui/nav-main.tsx @@ -436,7 +436,11 @@ export function NavMain({ items }: NavMainProps) { const isMicrosoftAccount = activeAccount?.providerId === 'microsoft'; if (isMicrosoftAccount) { return data?.map((label) => ( - + )); } @@ -475,7 +479,11 @@ export function NavMain({ items }: NavMainProps) { })), }; components.push( - , + , ); }); @@ -489,6 +497,7 @@ export function NavMain({ items }: NavMainProps) { name: label.name, originalLabel: label, }} + activeAccount={activeAccount} />, ); }); @@ -505,7 +514,11 @@ export function NavMain({ items }: NavMainProps) { })), }; components.push( - , + , ); } diff --git a/apps/mail/components/ui/recursive-folder.tsx b/apps/mail/components/ui/recursive-folder.tsx index ff249af25..13fc5c307 100644 --- a/apps/mail/components/ui/recursive-folder.tsx +++ b/apps/mail/components/ui/recursive-folder.tsx @@ -1,4 +1,5 @@ import { useActiveConnection, useConnections } from '@/hooks/use-connections'; +import { LabelSidebarContextMenu } from '../context/label-sidebar-context'; import { useSearchValue } from '@/hooks/use-search-value'; import { useSidebar } from '../context/sidebar-context'; import type { Label as LabelType } from '@/types'; @@ -7,7 +8,7 @@ import { useNavigate } from 'react-router'; import { useCallback } from 'react'; import * as React from 'react'; -export const RecursiveFolder = ({ label }: { label: any }) => { +export const RecursiveFolder = ({ label, activeAccount }: { label: any; activeAccount?: any }) => { const [searchValue, setSearchValue] = useSearchValue(); const isActive = searchValue.value.includes(`label:${label.name}`); const isFolderActive = isActive || window.location.pathname.includes(`/mail/label/${label.id}`); @@ -39,11 +40,6 @@ export const RecursiveFolder = ({ label }: { label: any }) => { [searchValue, setSearchValue], ); - const activeAccount = React.useMemo(() => { - if (!activeConnection?.id || !connections?.connections) return null; - return connections.connections.find((connection) => connection.id === activeConnection?.id); - }, [activeConnection?.id, connections?.connections]); - const handleFolderClick = useCallback( (id: string) => { if (!activeAccount) return; @@ -70,17 +66,23 @@ export const RecursiveFolder = ({ label }: { label: any }) => { const hasChildren = label.labels && label.labels.length > 0; return ( - - {label.labels?.map((childLabel: any) => ( - - ))} - + + {label.labels?.map((childLabel: any) => ( + + ))} + + ); };