import { ReportChart } from '@/components/report-chart'; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { cn } from '@/utils/cn'; import { CopyIcon, MoreHorizontal, Trash } from 'lucide-react'; import { timeWindows } from '@openpanel/constants'; import { useRouter } from '@tanstack/react-router'; export function ReportItemSkeleton() { return (
); } export function ReportItem({ report, organizationId, projectId, range, startDate, endDate, interval, onDelete, onDuplicate, }: { report: any; organizationId: string; projectId: string; range: any; startDate: any; endDate: any; interval: any; onDelete: (reportId: string) => void; onDuplicate: (reportId: string) => void; }) { const router = useRouter(); const chartRange = report.range; return (
{ if (event.metaKey) { window.open( `/${organizationId}/${projectId}/reports/${report.id}`, '_blank', ); return; } router.navigate({ to: '/$organizationId/$projectId/reports/$reportId', params: { organizationId, projectId, reportId: report.id, }, }); }} onKeyUp={(e) => { if (e.key === 'Enter' || e.key === ' ') { router.navigate({ to: '/$organizationId/$projectId/reports/$reportId', params: { organizationId, projectId, reportId: report.id, }, }); } }} role="button" tabIndex={0} >
{report.name}
{chartRange !== null && (
{timeWindows[chartRange as keyof typeof timeWindows]?.label} {startDate && endDate ? ( Custom dates ) : ( range !== null && chartRange !== range && ( {timeWindows[range as keyof typeof timeWindows]?.label} ) )}
)}
{ event.stopPropagation(); onDuplicate(report.id); }} > Duplicate { event.stopPropagation(); onDelete(report.id); }} > Delete
); } export function ReportItemReadOnly({ report, shareId, range, startDate, endDate, interval, }: { report: any; shareId: string; range: any; startDate: any; endDate: any; interval: any; }) { const chartRange = report.range; return (
{report.name}
{chartRange !== null && (
{timeWindows[chartRange as keyof typeof timeWindows]?.label} {startDate && endDate ? ( Custom dates ) : ( range !== null && chartRange !== range && ( {timeWindows[range as keyof typeof timeWindows]?.label} ) )}
)}
); }