Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(ui): improve ux across delete buttons (#2258)

Mish Ushakov9d6efbae19ec
diff --git a/web/src/components/deleteButton.tsx b/web/src/components/deleteButton.tsx
index 4cd5dd2d5c..5e732f307c 100644
--- a/web/src/components/deleteButton.tsx
+++ b/web/src/components/deleteButton.tsx
@@ -53,16 +53,13 @@ export function DeleteButton({
},
});
- if (!hasAccess) {
- return null;
- }
-
return (
<Popover key={itemId}>
<PopoverTrigger asChild>
<Button
variant={isTableAction ? "ghost" : "outline"}
size={isTableAction ? "xs" : "icon"}
+ disabled={!hasAccess}
onClick={() =>
type === "trace"
? capture("trace:delete_form_open", {
diff --git a/web/src/components/table/use-cases/models.tsx b/web/src/components/table/use-cases/models.tsx
index e7bf53714f..5e0e1237e0 100644
--- a/web/src/components/table/use-cases/models.tsx
+++ b/web/src/components/table/use-cases/models.tsx
@@ -1,6 +1,12 @@
import { DataTable } from "@/src/components/table/data-table";
import { type LangfuseColumnDef } from "@/src/components/table/types";
import { Button } from "@/src/components/ui/button";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/src/components/ui/popover";
+import { useState } from "react";
import useColumnVisibility from "@/src/features/column-visibility/hooks/useColumnVisibility";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { useHasAccess } from "@/src/features/rbac/utils/checkAccess";
@@ -222,13 +228,12 @@ export default function ModelTable({ projectId }: { projectId: string }) {
accessorKey: "actions",
header: "Actions",
cell: ({ row }) => {
- return row.original.maintainer === "User" ? (
+ return (
<DeleteModelButton
projectId={projectId}
modelId={row.original.modelId}
+ isBuiltIn={row.original.maintainer === "Langfuse"}
/>
- ) : (
- <div className="h-6" />
);
},
},
@@ -287,10 +292,13 @@ export default function ModelTable({ projectId }: { projectId: string }) {
const DeleteModelButton = ({
modelId,
projectId,
+ isBuiltIn,
}: {
modelId: string;
projectId: string;
+ isBuiltIn?: boolean;
}) => {
+ const [isOpen, setIsOpen] = useState(false);
const utils = api.useUtils();
const capture = usePostHogClientCapture();
const mut = api.models.delete.useMutation({
@@ -304,32 +312,44 @@ const DeleteModelButton = ({
scope: "models:CUD",
});
- if (!hasAccess) {
- return null;
- }
-
return (
- <Button
- size="xs"
- variant="ghost"
- onClick={() => {
- const confirmDelete = window.confirm(
- "Are you sure you want to delete this model?",
- );
- if (confirmDelete) {
- capture("models:delete_button_click");
- mut
- .mutateAsync({
- projectId,
- modelId,
- })
- .catch((error) => {
- console.error(error);
- });
- }
- }}
- >
- <Trash size={14} />
- </Button>
+ <Popover open={isOpen} onOpenChange={() => setIsOpen(!isOpen)}>
+ <PopoverTrigger asChild>
+ <Button
+ variant="ghost"
+ size="xs"
+ disabled={!hasAccess || isBuiltIn}
+ title={
+ isBuiltIn ? "Built-in models cannot be deleted" : "Delete model"
+ }
+ >
+ <Trash className="h-4 w-4" />
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent>
+ <h2 className="text-md mb-3 font-semibold">Please confirm</h2>
+ <p className="mb-3 text-sm">
+ This action permanently deletes this model definition.
+ </p>
+ <div className="flex justify-end space-x-4">
+ <Button
+ type="button"
+ variant="destructive"
+ loading={mut.isLoading}
+ onClick={() => {
+ capture("models:delete_button_click");
+ mut.mutateAsync({
+ projectId,
+ modelId,
+ });
+
+ setIsOpen(false);
+ }}
+ >
+ Delete Model
+ </Button>
+ </div>
+ </PopoverContent>
+ </Popover>
);
};
diff --git a/web/src/ee/features/evals/components/eval-config-detail.tsx b/web/src/ee/features/evals/components/eval-config-detail.tsx
index 15072fb252..4e5e1d1123 100644
--- a/web/src/ee/features/evals/components/eval-config-detail.tsx
+++ b/web/src/ee/features/evals/components/eval-config-detail.tsx
@@ -11,7 +11,7 @@ import {
PopoverTrigger,
} from "@/src/components/ui/popover";
import { useState } from "react";
-import { Trash2 } from "lucide-react";
+import { Trash } from "lucide-react";
import {
Tabs,
TabsContent,
@@ -156,7 +156,7 @@ export function DeactivateConfig({
disabled={!hasAccess || config?.status !== "ACTIVE"}
loading={isLoading}
>
- <Trash2 className="h-5 w-5" />
+ <Trash className="h-5 w-5" />
</Button>
</PopoverTrigger>
<PopoverContent>
diff --git a/web/src/ee/features/playground/page/components/PromptVariableComponent.tsx b/web/src/ee/features/playground/page/components/PromptVariableComponent.tsx
index 2b7b6cf350..d21867edaa 100644
--- a/web/src/ee/features/playground/page/components/PromptVariableComponent.tsx
+++ b/web/src/ee/features/playground/page/components/PromptVariableComponent.tsx
@@ -1,5 +1,5 @@
import { type ChangeEvent } from "react";
-import { CheckCircle2, Circle, Trash2Icon } from "lucide-react";
+import { CheckCircle2, Circle, TrashIcon } from "lucide-react";
import { Button } from "@/src/components/ui/button";
import { Textarea } from "@/src/components/ui/textarea";
import { type PromptVariable } from "@langfuse/shared";
@@ -46,7 +46,7 @@ export const PromptVariableComponent: React.FC<{
onClick={handleDeleteVariable}
className="p-0"
>
- {!isUsed && <Trash2Icon size={16} />}
+ {!isUsed && <TrashIcon size={16} />}
</Button>
</div>
<Textarea
diff --git a/web/src/features/manual-scoring/components/CreateScoreConfigButton.tsx b/web/src/features/manual-scoring/components/CreateScoreConfigButton.tsx
index 211e072488..6af776e9db 100644
--- a/web/src/features/manual-scoring/components/CreateScoreConfigButton.tsx
+++ b/web/src/features/manual-scoring/components/CreateScoreConfigButton.tsx
@@ -9,7 +9,7 @@ import {
DialogTitle,
DialogTrigger,
} from "@/src/components/ui/dialog";
-import { PlusIcon, Trash2 } from "lucide-react";
+import { PlusIcon, Trash } from "lucide-react";
import { useFieldArray, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import {
@@ -315,7 +315,7 @@ export function CreateScoreConfigButton({ projectId }: { projectId: string }) {
index === 0 || index !== fields.length - 1
}
>
- <Trash2 className="h-4 w-4" />
+ <Trash className="h-4 w-4" />
</Button>
)}
</div>
diff --git a/web/src/features/prompts/components/delete-prompt-version.tsx b/web/src/features/prompts/components/delete-prompt-version.tsx
index 11363302e1..842234cfab 100644
--- a/web/src/features/prompts/components/delete-prompt-version.tsx
+++ b/web/src/features/prompts/components/delete-prompt-version.tsx
@@ -1,7 +1,7 @@
import { Button } from "@/src/components/ui/button";
import { useHasAccess } from "@/src/features/rbac/utils/checkAccess";
import { api } from "@/src/utils/api";
-import { Trash2 } from "lucide-react";
+import { Trash } from "lucide-react";
import { useState } from "react";
import {
Popover,
@@ -46,10 +46,6 @@ export function DeletePromptVersion({
},
});
- if (!hasAccess) {
- return null;
- }
-
return (
<Popover
key={promptVersionId}
@@ -62,8 +58,13 @@ export function DeletePromptVersion({
}}
>
<PopoverTrigger asChild>
- <Button variant="outline" type="button" size="icon">
- <Trash2 className="h-5 w-5" />
+ <Button
+ variant="outline"
+ type="button"
+ size="icon"
+ disabled={!hasAccess}
+ >
+ <Trash className="h-5 w-5" />
</Button>
</PopoverTrigger>
<PopoverContent>
diff --git a/web/src/features/prompts/components/delete-prompt.tsx b/web/src/features/prompts/components/delete-prompt.tsx
index a82d72c3b4..842c2de9a5 100644
--- a/web/src/features/prompts/components/delete-prompt.tsx
+++ b/web/src/features/prompts/components/delete-prompt.tsx
@@ -1,7 +1,7 @@
import { Button } from "@/src/components/ui/button";
import { useHasAccess } from "@/src/features/rbac/utils/checkAccess";
import { api } from "@/src/utils/api";
-import { Trash2 } from "lucide-react";
+import { Trash } from "lucide-react";
import { useState } from "react";
import {
Popover,
@@ -22,15 +22,11 @@ export function DeletePrompt({ promptName }: { promptName: string }) {
},
});
- if (!hasAccess) {
- return null;
- }
-
return (
<Popover open={isOpen} onOpenChange={() => setIsOpen(!isOpen)}>
<PopoverTrigger asChild>
- <Button variant="ghost" size="xs">
- <Trash2 className="h-4 w-4" />
+ <Button variant="ghost" size="xs" disabled={!hasAccess}>
+ <Trash className="h-4 w-4" />
</Button>
</PopoverTrigger>
<PopoverContent>