import { useState } from "react" import { ServiceSlim } from "../../types/services" import StyledModal from "./StyledModal" import { IconArrowUp } from "@tabler/icons-react" import api from "~/lib/api" interface UpdateServiceModalProps { record: ServiceSlim currentTag: string latestVersion: string onCancel: () => void onUpdate: (version: string) => void showError: (msg: string) => void } export default function UpdateServiceModal({ record, currentTag, latestVersion, onCancel, onUpdate, showError, }: UpdateServiceModalProps) { const [selectedVersion, setSelectedVersion] = useState(latestVersion) const [showAdvanced, setShowAdvanced] = useState(false) const [versions, setVersions] = useState>([]) const [loadingVersions, setLoadingVersions] = useState(false) async function loadVersions() { if (versions.length > 0) return setLoadingVersions(true) try { const result = await api.getAvailableVersions(record.service_name) if (result?.versions) { setVersions(result.versions) } } catch (error) { showError('Failed to load available versions') } finally { setLoadingVersions(false) } } function handleToggleAdvanced() { const next = !showAdvanced setShowAdvanced(next) if (next) loadVersions() } return ( onUpdate(selectedVersion)} onCancel={onCancel} open={true} confirmText="Update" cancelText="Cancel" confirmVariant="primary" icon={} >

Update {record.friendly_name || record.service_name} from{' '} {currentTag} to{' '} {selectedVersion}?

Your data and configuration will be preserved during the update. {versions.find((v) => v.tag === selectedVersion)?.releaseUrl && ( <> {' '} v.tag === selectedVersion)!.releaseUrl} target="_blank" rel="noopener noreferrer" className="text-desert-green hover:underline" > View release notes )}

{showAdvanced && ( <>
{loadingVersions ? (
Loading versions...
) : versions.length === 0 ? (
No other versions available
) : ( versions.map((v) => ( )) )}

It's not recommended to upgrade to a new major version (e.g. 1.8.2 → 2.0.0) unless you have verified compatibility with your current configuration. Always review the release notes and test in a staging environment if possible.

)}
) }