import React from "react"; import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert.tsx"; import { Button } from "@/components/ui/button.tsx"; import { ExternalLink, Download, X, AlertTriangle } from "lucide-react"; import { useTranslation } from "react-i18next"; interface VersionAlertProps { updateInfo: { success: boolean; status?: "up_to_date" | "requires_update"; localVersion?: string; remoteVersion?: string; latest_release?: { tag_name: string; name: string; published_at: string; html_url: string; body: string; }; cached?: boolean; cache_age?: number; error?: string; }; onDismiss?: () => void; onDownload?: () => void; showDismiss?: boolean; } export function VersionAlert({ updateInfo, onDismiss, onDownload, showDismiss = true, }: VersionAlertProps) { const { t } = useTranslation(); if (!updateInfo.success) { return ( {t("versionCheck.error")} {updateInfo.error || t("versionCheck.checkFailed")} ); } if (updateInfo.status === "up_to_date") { return ( {t("versionCheck.upToDate")} {t("versionCheck.currentVersion", { version: updateInfo.localVersion })} ); } if (updateInfo.status === "requires_update") { return ( {t("versionCheck.updateAvailable")}
{t("versionCheck.newVersionAvailable", { current: updateInfo.localVersion, latest: updateInfo.remoteVersion, })}
{updateInfo.latest_release && (
{updateInfo.latest_release.name}
{t("versionCheck.releasedOn", { date: new Date(updateInfo.latest_release.published_at).toLocaleDateString(), })}
)}
{updateInfo.latest_release?.html_url && ( )} {showDismiss && onDismiss && ( )}
); } return null; }