Skip to content

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

feat(web): inline edit/delete action icons for datasets, evaluators, and annotation queues (#14335)

Tobias Wochinger8c4c2be38c0e
diff --git a/web/src/components/IconOnlyButton.tsx b/web/src/components/IconOnlyButton.tsx
new file mode 100644
index 0000000000..733c5c28f6
--- /dev/null
+++ b/web/src/components/IconOnlyButton.tsx
@@ -0,0 +1,84 @@
+import * as React from "react";
+import { Button, type ButtonProps } from "@/src/components/ui/button";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@/src/components/ui/tooltip";
+import { cn } from "@/src/utils/tailwind";
+
+export interface IconOnlyButtonProps extends Omit<
+ ButtonProps,
+ "children" | "title"
+> {
+ /** Icon glyph rendered inside the button. */
+ icon: React.ReactNode;
+ /**
+ * Accessible name for the button, shown as the hover/focus tooltip. An
+ * icon-only button has no visible text, so this is required. Also used as the
+ * `aria-label` unless one is passed explicitly.
+ */
+ label: string;
+ /**
+ * When set, the button is disabled and the tooltip shows this reason instead
+ * of the label (e.g. a missing-permission explanation).
+ */
+ disabledReason?: string;
+}
+
+/**
+ * Compact, icon-only action button with a built-in tooltip. It always renders a
+ * tooltip — the `label`, or `disabledReason` when disabled — because an icon
+ * button carries no visible text. Native disabled buttons swallow pointer
+ * events, so the tooltip trigger is the wrapping span and the button drops
+ * pointer events while disabled, letting the hover reach the span.
+ *
+ * Drive any Dialog/Popover from `onClick` (controlled open) rather than wrapping
+ * this in a Radix `*Trigger asChild`: the component's root is the tooltip, not
+ * the button, so `asChild` cloning would not reach the underlying element.
+ */
+export const IconOnlyButton = React.forwardRef<
+ HTMLButtonElement,
+ IconOnlyButtonProps
+>(function IconOnlyButton(
+ {
+ icon,
+ label,
+ disabledReason,
+ variant = "ghost",
+ size = "icon-xs",
+ disabled,
+ className,
+ "aria-label": ariaLabel,
+ ...props
+ },
+ ref,
+) {
+ const isDisabled = disabled || Boolean(disabledReason);
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span
+ className={cn("inline-flex", isDisabled && "cursor-not-allowed")}
+ // A disabled button has pointer-events-none, so a click lands on this
+ // span. Stop it so a disabled action in a clickable table row does not
+ // trigger the row's onClick (e.g. opening the peek view).
+ onClick={isDisabled ? (e) => e.stopPropagation() : undefined}
+ >
+ <Button
+ ref={ref}
+ variant={variant}
+ size={size}
+ aria-label={ariaLabel ?? label}
+ disabled={isDisabled}
+ className={cn(className, isDisabled && "pointer-events-none")}
+ {...props}
+ >
+ {icon}
+ </Button>
+ </span>
+ </TooltipTrigger>
+ <TooltipContent>{disabledReason ?? label}</TooltipContent>
+ </Tooltip>
+ );
+});
diff --git a/web/src/components/deleteButton.tsx b/web/src/components/deleteButton.tsx
index 2676a0a941..0ead276e89 100644
--- a/web/src/components/deleteButton.tsx
+++ b/web/src/components/deleteButton.tsx
@@ -2,11 +2,13 @@ import { useMemo, useState } from "react";
import { useRouter } from "next/router";
import {
Popover,
+ PopoverAnchor,
PopoverContent,
PopoverTrigger,
} from "@/src/components/ui/popover";
import { Button, type ButtonProps } from "@/src/components/ui/button";
import { LockIcon, TrashIcon } from "lucide-react";
+import { IconOnlyButton } from "@/src/components/IconOnlyButton";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { type ProjectScope } from "@/src/features/rbac/constants/projectAccessRights";
import { api } from "@/src/utils/api";
@@ -27,6 +29,7 @@ export type DeleteButtonProps = {
icon?: boolean;
enabled?: boolean;
variant?: ButtonProps["variant"];
+ size?: ButtonProps["size"];
title?: string;
className?: string;
// forwarded explicitly because the base component does not spread unknown
@@ -69,6 +72,7 @@ export function DeleteButton({
enabled = true,
title,
className,
+ size,
captureDeleteOpen,
captureDeleteSuccess,
entityToDeleteName,
@@ -80,6 +84,7 @@ export function DeleteButton({
"aria-label": ariaLabel,
}: BaseDeleteButtonProps) {
const [isDeleted, setIsDeleted] = useState(false);
+ const [open, setOpen] = useState(false);
const router = useRouter();
const capture = usePostHogClientCapture();
const [deleteConfirmationInput, setDeleteConfirmationInput] = useState("");
@@ -104,34 +109,70 @@ export function DeleteButton({
]);
return (
- <Popover key={itemId ?? "delete-action"} onOpenChange={onPopoverOpenChange}>
- <PopoverTrigger asChild>
- <Button
- variant={variant ?? (icon ? "outline-solid" : "ghost")}
- size={icon ? "icon" : "default"}
- title={title}
- aria-label={ariaLabel}
- className={className}
- disabled={!hasAccess || !enabled}
- onClick={(e) => {
- e.stopPropagation();
- captureDeleteOpen(capture, isTableAction);
- }}
- >
- {icon ? (
- <TrashIcon className="h-4 w-4" />
- ) : (
- <>
- {hasAccess ? (
- <TrashIcon className="mr-2 h-4 w-4" />
- ) : (
- <LockIcon className="mr-2 h-4 w-4" />
- )}
- Delete
- </>
- )}
- </Button>
- </PopoverTrigger>
+ <Popover
+ key={itemId ?? "delete-action"}
+ open={open}
+ onOpenChange={(o) => {
+ setOpen(o);
+ // Reset the type-to-confirm input on close so the confirmation must be
+ // re-typed each time (the component now stays mounted per table row).
+ if (!o) setDeleteConfirmationInput("");
+ onPopoverOpenChange?.(o);
+ }}
+ >
+ {icon ? (
+ // Icon-only: a compact button with a built-in tooltip; the popover is
+ // opened from onClick since the tooltip wrapper can't be a trigger.
+ <PopoverAnchor asChild>
+ <span className="inline-flex">
+ <IconOnlyButton
+ icon={<TrashIcon className="h-4 w-4" />}
+ label={title ?? "Delete"}
+ aria-label={ariaLabel ?? "delete"}
+ disabledReason={
+ hasAccess
+ ? undefined
+ : `You don't have permission to delete this ${entityToDeleteName}.`
+ }
+ variant={variant ?? "outline-solid"}
+ size={size ?? "icon"}
+ className={className}
+ disabled={!enabled}
+ onClick={(e) => {
+ e.stopPropagation();
+ captureDeleteOpen(capture, isTableAction);
+ // Opening via controlled state (PopoverAnchor, not
+ // PopoverTrigger) means Radix never echoes onOpenChange, so
+ // notify consumers explicitly.
+ setOpen(true);
+ onPopoverOpenChange?.(true);
+ }}
+ />
+ </span>
+ </PopoverAnchor>
+ ) : (
+ <PopoverTrigger asChild>
+ <Button
+ variant={variant ?? "ghost"}
+ size={size ?? "default"}
+ title={title}
+ aria-label={ariaLabel}
+ className={className}
+ disabled={!hasAccess || !enabled}
+ onClick={(e) => {
+ e.stopPropagation();
+ captureDeleteOpen(capture, isTableAction);
+ }}
+ >
+ {hasAccess ? (
+ <TrashIcon className="mr-2 h-4 w-4" />
+ ) : (
+ <LockIcon className="mr-2 h-4 w-4" />
+ )}
+ Delete
+ </Button>
+ </PopoverTrigger>
+ )}
<PopoverContent onClick={(e) => e.stopPropagation()}>
{deleteBlocker ?? (
<>
diff --git a/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsx b/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsx
index 9fb74e560a..52cfce9a6c 100644
--- a/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsx
+++ b/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsx
@@ -9,13 +9,7 @@ import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
import useColumnOrder from "@/src/features/column-visibility/hooks/useColumnOrder";
import { CreateOrEditAnnotationQueueButton } from "@/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuLabel,
- DropdownMenuTrigger,
-} from "@/src/components/ui/dropdown-menu";
-import { ClipboardPen, Lock, MoreVertical } from "lucide-react";
+import { ClipboardPen, Lock } from "lucide-react";
import { Button } from "@/src/components/ui/button";
import { cn } from "@/src/utils/tailwind";
import TableLink from "@/src/components/table/table-link";
@@ -179,28 +173,19 @@ export function AnnotationQueuesTable({ projectId }: { projectId: string }) {
cell: ({ row }) => {
const key: RowData["key"] = row.getValue("key");
return (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" className="h-8 w-8 p-0">
- <span className="sr-only">Open menu</span>
- <MoreVertical className="h-4 w-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuLabel>Actions</DropdownMenuLabel>
- <div className="flex flex-col space-y-0.5">
- <CreateOrEditAnnotationQueueButton
- projectId={projectId}
- queueId={key.id}
- variant="ghost"
- />
- <DeleteAnnotationQueueButton
- projectId={projectId}
- queueId={key.id}
- />
- </div>
- </DropdownMenuContent>
- </DropdownMenu>
+ <div className="flex items-center gap-1">
+ <CreateOrEditAnnotationQueueButton
+ projectId={projectId}
+ queueId={key.id}
+ variant="ghost"
+ size="icon-xs"
+ isTableAction
+ />
+ <DeleteAnnotationQueueButton
+ projectId={projectId}
+ queueId={key.id}
+ />
+ </div>
);
},
},
diff --git a/web/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx b/web/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx
index 16565ec3ad..176cd15343 100644
--- a/web/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx
+++ b/web/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx
@@ -21,7 +21,7 @@ import {
import { Input } from "@/src/components/ui/input";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { zodResolver } from "@hookform/resolvers/zod";
-import { Edit, PlusIcon } from "lucide-react";
+import { Edit, Pen, PlusIcon } from "lucide-react";
import { useForm } from "react-hook-form";
import { Form } from "@/src/components/ui/form";
import { Textarea } from "@/src/components/ui/textarea";
@@ -36,6 +36,7 @@ import { useRouter } from "next/router";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { useEntitlementLimit } from "@/src/features/entitlements/hooks";
import { ActionButton } from "@/src/components/ActionButton";
+import { IconOnlyButton } from "@/src/components/IconOnlyButton";
import { DropdownMenuItem } from "@/src/components/ui/dropdown-menu";
import { useUniqueNameValidation } from "@/src/hooks/useUniqueNameValidation";
import {
@@ -53,11 +54,13 @@ export const CreateOrEditAnnotationQueueButton = ({
queueId,
variant = "secondary",
size,
+ isTableAction = false,
}: {
projectId: string;
queueId?: string;
variant?: ButtonProps["variant"];
size?: ButtonProps["size"];
+ isTableAction?: boolean;
}) => {
const [isOpen, setIsOpen] = useState(false);
const [isAdvancedOpen, setIsAdvancedOpen] = useState(false);
@@ -75,7 +78,9 @@ export const CreateOrEditAnnotationQueueButton = ({
const queueQuery = api.annotationQueues.byId.useQuery(
{ projectId, queueId: queueId as string },
- { enabled: !!queueId && hasQueueAccess },
+ // Only needed once the edit dialog is open; otherwise this fires for every
+ // row that eagerly mounts the inline table-action button.
+ { enabled: !!queueId && hasQueueAccess && isOpen },
);
const form = useForm({
@@ -83,6 +88,9 @@ export const CreateOrEditAnnotationQueueButton = ({
});
useEffect(() => {
+ // Re-seed when the dialog opens so reopening discards any unsaved edits;
+ // the component now stays mounted per table row instead of remounting.
+ if (!isOpen) return;
if (queueId && queueQuery.data) {
form.reset({
name: queueQuery.data.name,
@@ -100,7 +108,7 @@ export const CreateOrEditAnnotationQueueButton = ({
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [queueId, queueQuery.data]);
+ }, [queueId, queueQuery.data, isOpen]);
const utils = api.useUtils();
@@ -111,7 +119,9 @@ export const CreateOrEditAnnotationQueueButton = ({
const queueCountData = api.annotationQueues.count.useQuery(
{ projectId },
- { enabled: hasQueueAccess },
+ // The count only feeds the create button's limit check; skip it when
+ // editing (e.g. the per-row table action button) where it goes unused.
+ { enabled: hasQueueAccess && !queueId },
);
const configsData = api.scoreConfigs.all.useQuery(
@@ -210,31 +220,57 @@ export const CreateOrEditAnnotationQueueButton = ({
}
};
+ // Table rows render a compact icon button and rely on the disabled state plus
+ // a tooltip; everywhere else uses the labeled ActionButton with its built-in
+ // access/limit messaging.
+ const triggerButton = isTableAction ? (
+ <IconOnlyButton
+ icon={<Pen className="h-4 w-4" />}
+ label="Edit"
+ aria-label="edit"
+ disabledReason={
+ hasQueueAccess
+ ? undefined
+ : "You don't have permission to edit this queue."
+ }
+ onClick={(event) => {
+ event.stopPropagation();
+ setIsOpen(true);
+ }}
+ />
+ ) : (
+ <ActionButton
+ variant={variant}
+ onClick={() => setIsOpen(true)}
+ className="justify-start"
+ icon={
+ queueId ? (
+ <Edit className="h-4 w-4" aria-hidden="true" />
+ ) : (
+ <PlusIcon className="h-4 w-4" aria-hidden="true" />
+ )
+ }
+ hasAccess={hasQueueAccess}
+ limitValue={queueCountData.data}
+ limit={queueLimit}
+ size={size}
+ >
+ <span className="ml-1 text-sm font-normal">
+ {queueId ? "Edit" : "New queue"}
+ </span>
+ </ActionButton>
+ );
+
return (
<Dialog open={isOpen} onOpenChange={setIsOpen}>
- <DialogTrigger asChild>
- <ActionButton
- variant={variant}
- onClick={() => setIsOpen(true)}
- className="justify-start"
- icon={
- queueId ? (
- <Edit className="h-4 w-4" aria-hidden="true" />
- ) : (
- <PlusIcon className="h-4 w-4" aria-hidden="true" />
- )
- }
- hasAccess={hasQueueAccess}
- limitValue={queueCountData.data}
- limit={queueLimit}
- size={size}
- >
- <span className="ml-1 text-sm font-normal">
- {queueId ? "Edit" : "New queue"}
- </span>
- </ActionButton>
- </DialogTrigger>
- {configsData.data && (
+ {isTableAction ? (
+ triggerButton
+ ) : (
+ <DialogTrigger asChild>{triggerButton}</DialogTrigger>
+ )}
+ {/* For an edit, also wait for the queue data so the form opens populated
+ rather than briefly showing empty fields while byId loads. */}
+ {configsData.data && (!queueId || queueQuery.data) && (
<DialogContent className="max-h-[90vh] overflow-y-auto">
<DialogHeader>
<DialogTitle>
diff --git a/web/src/features/annotation-queues/components/DeleteAnnotationQueueButton.tsx b/web/src/features/annotation-queues/components/DeleteAnnotationQueueButton.tsx
index 348a54a75e..344d63ea33 100644
--- a/web/src/features/annotation-queues/components/DeleteAnnotationQueueButton.tsx
+++ b/web/src/features/annotation-queues/components/DeleteAnnotationQueueButton.tsx
@@ -1,17 +1,5 @@
-import { Button } from "@/src/components/ui/button";
-import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogFooter,
- DialogHeader,
- DialogTitle,
- DialogTrigger,
-} from "@/src/components/ui/dialog";
-import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
+import { DeleteButton } from "@/src/components/deleteButton";
import { api } from "@/src/utils/api";
-import { LockIcon, Trash } from "lucide-react";
-import React, { useState } from "react";
type DeleteAnnotationQueueButtonProps = {
projectId: string;
@@ -22,70 +10,33 @@ export const DeleteAnnotationQueueButton = ({
projectId,
queueId,
}: DeleteAnnotationQueueButtonProps) => {
- const [isOpen, setIsOpen] = useState(false);
- const hasAccess = useHasProjectAccess({
- projectId: projectId,
- scope: "annotationQueues:CUD",
- });
const utils = api.useUtils();
- const mutDelete = api.annotationQueues.delete.useMutation({
- onSuccess: () => {
- utils.annotationQueues.invalidate();
- },
- });
+ const deleteMutation = api.annotationQueues.delete.useMutation();
- const button = (
- <Button variant="ghost" disabled={!hasAccess}>
- <div className="flex w-full flex-row items-center gap-1">
- {hasAccess ? (
- <Trash className="mr-1.5 -ml-0.5 h-4 w-4" />
- ) : (
- <LockIcon className="mr-1.5 -ml-0.5 h-4 w-4" aria-hidden="true" />
- )}
- <span className="text-sm font-normal">Delete</span>
- </div>
- </Button>
- );
-
- return hasAccess ? (
- <Dialog
- open={isOpen}
- onOpenChange={(open) => {
- if (!mutDelete.isPending) {
- setIsOpen(open);
- }
+ return (
+ <DeleteButton
+ itemId={queueId}
+ projectId={projectId}
+ scope="annotationQueues:CUD"
+ invalidateFunc={() => utils.annotationQueues.invalidate()}
+ isTableAction
+ icon
+ variant="ghost"
+ size="icon-xs"
+ title="Delete"
+ aria-label="delete"
+ captureDeleteOpen={() => undefined}
+ captureDeleteSuccess={() => undefined}
+ customDeletePrompt="This action cannot be undone and removes queue items attached to this queue. Scores added while annotating in this queue will not be deleted."
+ entityToDeleteName="annotation queue"
+ executeDeleteMutation={async (onSuccess) => {
+ await deleteMutation.mutateAsync({
+ projectId,
+ queueId,
+ });
+ onSuccess();
}}
- >
- <DialogTrigger asChild>{button}</DialogTrigger>
- <DialogContent className="overflow-hidden sm:max-w-xl">
- <DialogHeader>
- <DialogTitle className="mb-4">Please confirm</DialogTitle>
- <DialogDescription className="text-md p-0">
- This action cannot be undone and removes queue items attached to
- this queue. Scores added while annotating in this queue will not be
- deleted.
- </DialogDescription>
- </DialogHeader>
- <DialogFooter>
- <Button
- variant="destructive"
- loading={mutDelete.isPending}
- disabled={mutDelete.isPending}
- onClick={async (event) => {
- event.preventDefault();
- await mutDelete.mutateAsync({
- projectId,
- queueId,
- });
- setIsOpen(false);
- }}
- >
- Delete Annotation Queue
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- ) : (
- button
+ isDeleteMutationLoading={deleteMutation.isPending}
+ />
);
};
diff --git a/web/src/features/datasets/components/DatasetActionButton.tsx b/web/src/features/datasets/components/DatasetActionButton.tsx
index b7a4b834f0..9be62a0a29 100644
--- a/web/src/features/datasets/components/DatasetActionButton.tsx
+++ b/web/src/features/datasets/components/DatasetActionButton.tsx
@@ -1,5 +1,5 @@
import { Button, type ButtonProps } from "@/src/components/ui/button";
-import { Edit, LockIcon, PlusIcon, Trash } from "lucide-react";
+import { Edit, LockIcon, Pen, PlusIcon, Trash } from "lucide-react";
import {
Dialog,
DialogContent,
@@ -13,6 +13,7 @@ import { DatasetForm } from "@/src/features/datasets/components/DatasetForm";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { type Prisma } from "@langfuse/shared";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
+import { IconOnlyButton } from "@/src/components/IconOnlyButton";
interface BaseDatasetButtonProps {
mode: "create" | "update" | "delete";
@@ -31,6 +32,7 @@ interface DeleteDatasetButtonProps extends BaseDatasetButtonProps {
mode: "delete";
datasetId: string;
datasetName: string;
+ icon?: boolean;
}
interface UpdateDatasetButtonProps extends BaseDatasetButtonProps {
@@ -60,86 +62,127 @@ export const DatasetActionButton = forwardRef<
scope: "datasets:CUD",
});
- return (
- <Dialog open={hasAccess && open} onOpenChange={setOpen}>
- <DialogTrigger asChild>
- {props.mode === "update" ? (
- props.icon ? (
- <Button
- ref={ref}
- variant={props.variant || "outline-solid"}
- size={props.size || "icon"}
- className={props.className}
- disabled={!hasAccess}
- onClick={() =>
- capture("datasets:update_form_open", {
- source: "dataset",
- })
- }
- >
- <Edit className="h-4 w-4" />
- </Button>
+ const actionButton =
+ props.mode === "update" ? (
+ props.icon ? (
+ <IconOnlyButton
+ ref={ref}
+ icon={<Pen className="h-4 w-4" />}
+ label="Edit"
+ aria-label="edit"
+ disabledReason={
+ hasAccess
+ ? undefined
+ : "You don't have permission to edit this dataset."
+ }
+ variant={props.variant}
+ size={props.size}
+ className={props.className}
+ onClick={(e) => {
+ e.stopPropagation();
+ setOpen(true);
+ capture("datasets:update_form_open", {
+ source: "table-single-row",
+ });
+ }}
+ />
+ ) : (
+ <Button
+ ref={ref}
+ variant={props.variant || "ghost"}
+ size={props.size || "icon"}
+ className={props.className}
+ disabled={!hasAccess}
+ onClick={() => {
+ setOpen(true);
+ capture("datasets:update_form_open", {
+ source: "table-single-row",
+ });
+ }}
+ >
+ {hasAccess ? (
+ <Edit className="mr-2 h-4 w-4" />
) : (
- <Button
- ref={ref}
- variant={props.variant || "ghost"}
- size={props.size || "icon"}
- className={props.className}
- disabled={!hasAccess}
- onClick={() => {
- setOpen(true);
- capture("datasets:update_form_open", {
- source: "table-single-row",
- });
- }}
- >
- {hasAccess ? (
- <Edit className="mr-2 h-4 w-4" />
- ) : (
- <LockIcon className="mr-2 h-4 w-4" aria-hidden="true" />
- )}
- Edit
- </Button>
- )
- ) : props.mode === "delete" ? (
- <Button
- ref={ref}
- variant={props.variant || "ghost"}
- size={props.size}
- className={props.className}
- disabled={!hasAccess}
- onClick={() => {
- setOpen(true);
- capture("datasets:delete_form_open", {
- source: "table-single-row",
- });
- }}
- >
- {hasAccess ? (
- <Trash className="mr-2 h-4 w-4" />
- ) : (
- <LockIcon className="mr-2 h-4 w-4" aria-hidden="true" />
- )}
- Delete
- </Button>
+ <LockIcon className="mr-2 h-4 w-4" aria-hidden="true" />
+ )}
+ Edit
+ </Button>
+ )
+ ) : props.mode === "delete" ? (
+ props.icon ? (
+ <IconOnlyButton
+ ref={ref}
+ icon={<Trash className="h-4 w-4" />}
+ label="Delete"
+ aria-label="delete"
+ disabledReason={
+ hasAccess
+ ? undefined
+ : "You don't have permission to delete this dataset."
+ }
+ variant={props.variant}
+ size={props.size}
+ className={props.className}
+ onClick={(e) => {
+ e.stopPropagation();
+ setOpen(true);
+ capture("datasets:delete_form_open", {
+ source: "table-single-row",
+ });
+ }}
+ />
+ ) : (
+ <Button
+ ref={ref}
+ variant={props.variant || "ghost"}
+ size={props.size}
+ className={props.className}
+ disabled={!hasAccess}
+ onClick={(e) => {
+ e.stopPropagation();
+ setOpen(true);
+ capture("datasets:delete_form_open", {
+ source: "table-single-row",
+ });
+ }}
+ >
+ {hasAccess ? (
+ <Trash className="mr-2 h-4 w-4" />
+ ) : (
+ <LockIcon className="mr-2 h-4 w-4" aria-hidden="true" />
+ )}
+ Delete
+ </Button>
+ )
+ ) : (
+ <Button
+ ref={ref}
+ size={props.size}
+ className={props.className}
+ disabled={!hasAccess}
+ onClick={() => capture("datasets:new_form_open")}
+ variant={props.variant || "default"}
+ >
+ {hasAccess ? (
+ <PlusIcon className="mr-1.5 -ml-0.5 h-4 w-4" aria-hidden="true" />
) : (
- <Button
- ref={ref}
- size={props.size}
- className={props.className}
- disabled={!hasAccess}
- onClick={() => capture("datasets:new_form_open")}
- variant={props.variant || "default"}
- >
- {hasAccess ? (
- <PlusIcon className="mr-1.5 -ml-0.5 h-4 w-4" aria-hidden="true" />
- ) : (
- <LockIcon className="mr-1.5 -ml-0.5 h-3 w-3" aria-hidden="true" />
- )}
- New dataset
- </Button>
+ <LockIcon className="mr-1.5 -ml-0.5 h-3 w-3" aria-hidden="true" />
)}
- </DialogTrigger>
+ New dataset
+ </Button>
+ );
+
+ // Icon-only buttons carry their own tooltip and open the dialog via onClick,
+ // so they are rendered directly rather than as an asChild dialog trigger.
+ const isIconMode = props.mode !== "create" && props.icon;
+
+ return (
+ <Dialog open={hasAccess && open} onOpenChange={setOpen}>
+ {isIconMode ? (
+ actionButton
+ ) : (
+ <DialogTrigger asChild>{actionButton}</DialogTrigger>
+ )}
<DialogContent className="max-h-[90vh] sm:max-w-2xl md:max-w-3xl">
<DialogHeader>
<DialogTitle className="mb-4">
diff --git a/web/src/features/datasets/components/DatasetsTable.tsx b/web/src/features/datasets/components/DatasetsTable.tsx
index a7e2fcf76b..eea8ab41fb 100644
--- a/web/src/features/datasets/components/DatasetsTable.tsx
+++ b/web/src/features/datasets/components/DatasetsTable.tsx
@@ -1,21 +1,12 @@
import { DataTable } from "@/src/components/table/data-table";
import TableLink from "@/src/components/table/table-link";
import { type LangfuseColumnDef } from "@/src/components/table/types";
-import { Button } from "@/src/components/ui/button";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuTrigger,
-} from "@/src/components/ui/dropdown-menu";
import { DatasetActionButton } from "@/src/features/datasets/components/DatasetActionButton";
import { DatasetSchemaHoverCard } from "@/src/features/datasets/components/DatasetSchemaHoverCard";
import { useDetailPageLists } from "@/src/features/navigate-detail-pages/context";
import { api } from "@/src/utils/api";
import { withDefault, useQueryParam, StringParam } from "use-query-params";
import { type RouterOutput } from "@/src/utils/types";
-import { MoreVertical } from "lucide-react";
import { useEffect, useMemo } from "react";
import useColumnVisibility from "@/src/features/column-visibility/hooks/useColumnVisibility";
import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
@@ -261,42 +252,32 @@ export function DatasetsTable(props: { projectId: string }) {
}
return (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" className="h-8 w-8 p-0">
- <span className="sr-only">Open menu</span>
- <MoreVertical className="h-4 w-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent
- align="end"
- className="flex flex-col *:w-full *:justify-start"
- >
- <DropdownMenuLabel>Actions</DropdownMenuLabel>
- <DropdownMenuItem asChild>
- <DatasetActionButton
- mode="update"
- projectId={props.projectId}
- datasetId={key.id}
- datasetName={row.original.folderPath}
- datasetDescription={row.getValue("description") ?? undefined}
- datasetMetadata={row.getValue("metadata") ?? undefined}
- datasetInputSchema={row.original.inputSchema ?? undefined}
- datasetExpectedOutputSchema={
- row.original.expectedOutputSchema ?? undefined
- }
- />
- </DropdownMenuItem>
- <DropdownMenuItem asChild>
- <DatasetActionButton
- mode="delete"
- projectId={props.projectId}
- datasetId={key.id}
- datasetName={row.original.folderPath}
- />
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
+ <div className="flex items-center gap-1">
+ <DatasetActionButton
+ mode="update"
+ projectId={props.projectId}
+ datasetId={key.id}
+ datasetName={row.original.folderPath}
+ datasetDescription={row.getValue("description") ?? undefined}
+ datasetMetadata={row.getValue("metadata") ?? undefined}
+ datasetInputSchema={row.original.inputSchema ?? undefined}
+ datasetExpectedOutputSchema={
+ row.original.expectedOutputSchema ?? undefined
+ }
+ icon
+ variant="ghost"
+ size="icon-xs"
+ />
+ <DatasetActionButton
+ mode="delete"
+ projectId={props.projectId}
+ datasetId={key.id}
+ datasetName={row.original.folderPath}
+ icon
+ variant="ghost"
+ size="icon-xs"
+ />
+ </div>
);
},
},
diff --git a/web/src/features/evals/components/evaluator-table.tsx b/web/src/features/evals/components/evaluator-table.tsx
index 879ed02acb..0f75f77e44 100644
--- a/web/src/features/evals/components/evaluator-table.tsx
+++ b/web/src/features/evals/components/evaluator-table.tsx
@@ -24,18 +24,12 @@ import {
} from "@/src/features/evals/utils/typeHelpers";
import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";
import TableIdOrName from "@/src/components/table/table-id";
-import { MoreVertical, ExternalLinkIcon, Edit, Info } from "lucide-react";
+import { ExternalLinkIcon, Info, Pen } from "lucide-react";
import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";
import { TablePeekViewEvaluatorConfigDetail } from "@/src/components/table/peek/peek-evaluator-config-detail";
import { evalConfigTargetValues } from "@/src/server/api/definitions/evalConfigsTable";
-import {
- DropdownMenu,
- DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuContent,
- DropdownMenuTrigger,
-} from "@/src/components/ui/dropdown-menu";
import { Button } from "@/src/components/ui/button";
+import { IconOnlyButton } from "@/src/components/IconOnlyButton";
import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";
import {
Dialog,
@@ -371,42 +365,34 @@ export default function EvaluatorTable({ projectId }: { projectId: string }) {
cell: ({ row }) => {
const id = row.original.id;
return (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- variant="ghost"
- className="h-8 w-8 p-0"
- aria-label="actions"
- >
- <span className="sr-only relative">Open menu</span>
- <MoreVertical className="h-4 w-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuLabel>Actions</DropdownMenuLabel>
- <DropdownMenuItem
- key={id}
- aria-label="edit"
- disabled={!hasAccess}
- onClick={(e) => {
- e.stopPropagation();
- if (id) setEditConfigId(id);
- }}
- >
- <Edit className="mr-2 h-4 w-4" />
- Edit
- </DropdownMenuItem>
- <DropdownMenuItem asChild>
- <DeleteEvalConfigButton
- aria-label="delete"
- itemId={id}
- projectId={projectId}
- redirectUrl={`/project/${projectId}/evals`}
- deleteConfirmation={row.original.scoreName}
- />
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
+ <div className="flex items-center gap-1">
+ <IconOnlyButton
+ key={id}
+ icon={<Pen className="h-4 w-4" />}
+ label="Edit"
+ aria-label="edit"
+ disabledReason={
+ hasAccess
+ ? undefined
+ : "You don't have permission to edit this evaluator."
+ }
+ onClick={(e) => {
+ e.stopPropagation();
+ if (id) setEditConfigId(id);
+ }}
+ />
+ <DeleteEvalConfigButton
+ aria-label="delete"
+ itemId={id}
+ projectId={projectId}
+ isTableAction
+ deleteConfirmation={row.original.scoreName}
+ icon
+ variant="ghost"
+ size="icon-xs"
+ title="Delete"
+ />
+ </div>
);
},
}),
@@ -426,7 +412,7 @@ export default function EvaluatorTable({ projectId }: { projectId: string }) {
detailNavigationKey: "evals",
peekEventOptions: {
ignoredSelectors: [
- "[aria-label='edit'], [aria-label='actions'], [aria-label='view-logs'], [aria-label='delete']",
+ "[aria-label='edit'], [aria-label='view-logs'], [aria-label='delete']",
],
},
...peekNavigationProps,