// ======================================== // CCW-LiteLLM Status & Install Component // ======================================== // Shows ccw-litellm installation status with install/uninstall actions import { useState } from 'react'; import { useIntl } from 'react-intl'; import { Download, Trash2, RefreshCw, CheckCircle2, XCircle, Loader2, Package, } from 'lucide-react'; import { Button } from '@/components/ui/Button'; import { Card, CardContent } from '@/components/ui/Card'; import { Badge } from '@/components/ui/Badge'; import { useCcwLitellmStatus, useInstallCcwLitellm, useUninstallCcwLitellm, } from '@/hooks/useApiSettings'; import { useNotifications } from '@/hooks/useNotifications'; export function CcwLitellmStatus() { const { formatMessage } = useIntl(); const { success, error: notifyError } = useNotifications(); const [refresh, setRefresh] = useState(false); const { data: status, isLoading, refetch } = useCcwLitellmStatus({ refresh }); const { install, isInstalling } = useInstallCcwLitellm(); const { uninstall, isUninstalling } = useUninstallCcwLitellm(); const isBusy = isInstalling || isUninstalling; const handleInstall = async () => { try { await install(); success(formatMessage({ id: 'apiSettings.ccwLitellm.messages.installSuccess' })); setRefresh(true); refetch(); } catch { notifyError(formatMessage({ id: 'apiSettings.ccwLitellm.messages.installFailed' })); } }; const handleUninstall = async () => { try { await uninstall(); success(formatMessage({ id: 'apiSettings.ccwLitellm.messages.uninstallSuccess' })); setRefresh(true); refetch(); } catch { notifyError(formatMessage({ id: 'apiSettings.ccwLitellm.messages.uninstallFailed' })); } }; const handleRefresh = () => { setRefresh(true); refetch(); }; const installed = status?.installed ?? false; const version = status?.version; return (

{formatMessage({ id: 'apiSettings.ccwLitellm.title' })}

{formatMessage({ id: 'apiSettings.ccwLitellm.description' })}

{/* Status badge */} {isLoading ? ( ... ) : installed ? ( {formatMessage({ id: 'apiSettings.ccwLitellm.status.installed' })} {version && ` v${version}`} ) : ( {formatMessage({ id: 'apiSettings.ccwLitellm.status.notInstalled' })} )} {/* Refresh */} {/* Install / Uninstall */} {installed ? ( ) : ( )}
); } export default CcwLitellmStatus;