[] = [
- {
- header: "Attachment ID",
- accessorKey: "attachment_id",
- cell: (info: any) => ,
- },
- {
- header: "Policy",
- accessorKey: "policy_name",
- cell: ({ row }) => {
- const attachment = row.original;
- return (
-
- {attachment.policy_name}
-
- );
- },
- },
- {
- header: "Scope",
- accessorKey: "scope",
- cell: ({ row }) => {
- const attachment = row.original;
- if (attachment.scope === "*") {
- return (
-
- Global (*)
-
- );
- }
- return attachment.scope ? (
- {attachment.scope}
- ) : (
- -
- );
- },
- },
- {
- header: "Teams",
- accessorKey: "teams",
- cell: ({ row }) => {
- const attachment = row.original;
- const teams = attachment.teams || [];
- if (teams.length === 0) {
- return -;
- }
- return (
-
- {teams.slice(0, 2).map((t, i) => (
-
- {t}
-
- ))}
- {teams.length > 2 && (
-
- +{teams.length - 2}
-
- )}
-
- );
- },
- },
- {
- header: "Keys",
- accessorKey: "keys",
- cell: ({ row }) => {
- const attachment = row.original;
- const keys = attachment.keys || [];
- if (keys.length === 0) {
- return -;
- }
- return (
-
- {keys.slice(0, 2).map((k, i) => (
-
- {k}
-
- ))}
- {keys.length > 2 && (
-
- +{keys.length - 2}
-
- )}
-
- );
- },
- },
- {
- header: "Models",
- accessorKey: "models",
- cell: ({ row }) => {
- const attachment = row.original;
- const models = attachment.models || [];
- if (models.length === 0) {
- return -;
- }
- return (
-
- {models.slice(0, 2).map((m, i) => (
-
- {m}
-
- ))}
- {models.length > 2 && (
-
- +{models.length - 2}
-
- )}
-
- );
- },
- },
- {
- header: "Tags",
- accessorKey: "tags",
- cell: ({ row }) => {
- const attachment = row.original;
- const tags = attachment.tags || [];
- if (tags.length === 0) {
- return -;
- }
- return (
-
- {tags.slice(0, 2).map((t, i) => (
-
- {t}
-
- ))}
- {tags.length > 2 && (
-
- +{tags.length - 2}
-
- )}
-
- );
- },
- },
- {
- header: "Created At",
- accessorKey: "created_at",
- cell: ({ row }) => ,
- },
- {
- id: "actions",
- header: "Actions",
- cell: ({ row }) => {
- const attachment = row.original;
- return (
-
-
- {isAdmin && (
-
- onDeleteClick(attachment.attachment_id)}
- className="cursor-pointer hover:text-red-500"
- />
-
- )}
-
- );
- },
- },
- ];
-
- const table = useReactTable({
- data: attachments,
- columns,
- state: {
- sorting,
- },
- onSortingChange: setSorting,
- getCoreRowModel: getCoreRowModel(),
- getSortedRowModel: getSortedRowModel(),
- enableSorting: true,
- });
-
- return (
-
-
-
-
- {table.getHeaderGroups().map((headerGroup) => (
-
- {headerGroup.headers.map((header) => (
-
-
-
- {header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
-
- {header.id !== "actions" && (
-
- {header.column.getIsSorted() ? (
- {
- asc: ,
- desc: ,
- }[header.column.getIsSorted() as string]
- ) : (
-
- )}
-
- )}
-
-
- ))}
-
- ))}
-
-
- {isLoading ? (
-
-
-
-
-
- ) : attachments.length > 0 ? (
- table.getRowModel().rows.map((row) => (
-
- {row.getVisibleCells().map((cell) => (
-
- {flexRender(cell.column.columnDef.cell, cell.getContext())}
-
- ))}
-
- ))
- ) : (
-
-
-
-
-
- )}
-
-
-
-
- );
-};
-
-export default AttachmentTable;
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.test.tsx
index 85d8c408032..3b6534ab0f0 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.test.tsx
@@ -56,21 +56,6 @@ vi.mock("./impact_popover", () => ({
default: () => ,
}));
-vi.mock("@heroicons/react/outline", () => ({
- TrashIcon: function TrashIcon() {
- return null;
- },
- SwitchVerticalIcon: function SwitchVerticalIcon() {
- return null;
- },
- ChevronUpIcon: function ChevronUpIcon() {
- return null;
- },
- ChevronDownIcon: function ChevronDownIcon() {
- return null;
- },
-}));
-
vi.mock("@tremor/react", async (importOriginal) => {
const actual = await importOriginal();
return {
@@ -95,8 +80,6 @@ vi.mock("@tremor/react", async (importOriginal) => {
onChange: (e: React.ChangeEvent) => onChange?.(e.target.checked),
className,
}),
- Icon: ({ icon: _IconComp, onClick, className }: any) =>
- React.createElement("button", { type: "button", onClick, className }, "TrashIcon"),
};
});
@@ -163,7 +146,8 @@ describe("PoliciesPanel attachment delete", () => {
expect(screen.getByText("test-policy")).toBeInTheDocument();
});
- await user.click(screen.getByRole("button", { name: /TrashIcon/i }));
+ await user.click(screen.getByTestId(`attachment-actions-${EXPECTED_ATTACHMENT_ID}`));
+ await user.click(await screen.findByTestId("attachment-action-delete"));
const dialog = await screen.findByRole("dialog", {}, { timeout: 5000 });
expect(within(dialog).getByText(/Are you sure you want to delete this attachment/i)).toBeInTheDocument();
@@ -195,7 +179,8 @@ describe("PoliciesPanel attachment delete", () => {
expect(screen.getByText("test-policy")).toBeInTheDocument();
});
- await user.click(screen.getByRole("button", { name: /TrashIcon/i }));
+ await user.click(screen.getByTestId(`attachment-actions-${EXPECTED_ATTACHMENT_ID}`));
+ await user.click(await screen.findByTestId("attachment-action-delete"));
const dialog = await screen.findByRole("dialog", {}, { timeout: 5000 });
const deleteButton = within(dialog).getByRole("button", { name: /^delete$/i });
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.tsx b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.tsx
index df55d2c386b..722d8face3d 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.tsx
@@ -9,7 +9,7 @@ import PolicyTable from "./PolicyTable";
import PolicyInfoView from "./policy_info";
import AddPolicyForm from "./add_policy_form";
import { FlowBuilderPage } from "./pipeline_flow_builder";
-import AttachmentTable from "./attachment_table";
+import AttachmentTable from "./AttachmentTable";
import AddAttachmentForm from "./add_attachment_form";
import PolicyTestPanel from "./policy_test_panel";
import PolicyTemplates from "./policy_templates";