mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 03:25:56 +00:00
Settings gets two options, one per extra realm; turning on both runs all three realms. Each extra world keeps its own folder, configs, logs and ports (multiworld now handles a set of worlds instead of one second world), and Warcraft Reborn gets its own status card, realm list entry and firewall rule. Starting a server also sets CoA.ClassModel of the realm chosen on Overview to exactly that realm's model, so the shipped "coa wcr" default no longer shows two class models on a Conquest of Azeroth realm. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
40 lines
1.9 KiB
TypeScript
40 lines
1.9 KiB
TypeScript
import { useEffect, useState } from "react";
|
|
import { api, asUiError } from "@/lib/api";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Card } from "@/components/ui/card";
|
|
import { useT } from "@/i18n";
|
|
|
|
/** Takes a server out of the Manager's list. Nothing on disk is deleted, so the folder can be added again later. */
|
|
export function RemoveServerCard({ serverId, path, onForget }: { serverId: string; path: string; onForget: () => Promise<void> }) {
|
|
const t = useT();
|
|
const [running, setRunning] = useState(false);
|
|
const [error, setError] = useState<string | null>(null);
|
|
const [busy, setBusy] = useState(false);
|
|
|
|
useEffect(() => {
|
|
let active = true;
|
|
void api.status(serverId).then((s) => {
|
|
if (!active) return;
|
|
const all = [s.observed.mysql, s.observed.auth, s.observed.world, ...(s.observed.secondary_world ? [s.observed.secondary_world] : []), ...(s.observed.reborn_world ? [s.observed.reborn_world] : [])];
|
|
setRunning(all.some((x) => x.state === "running" || x.state === "starting" || x.state === "stopping"));
|
|
}).catch(() => { /* an unreadable status must not hide the button */ });
|
|
return () => { active = false; };
|
|
}, [serverId]);
|
|
|
|
async function remove() {
|
|
if (!window.confirm(t("remove.confirm", { path }))) return;
|
|
setBusy(true); setError(null);
|
|
try { await onForget(); }
|
|
catch (e) { setError(asUiError(e).technical); setBusy(false); }
|
|
}
|
|
|
|
return <Card className="mt-6 p-6">
|
|
<h2 className="font-semibold">{t("remove.title")}</h2>
|
|
<p className="mt-2 text-sm text-muted">{t("remove.text")}</p>
|
|
<p className="selectable mt-1 break-all text-sm text-muted">{path}</p>
|
|
<Button className="mt-4" disabled={busy || running} onClick={() => void remove()}>{t("remove.button")}</Button>
|
|
{running && <p className="mt-2 text-sm text-warn">{t("remove.stopFirst")}</p>}
|
|
{error && <p className="mt-3 text-sm text-bad" role="alert">{error}</p>}
|
|
</Card>;
|
|
}
|