Show Overview update failures and cover copied launcher configuration

This commit is contained in:
Дмитрий committed 2026-10-14 08:26:19 +05:00
1 parent 24d593d787
commit be2f252593
6 files changed
+114 -7

No files matched your search

+13 -7
View File
@@ -99,7 +99,13 @@ export function Overview({ server, companions = true, onForget, onOpenUpdates, o
const [keepMine, setKeepMine] = useState(true);
const [perf, setPerf] = useState<Performance | null>(null);
const upd = useServerUpdate(server.id);
const visibleFailure = failure ?? upd.stateError ?? upd.uiError;
const needsDecision = (upd.preview?.conflicts.length ?? 0) > 0;
const runServerUpdate = async () => {
setFailure(null);
setShowDetails(false);
await applyServerUpdate(server.id);
};
const [startBots, setStartBots] = useState<number | null | undefined>(undefined);
const [autoRestart, setAutoRestart] = useAutoRestart(server.id);
const autoRestartRef = useRef(autoRestart);
@@ -401,7 +407,7 @@ export function Overview({ server, companions = true, onForget, onOpenUpdates, o
variant="primary"
size="xl"
disabled={transitioning || upd.applying}
onClick={() => (needsDecision ? onOpenUpdates() : void applyServerUpdate(server.id))}
onClick={() => (needsDecision ? onOpenUpdates() : void runServerUpdate())}
className="min-w-56"
>
{upd.applying && <Loader2 className="h-5 w-5 animate-spin" aria-hidden />}
@@ -424,7 +430,7 @@ export function Overview({ server, companions = true, onForget, onOpenUpdates, o
</Button>
)}
{running && upd.available && (
<Button variant="secondary" size="sm" disabled={transitioning || upd.applying} onClick={() => (needsDecision ? onOpenUpdates() : void applyServerUpdate(server.id))}>
<Button variant="secondary" size="sm" disabled={transitioning || upd.applying} onClick={() => (needsDecision ? onOpenUpdates() : void runServerUpdate())}>
{upd.applying && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
{needsDecision ? t("overview.openUpdates") : t("btn.updateTo", { v: upd.preview?.to_version ?? "" })}
</Button>
@@ -587,21 +593,21 @@ export function Overview({ server, companions = true, onForget, onOpenUpdates, o
</Card>
)}
{failure && (
{visibleFailure && (
<Card className="mt-4 border-bad/40 p-5" role="alert">
<p className="font-medium text-bad">{human(failure.human).title}</p>
<p className="mt-1 text-sm text-muted">{human(failure.human).message}</p>
<p className="font-medium text-bad">{human(visibleFailure.human).title}</p>
<p className="mt-1 text-sm text-muted">{human(visibleFailure.human).message}</p>
<div className="mt-3 flex gap-2">
<Button size="sm" onClick={() => setShowDetails((v) => !v)}>
{showDetails ? t("common.hideDetails") : t("common.viewDetails")}
</Button>
<Button size="sm" variant="ghost" onClick={() => void navigator.clipboard.writeText(failure.technical)}>
<Button size="sm" variant="ghost" onClick={() => void navigator.clipboard.writeText(visibleFailure.technical)}>
{t("common.copyError")}
</Button>
</div>
{showDetails && (
<pre className="mt-3 max-h-56 overflow-auto whitespace-pre-wrap rounded bg-black/40 p-3 text-xs text-muted">
{failure.technical || t("common.noOutput")}
{visibleFailure.technical || t("common.noOutput")}
</pre>
)}
</Card>