-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI feat: models grid - clicking row opens edit dialog
- Loading branch information
1 parent
c0c21b9
commit 3408ffe
Showing
4 changed files
with
54 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,37 @@ | ||
import { PenSquareIcon } from "lucide-react"; | ||
import { useState } from "react"; | ||
|
||
import { Model } from "~/lib/model/models"; | ||
|
||
import { ModelForm } from "~/components/model/ModelForm"; | ||
import { Button } from "~/components/ui/button"; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from "~/components/ui/dialog"; | ||
import { | ||
Tooltip, | ||
TooltipContent, | ||
TooltipProvider, | ||
TooltipTrigger, | ||
} from "~/components/ui/tooltip"; | ||
|
||
type UpdateModelProps = { | ||
model: Model; | ||
|
||
type UpdateModelDialogProps = { | ||
model: Nullish<Model>; | ||
open: boolean; | ||
setOpen: (open: boolean) => void; | ||
children?: React.ReactNode; | ||
}; | ||
|
||
export function UpdateModel(props: UpdateModelProps) { | ||
const { model } = props; | ||
const [open, setOpen] = useState(false); | ||
export function UpdateModelDialog(props: UpdateModelDialogProps) { | ||
const { model, open, setOpen, children } = props; | ||
|
||
if (!model) return null; | ||
|
||
return ( | ||
<TooltipProvider> | ||
<Tooltip> | ||
<Dialog open={open} onOpenChange={setOpen}> | ||
<DialogContent> | ||
<DialogTitle>Update model</DialogTitle> | ||
|
||
<DialogDescription hidden> | ||
Update model | ||
</DialogDescription> | ||
|
||
<ModelForm | ||
model={model} | ||
onSubmit={() => setOpen(false)} | ||
/> | ||
</DialogContent> | ||
|
||
<DialogTrigger asChild> | ||
<TooltipTrigger asChild> | ||
<Button size={"icon"} variant="ghost"> | ||
<PenSquareIcon /> | ||
</Button> | ||
</TooltipTrigger> | ||
</DialogTrigger> | ||
</Dialog> | ||
|
||
<TooltipContent>Update Model</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
<Dialog open={open} onOpenChange={setOpen}> | ||
<DialogContent> | ||
<DialogTitle>Update model</DialogTitle> | ||
|
||
<DialogDescription hidden>Update model</DialogDescription> | ||
|
||
<ModelForm model={model} onSubmit={() => setOpen(false)} /> | ||
</DialogContent> | ||
|
||
{children && <DialogTrigger asChild>{children}</DialogTrigger>} | ||
</Dialog> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters