From d4b5cb25147ab3d6ce5b0cfb7f2d3b14d301d102 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 23 Apr 2026 14:09:23 +0000 Subject: [PATCH] feat(ui): KeyLifecycleSettings to shadcn - antd Select/Tooltip/Divider/Switch/Checkbox + @tremor TextInput + @ant-design InfoCircleOutlined \u2192 shadcn Select/Tooltip/Switch/ Checkbox/Input + lucide Info + native
. - Extracted a small InfoTooltip helper for the repeated info-icon pattern. - Blue auto-rotation notification callout is categorical; file added to .eslintrc.json overrides. Gates: TS \u2713 | Build \u2713. Co-authored-by: yuneng-jiang --- ui/litellm-dashboard/.eslintrc.json | 1 + .../KeyLifecycleSettings.tsx | 188 +++++++++++------- 2 files changed, 118 insertions(+), 71 deletions(-) diff --git a/ui/litellm-dashboard/.eslintrc.json b/ui/litellm-dashboard/.eslintrc.json index 9d066e44922..ae9a0137548 100644 --- a/ui/litellm-dashboard/.eslintrc.json +++ b/ui/litellm-dashboard/.eslintrc.json @@ -62,6 +62,7 @@ "src/components/Settings/RouterSettings/Fallbacks/FallbackGroupConfig.tsx", "src/components/prompts/variable_textarea.tsx", "src/components/chat/MCPCredentialsTab.tsx", + "src/components/common_components/KeyLifecycleSettings.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/common_components/KeyLifecycleSettings.tsx b/ui/litellm-dashboard/src/components/common_components/KeyLifecycleSettings.tsx index 17d65e1f66a..797b95309ed 100644 --- a/ui/litellm-dashboard/src/components/common_components/KeyLifecycleSettings.tsx +++ b/ui/litellm-dashboard/src/components/common_components/KeyLifecycleSettings.tsx @@ -1,21 +1,48 @@ import React, { useState } from "react"; -import { Select, Tooltip, Divider, Switch, Checkbox } from "antd"; -import { InfoCircleOutlined } from "@ant-design/icons"; -import { TextInput } from "@tremor/react"; - -const { Option } = Select; +import { Checkbox } from "@/components/ui/checkbox"; +import { Input } from "@/components/ui/input"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { Switch } from "@/components/ui/switch"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; +import { Info } from "lucide-react"; interface KeyLifecycleSettingsProps { - form: any; // Form instance from parent + // Form instance from parent (antd Form) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + form: any; autoRotationEnabled: boolean; onAutoRotationChange: (enabled: boolean) => void; rotationInterval: string; onRotationIntervalChange: (interval: string) => void; - isCreateMode?: boolean; // If true, shows "leave empty to never expire" instead of "-1 to never expire" + isCreateMode?: boolean; neverExpire?: boolean; onNeverExpireChange?: (checked: boolean) => void; } +const InfoTooltip: React.FC<{ children: React.ReactNode }> = ({ + children, +}) => ( + + + + + + {children} + + +); + const KeyLifecycleSettings: React.FC = ({ form, autoRotationEnabled, @@ -26,20 +53,22 @@ const KeyLifecycleSettings: React.FC = ({ neverExpire = false, onNeverExpireChange, }) => { - // Predefined intervals const predefinedIntervals = ["7d", "30d", "90d", "180d", "365d"]; - // Check if current interval is custom - const isCustomInterval = rotationInterval && !predefinedIntervals.includes(rotationInterval); + const isCustomInterval = + rotationInterval && !predefinedIntervals.includes(rotationInterval); const [showCustomInput, setShowCustomInput] = useState(isCustomInterval); - const [customInterval, setCustomInterval] = useState(isCustomInterval ? rotationInterval : ""); - const [durationValue, setDurationValue] = useState(form?.getFieldValue?.("duration") || ""); + const [customInterval, setCustomInterval] = useState( + isCustomInterval ? rotationInterval : "", + ); + const [durationValue, setDurationValue] = useState( + form?.getFieldValue?.("duration") || "", + ); const handleIntervalChange = (value: string) => { if (value === "custom") { setShowCustomInput(true); - // Don't change the actual interval yet, wait for custom input } else { setShowCustomInput(false); setCustomInterval(""); @@ -47,7 +76,9 @@ const KeyLifecycleSettings: React.FC = ({ } }; - const handleCustomIntervalChange = (e: React.ChangeEvent) => { + const handleCustomIntervalChange = ( + e: React.ChangeEvent, + ) => { const value = e.target.value; setCustomInterval(value); onRotationIntervalChange(value); @@ -61,106 +92,120 @@ const KeyLifecycleSettings: React.FC = ({ form.setFieldsValue({ duration: value }); } }; + return (
- {/* Key Expiry Section */}
- Key Expiry Settings + + Key Expiry Settings +
-
- +
- {/* Auto-Rotation Section */}
- Auto-Rotation Settings + + Auto-Rotation Settings +
-
{autoRotationEnabled && (
-