diff --git a/ui/litellm-dashboard/.eslintrc.json b/ui/litellm-dashboard/.eslintrc.json index 475787bed9c..ef35ae782ad 100644 --- a/ui/litellm-dashboard/.eslintrc.json +++ b/ui/litellm-dashboard/.eslintrc.json @@ -58,6 +58,7 @@ "src/components/view_logs/ToolsSection/ToolItem.tsx", "src/components/guardrails/content_filter/PatternTable.tsx", "src/components/guardrails/content_filter/ContentFilterDisplay.tsx", + "src/components/guardrails/content_filter/CategoryTable.tsx", "src/components/prompts/prompt_editor_view/PromptEditorHeader.tsx", "src/components/prompts/prompt_editor_view/VersionHistorySidePanel.tsx", "src/app/(dashboard)/teams/components/TeamsTable/ModelsCell.tsx", diff --git a/ui/litellm-dashboard/src/components/guardrails/content_filter/CategoryTable.tsx b/ui/litellm-dashboard/src/components/guardrails/content_filter/CategoryTable.tsx index 444be689f85..d06a1d34fe8 100644 --- a/ui/litellm-dashboard/src/components/guardrails/content_filter/CategoryTable.tsx +++ b/ui/litellm-dashboard/src/components/guardrails/content_filter/CategoryTable.tsx @@ -1,9 +1,23 @@ +import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table"; +import { cn } from "@/lib/utils"; +import { Trash2 } from "lucide-react"; import React from "react"; -import { Typography, Select, Table, Tag, Button } from "antd"; -import { DeleteOutlined } from "@ant-design/icons"; - -const { Text } = Typography; -const { Option } = Select; interface ContentCategory { id: string; @@ -21,6 +35,17 @@ interface CategoryTableProps { readOnly?: boolean; } +const severityBadgeClass: Record = { + high: "bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-300", + medium: "bg-amber-100 text-amber-700 dark:bg-amber-950 dark:text-amber-300", + low: "bg-yellow-100 text-yellow-700 dark:bg-yellow-950 dark:text-yellow-300", +}; + +const actionBadgeClass: Record = { + BLOCK: "bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-300", + MASK: "bg-blue-100 text-blue-700 dark:bg-blue-950 dark:text-blue-300", +}; + const CategoryTable: React.FC = ({ categories, onActionChange, @@ -28,119 +53,110 @@ const CategoryTable: React.FC = ({ onRemove, readOnly = false, }) => { - const columns = [ - { - title: "Category", - dataIndex: "display_name", - key: "display_name", - render: (displayName: string, record: ContentCategory) => ( -
- {displayName} - {displayName !== record.category && ( -
- - {record.category} - -
- )} -
- ), - }, - { - title: "Severity Threshold", - dataIndex: "severity_threshold", - key: "severity_threshold", - width: 180, - render: (severity: string, record: ContentCategory) => { - if (readOnly) { - const colorMap = { - high: "red", - medium: "orange", - low: "yellow", - } as const; - return ( - - {severity.toUpperCase()} - - ); - } - return ( - - ); - }, - }, - { - title: "Action", - dataIndex: "action", - key: "action", - width: 150, - render: (action: string, record: ContentCategory) => { - if (readOnly) { - return ( - - {action} - - ); - } - return ( - - ); - }, - }, - ]; - - if (!readOnly) { - columns.push({ - title: "", - key: "actions", - width: 100, - render: (_: any, record: ContentCategory) => ( - - ), - } as any); - } - if (categories.length === 0) { return ( -
+
No categories configured.
); } return ( - +
+
+ + + Category + Severity Threshold + Action + {!readOnly && } + + + + {categories.map((record) => ( + + +
+ {record.display_name} + {record.display_name !== record.category && ( +
+ + {record.category} + +
+ )} +
+
+ + {readOnly ? ( + + {record.severity_threshold.toUpperCase()} + + ) : ( + + )} + + + {readOnly ? ( + + {record.action} + + ) : ( + + )} + + {!readOnly && ( + + + + )} +
+ ))} +
+
+
); };