-
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: Create crud interface for models
- Loading branch information
1 parent
2be59ef
commit 235c9ef
Showing
16 changed files
with
707 additions
and
31 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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { PlusIcon } from "lucide-react"; | ||
import { useState } from "react"; | ||
|
||
import { ModelForm } from "~/components/model/ModelForm"; | ||
import { Button } from "~/components/ui/button"; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from "~/components/ui/dialog"; | ||
|
||
export function CreateModel() { | ||
const [open, setOpen] = useState(false); | ||
|
||
return ( | ||
<Dialog open={open} onOpenChange={setOpen}> | ||
<DialogTrigger asChild> | ||
<Button variant="outline" startContent={<PlusIcon />}> | ||
Create Model | ||
</Button> | ||
</DialogTrigger> | ||
|
||
<DialogContent> | ||
<DialogTitle>Create Model</DialogTitle> | ||
<DialogDescription hidden>Create Model</DialogDescription> | ||
|
||
<ModelForm onSubmit={() => setOpen(false)} /> | ||
</DialogContent> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { TrashIcon } from "lucide-react"; | ||
import { mutate } from "swr"; | ||
|
||
import { ModelApiService } from "~/lib/service/api/modelApiService"; | ||
|
||
import { ConfirmationDialog } from "~/components/composed/ConfirmationDialog"; | ||
import { Button } from "~/components/ui/button"; | ||
import { | ||
Tooltip, | ||
TooltipContent, | ||
TooltipProvider, | ||
TooltipTrigger, | ||
} from "~/components/ui/tooltip"; | ||
import { useAsync } from "~/hooks/useAsync"; | ||
|
||
type DeleteModelProps = { | ||
id: string; | ||
}; | ||
|
||
export function DeleteModel(props: DeleteModelProps) { | ||
const deleteModel = useAsync(ModelApiService.deleteModel, { | ||
onSuccess: () => mutate(ModelApiService.getModels.key()), | ||
}); | ||
|
||
return ( | ||
<TooltipProvider> | ||
<Tooltip> | ||
<ConfirmationDialog | ||
title="Are you sure you want to delete this model?" | ||
description="Doing so will break any tools or agents currently using it." | ||
onConfirm={() => deleteModel.execute(props.id)} | ||
confirmProps={{ | ||
variant: "destructive", | ||
children: "Delete", | ||
}} | ||
> | ||
<TooltipTrigger asChild> | ||
<Button | ||
size="icon" | ||
variant="ghost" | ||
disabled={deleteModel.isLoading} | ||
loading={deleteModel.isLoading} | ||
> | ||
<TrashIcon /> | ||
</Button> | ||
</TooltipTrigger> | ||
</ConfirmationDialog> | ||
|
||
<TooltipContent>Delete Model</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
); | ||
} |
Oops, something went wrong.