File tree Expand file tree Collapse file tree 2 files changed +51
-11
lines changed
Expand file tree Collapse file tree 2 files changed +51
-11
lines changed Original file line number Diff line number Diff line change 1+ import { Button } from "@/components/ui/button" ;
2+ import { ExternalLinkIcon , MoreVertical } from "lucide-react" ;
3+ import { Id } from "../../../convex/_generated/dataModel" ;
4+ import {
5+ DropdownMenu ,
6+ DropdownMenuContent ,
7+ DropdownMenuItem ,
8+ DropdownMenuTrigger ,
9+ } from "@/components/ui/dropdown-menu" ;
10+
11+ type Props = {
12+ documentId : Id < "documents" > ;
13+ title : string ;
14+ onNewTab : ( id : Id < "documents" > ) => void ;
15+ } ;
16+
17+ export const DocumentMenu : React . FC < Props > = ( {
18+ documentId,
19+ title,
20+ onNewTab,
21+ } ) => {
22+ return (
23+ < >
24+ < DropdownMenu >
25+ < DropdownMenuTrigger asChild >
26+ < Button variant = { "ghost" } size = { "icon" } className = "rounded-full" >
27+ < MoreVertical className = "size-4" />
28+ </ Button >
29+ </ DropdownMenuTrigger >
30+ < DropdownMenuContent >
31+ < DropdownMenuItem onClick = { ( ) => onNewTab ( documentId ) } >
32+ < ExternalLinkIcon className = "size-4 mr-2" />
33+ Open in a new tab
34+ </ DropdownMenuItem >
35+ </ DropdownMenuContent >
36+ </ DropdownMenu >
37+ </ >
38+ ) ;
39+ } ;
Original file line number Diff line number Diff line change 11import { TableCell , TableRow } from "@/components/ui/table" ;
2- import {
3- Building2Icon ,
4- CircleUserIcon ,
5- FileIcon ,
6- MoreVertical ,
7- } from "lucide-react" ;
2+ import { Building2Icon , CircleUserIcon , FileIcon } from "lucide-react" ;
83
9- import { Button } from "@/components/ui/button" ;
104import { format } from "date-fns" ;
11- import { Doc } from "../../../convex/_generated/dataModel" ;
5+ import { Doc , Id } from "../../../convex/_generated/dataModel" ;
6+ import { DocumentMenu } from "./document-menu" ;
127
138type Props = {
149 document : Doc < "documents" > ;
1510} ;
1611
1712export const DocumentRow : React . FC < Props > = ( { document } ) => {
13+ const onNewTab = ( id : Id < "documents" > ) => {
14+ window . open ( `/document/${ id } ` , "_blank" ) ;
15+ } ;
16+
1817 return (
1918 < TableRow className = "cursor-pointer" >
2019 < TableCell className = "w-[50px]" >
@@ -35,9 +34,11 @@ export const DocumentRow: React.FC<Props> = ({ document }) => {
3534 </ TableCell >
3635
3736 < TableCell className = "flex ml-auto justify-end" >
38- < Button variant = { "ghost" } size = { "icon" } className = "rounded-full" >
39- < MoreVertical className = "size-4" />
40- </ Button >
37+ < DocumentMenu
38+ documentId = { document . _id }
39+ title = { document . title }
40+ onNewTab = { onNewTab }
41+ />
4142 </ TableCell >
4243 </ TableRow >
4344 ) ;
You can’t perform that action at this time.
0 commit comments