The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
[Feat] UI - Add Confirmation Modal Before Deleting Keys (#13655)
Ishaan Jaffd6fa6b60d7c4
diff --git a/ui/litellm-dashboard/package-lock.json b/ui/litellm-dashboard/package-lock.jsonindex a80d65485e9..9cb088adaf1 100644--- a/ui/litellm-dashboard/package-lock.json+++ b/ui/litellm-dashboard/package-lock.json@@ -3870,6 +3870,126 @@"node": ">= 10"}},+ "node_modules/@next/swc-darwin-x64": {+ "version": "14.2.30",+ "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.30.tgz",+ "integrity": "sha512-TyO7Wz1IKE2kGv8dwQ0bmPL3s44EKVencOqwIY69myoS3rdpO1NPg5xPM5ymKu7nfX4oYJrpMxv8G9iqLsnL4A==",+ "cpu": [+ "x64"+ ],+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-linux-arm64-gnu": {+ "version": "14.2.30",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.30.tgz",+ "integrity": "sha512-I5lg1fgPJ7I5dk6mr3qCH1hJYKJu1FsfKSiTKoYwcuUf53HWTrEkwmMI0t5ojFKeA6Vu+SfT2zVy5NS0QLXV4Q==",+ "cpu": [+ "arm64"+ ],+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-linux-arm64-musl": {+ "version": "14.2.30",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.30.tgz",+ "integrity": "sha512-8GkNA+sLclQyxgzCDs2/2GSwBc92QLMrmYAmoP2xehe5MUKBLB2cgo34Yu242L1siSkwQkiV4YLdCnjwc/Micw==",+ "cpu": [+ "arm64"+ ],+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-linux-x64-gnu": {+ "version": "14.2.30",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.30.tgz",+ "integrity": "sha512-8Ly7okjssLuBoe8qaRCcjGtcMsv79hwzn/63wNeIkzJVFVX06h5S737XNr7DZwlsbTBDOyI6qbL2BJB5n6TV/w==",+ "cpu": [+ "x64"+ ],+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-linux-x64-musl": {+ "version": "14.2.30",+ "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.30.tgz",+ "integrity": "sha512-dBmV1lLNeX4mR7uI7KNVHsGQU+OgTG5RGFPi3tBJpsKPvOPtg9poyav/BYWrB3GPQL4dW5YGGgalwZ79WukbKQ==",+ "cpu": [+ "x64"+ ],+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-win32-arm64-msvc": {+ "version": "14.2.30",+ "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.30.tgz",+ "integrity": "sha512-6MMHi2Qc1Gkq+4YLXAgbYslE1f9zMGBikKMdmQRHXjkGPot1JY3n5/Qrbg40Uvbi8//wYnydPnyvNhI1DMUW1g==",+ "cpu": [+ "arm64"+ ],+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-win32-ia32-msvc": {+ "version": "14.2.30",+ "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.30.tgz",+ "integrity": "sha512-pVZMnFok5qEX4RT59mK2hEVtJX+XFfak+/rjHpyFh7juiT52r177bfFKhnlafm0UOSldhXjj32b+LZIOdswGTg==",+ "cpu": [+ "ia32"+ ],+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 10"+ }+ },+ "node_modules/@next/swc-win32-x64-msvc": {+ "version": "14.2.30",+ "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.30.tgz",+ "integrity": "sha512-4KCo8hMZXMjpTzs3HOqOGYYwAXymXIy7PEPAXNEcEOyKqkjiDlECumrWziy+JEF0Oi4ILHGxzgQ3YiMGG2t/Lg==",+ "cpu": [+ "x64"+ ],+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 10"+ }+ },"node_modules/@nodelib/fs.scandir": {"version": "2.1.5","resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",@@ -20484,126 +20604,6 @@"type": "github","url": "https://github.com/sponsors/wooorm"}- },- "node_modules/@next/swc-darwin-x64": {- "version": "14.2.30",- "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.30.tgz",- "integrity": "sha512-TyO7Wz1IKE2kGv8dwQ0bmPL3s44EKVencOqwIY69myoS3rdpO1NPg5xPM5ymKu7nfX4oYJrpMxv8G9iqLsnL4A==",- "cpu": [- "x64"- ],- "optional": true,- "os": [- "darwin"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@next/swc-linux-arm64-gnu": {- "version": "14.2.30",- "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.30.tgz",- "integrity": "sha512-I5lg1fgPJ7I5dk6mr3qCH1hJYKJu1FsfKSiTKoYwcuUf53HWTrEkwmMI0t5ojFKeA6Vu+SfT2zVy5NS0QLXV4Q==",- "cpu": [- "arm64"- ],- "optional": true,- "os": [- "linux"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@next/swc-linux-arm64-musl": {- "version": "14.2.30",- "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.30.tgz",- "integrity": "sha512-8GkNA+sLclQyxgzCDs2/2GSwBc92QLMrmYAmoP2xehe5MUKBLB2cgo34Yu242L1siSkwQkiV4YLdCnjwc/Micw==",- "cpu": [- "arm64"- ],- "optional": true,- "os": [- "linux"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@next/swc-linux-x64-gnu": {- "version": "14.2.30",- "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.30.tgz",- "integrity": "sha512-8Ly7okjssLuBoe8qaRCcjGtcMsv79hwzn/63wNeIkzJVFVX06h5S737XNr7DZwlsbTBDOyI6qbL2BJB5n6TV/w==",- "cpu": [- "x64"- ],- "optional": true,- "os": [- "linux"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@next/swc-linux-x64-musl": {- "version": "14.2.30",- "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.30.tgz",- "integrity": "sha512-dBmV1lLNeX4mR7uI7KNVHsGQU+OgTG5RGFPi3tBJpsKPvOPtg9poyav/BYWrB3GPQL4dW5YGGgalwZ79WukbKQ==",- "cpu": [- "x64"- ],- "optional": true,- "os": [- "linux"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@next/swc-win32-arm64-msvc": {- "version": "14.2.30",- "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.30.tgz",- "integrity": "sha512-6MMHi2Qc1Gkq+4YLXAgbYslE1f9zMGBikKMdmQRHXjkGPot1JY3n5/Qrbg40Uvbi8//wYnydPnyvNhI1DMUW1g==",- "cpu": [- "arm64"- ],- "optional": true,- "os": [- "win32"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@next/swc-win32-ia32-msvc": {- "version": "14.2.30",- "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.30.tgz",- "integrity": "sha512-pVZMnFok5qEX4RT59mK2hEVtJX+XFfak+/rjHpyFh7juiT52r177bfFKhnlafm0UOSldhXjj32b+LZIOdswGTg==",- "cpu": [- "ia32"- ],- "optional": true,- "os": [- "win32"- ],- "engines": {- "node": ">= 10"- }- },- "node_modules/@next/swc-win32-x64-msvc": {- "version": "14.2.30",- "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.30.tgz",- "integrity": "sha512-4KCo8hMZXMjpTzs3HOqOGYYwAXymXIy7PEPAXNEcEOyKqkjiDlECumrWziy+JEF0Oi4ILHGxzgQ3YiMGG2t/Lg==",- "cpu": [- "x64"- ],- "optional": true,- "os": [- "win32"- ],- "engines": {- "node": ">= 10"- }}}}diff --git a/ui/litellm-dashboard/src/components/templates/key_info_view.tsx b/ui/litellm-dashboard/src/components/templates/key_info_view.tsxindex c4e5276021f..b4a74bf846b 100644--- a/ui/litellm-dashboard/src/components/templates/key_info_view.tsx+++ b/ui/litellm-dashboard/src/components/templates/key_info_view.tsx@@ -61,6 +61,7 @@ export default function KeyInfoView({const [isEditing, setIsEditing] = useState(false)const [form] = Form.useForm()const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false)+ const [deleteConfirmInput, setDeleteConfirmInput] = useState("")const [isRegenerateModalOpen, setIsRegenerateModalOpen] = useState(false)const [copiedStates, setCopiedStates] = useState<Record<string, boolean>>({})@@ -200,6 +201,8 @@ export default function KeyInfoView({console.error("Error deleting the key:", error)NotificationManager.fromBackend(error)}+ // Reset the confirmation input+ setDeleteConfirmInput("")}const copyToClipboard = async (text: string, key: string) => {@@ -342,38 +345,79 @@ export default function KeyInfoView({/>{/* Delete Confirmation Modal */}- {isDeleteModalOpen && (- <div className="fixed z-10 inset-0 overflow-y-auto">- <div className="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">- <div className="fixed inset-0 transition-opacity" aria-hidden="true">- <div className="absolute inset-0 bg-gray-500 opacity-75"></div>- </div>-- <span className="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">- ​- </span>-- <div className="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full">- <div className="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">- <div className="sm:flex sm:items-start">- <div className="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">- <h3 className="text-lg leading-6 font-medium text-gray-900">Delete Key</h3>- <div className="mt-2">- <p className="text-sm text-gray-500">Are you sure you want to delete this key?</p>- </div>- </div>- </div>+ {isDeleteModalOpen && (() => {+ const keyName = currentKeyData?.key_alias || currentKeyData?.token_id || "API Key";+ const isValid = deleteConfirmInput === keyName;+ return (+ <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">+ <div className="bg-white rounded-lg shadow-xl w-full max-w-2xl min-h-[380px] py-6 overflow-hidden transform transition-all flex flex-col justify-between">+ <div>+ <div className="flex items-center justify-between px-6 py-4 border-b border-gray-200">+ <h3 className="text-lg font-semibold text-gray-900">Delete Key</h3>+ <button+ onClick={() => { setIsDeleteModalOpen(false); setDeleteConfirmInput(""); }}+ className="text-gray-400 hover:text-gray-500 focus:outline-none"+ >+ <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />+ </svg>+ </button>+ </div>+ <div className="px-6 py-4">+ <div className="flex items-start gap-3 p-4 bg-red-50 border border-red-100 rounded-md mb-5">+ <div className="text-red-500 mt-0.5">+ <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.082 16.5c-.77.833.192 2.5 1.732 2.5z" />+ </svg></div>- <div className="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">- <Button onClick={handleDelete} color="red" className="ml-2">- Delete- </Button>- <Button onClick={() => setIsDeleteModalOpen(false)}>Cancel</Button>+ <div>+ <p className="text-base font-medium text-red-600">+ Warning: You are about to delete this API key.+ </p>+ <p className="text-base text-red-600 mt-2">+ This action is irreversible and will immediately revoke access for any applications using this key.+ </p></div></div>+ <p className="text-base text-gray-600 mb-5">+ Are you sure you want to delete this API key?+ </p>+ <div className="mb-5">+ <label className="block text-base font-medium text-gray-700 mb-2">+ {`Type `}+ <span className="underline">{keyName}</span>+ {` to confirm deletion:`}+ </label>+ <input+ type="text"+ value={deleteConfirmInput}+ onChange={(e) => setDeleteConfirmInput(e.target.value)}+ placeholder="Enter key name exactly"+ className="w-full px-4 py-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-base"+ autoFocus+ />+ </div></div></div>- )}+ <div className="px-6 py-4 bg-gray-50 flex justify-end gap-4">+ <button+ onClick={() => { setIsDeleteModalOpen(false); setDeleteConfirmInput(""); }}+ className="px-5 py-3 bg-white border border-gray-300 rounded-md text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"+ >+ Cancel+ </button>+ <button+ onClick={handleDelete}+ disabled={!isValid}+ className={`px-5 py-3 rounded-md text-base font-medium text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 ${isValid ? 'bg-red-600 hover:bg-red-700' : 'bg-red-300 cursor-not-allowed'}`}+ >+ Delete Key+ </button>+ </div>+ </div>+ </div>+ );+})()}<TabGroup><TabList className="mb-4">diff --git a/ui/litellm-dashboard/src/components/templates/view_key_table.tsx b/ui/litellm-dashboard/src/components/templates/view_key_table.tsxindex ca4260d4f25..858299364c7 100644--- a/ui/litellm-dashboard/src/components/templates/view_key_table.tsx+++ b/ui/litellm-dashboard/src/components/templates/view_key_table.tsx@@ -156,6 +156,7 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({const [isButtonClicked, setIsButtonClicked] = useState(false)const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false)const [keyToDelete, setKeyToDelete] = useState<string | null>(null)+ const [deleteConfirmInput, setDeleteConfirmInput] = useState("")const [selectedItem, setSelectedItem] = useState<KeyResponse | null>(null)const [spendData, setSpendData] = useState<{ day: string; spend: number }[] | null>(null)@@ -274,7 +275,7 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({}, [teams])const confirmDelete = async () => {- if (keyToDelete == null || data == null) {+ if (keyToDelete == null || keys == null) {return}@@ -282,8 +283,8 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({if (!accessToken) returnawait keyDeleteCall(accessToken, keyToDelete)// Successfully completed the deletion. Update the state to trigger a rerender.- const filteredData = data.filter((item) => item.token !== keyToDelete)- setData(filteredData)+ const filteredKeys = keys.filter((item) => item.token !== keyToDelete)+ setKeys(filteredKeys)} catch (error) {NotificationManager.error({ description: "Error deleting the key" })}@@ -291,12 +292,14 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({// Close the confirmation modal and reset the keyToDeletesetIsDeleteModalOpen(false)setKeyToDelete(null)+ setDeleteConfirmInput("")}const cancelDelete = () => {// Close the confirmation modal and reset the keyToDeletesetIsDeleteModalOpen(false)setKeyToDelete(null)+ setDeleteConfirmInput("")}const handleRegenerateClick = (token: any) => {@@ -378,40 +381,80 @@ const ViewKeyTable: React.FC<ViewKeyTableProps> = ({setAccessToken={setAccessToken}/>- {isDeleteModalOpen && (- <div className="fixed z-10 inset-0 overflow-y-auto">- <div className="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">- <div className="fixed inset-0 transition-opacity" aria-hidden="true">- <div className="absolute inset-0 bg-gray-500 opacity-75"></div>- </div>-- {/* Modal Panel */}- <span className="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">- ​- </span>-- {/* Confirmation Modal Content */}- <div className="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full">- <div className="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">- <div className="sm:flex sm:items-start">- <div className="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">- <h3 className="text-lg leading-6 font-medium text-gray-900">Delete Key</h3>- <div className="mt-2">- <p className="text-sm text-gray-500">Are you sure you want to delete this key ?</p>- </div>- </div>- </div>+ {isDeleteModalOpen && (() => {+ const keyData = keys?.find((k) => k.token === keyToDelete);+ const keyName = keyData?.key_alias || keyData?.token_id || keyToDelete;+ const isValid = deleteConfirmInput === keyName;+ return (+ <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">+ <div className="bg-white rounded-lg shadow-xl w-full max-w-2xl min-h-[380px] py-6 overflow-hidden transform transition-all flex flex-col justify-between">+ <div>+ <div className="flex items-center justify-between px-6 py-4 border-b border-gray-200">+ <h3 className="text-lg font-semibold text-gray-900">Delete Key</h3>+ <button+ onClick={() => { cancelDelete(); setDeleteConfirmInput(""); }}+ className="text-gray-400 hover:text-gray-500 focus:outline-none"+ >+ <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />+ </svg>+ </button>+ </div>+ <div className="px-6 py-4">+ <div className="flex items-start gap-3 p-4 bg-red-50 border border-red-100 rounded-md mb-5">+ <div className="text-red-500 mt-0.5">+ <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.082 16.5c-.77.833.192 2.5 1.732 2.5z" />+ </svg></div>- <div className="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">- <Button onClick={confirmDelete} color="red" className="ml-2">- Delete- </Button>- <Button onClick={cancelDelete}>Cancel</Button>+ <div>+ <p className="text-base font-medium text-red-600">+ Warning: You are about to delete this API key.+ </p>+ <p className="text-base text-red-600 mt-2">+ This action is irreversible and will immediately revoke access for any applications using this key.+ </p></div></div>+ <p className="text-base text-gray-600 mb-5">+ Are you sure you want to delete this API key?+ </p>+ <div className="mb-5">+ <label className="block text-base font-medium text-gray-700 mb-2">+ {`Type `}+ <span className="underline">{keyName}</span>+ {` to confirm deletion:`}+ </label>+ <input+ type="text"+ value={deleteConfirmInput}+ onChange={(e) => setDeleteConfirmInput(e.target.value)}+ placeholder="Enter key name exactly"+ className="w-full px-4 py-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-base"+ autoFocus+ />+ </div></div></div>- )}+ <div className="px-6 py-4 bg-gray-50 flex justify-end gap-4">+ <button+ onClick={() => { cancelDelete(); setDeleteConfirmInput(""); }}+ className="px-5 py-3 bg-white border border-gray-300 rounded-md text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"+ >+ Cancel+ </button>+ <button+ onClick={confirmDelete}+ disabled={!isValid}+ className={`px-5 py-3 rounded-md text-base font-medium text-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 ${isValid ? 'bg-red-600 hover:bg-red-700' : 'bg-red-300 cursor-not-allowed'}`}+ >+ Delete Key+ </button>+ </div>+ </div>+ </div>+ );+})()}{/* Regenerate Key Form Modal */}<Modal