mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 03:25:56 +00:00
Add CoA / Wildcard realm profiles for v0.5.0 (#10)
* Add isolated Wildcard realm profiles and release v0.5.0 * Document realm validation and align npm lock version
This commit is contained in:
1 parent
831685dbd7
commit
1bcef5f8c2
35 files changed
+872
-37
No files matched your search
@@ -33,7 +33,11 @@ export function BackupsPage({ serverId }: { serverId: string }) {
|
||||
const human = useHuman();
|
||||
const w = (iso: string) => when(iso, t, locale);
|
||||
const trigger = (x: string) => (TRIGGER_KEYS.includes(x) ? t(`bk.trigger.${x}` as Key) : x);
|
||||
const dbLabel = (x: string) => (DB_KEYS.includes(x) ? t(`bk.db.${x}` as Key) : x);
|
||||
const dbLabel = (x: string) => {
|
||||
const [realm, kind] = x.split("-");
|
||||
if (kind && DB_KEYS.includes(kind)) return `${realm === "coa" ? "CoA" : "Wildcard"} · ${t(`bk.db.${kind}` as Key)}`;
|
||||
return DB_KEYS.includes(x) ? t(`bk.db.${x}` as Key) : x;
|
||||
};
|
||||
const [points, setPoints] = useState<RecoveryPoint[] | null>(null);
|
||||
const [busy, setBusy] = useState<string | null>(null);
|
||||
const [step, setStep] = useState<string | null>(null);
|
||||
@@ -174,7 +178,7 @@ export function BackupsPage({ serverId }: { serverId: string }) {
|
||||
<div>
|
||||
<p className="font-medium">{p.label && p.trigger === "manual" && p.label !== "e2e" ? p.label : trigger(p.trigger)}</p>
|
||||
<p className="text-sm text-muted">
|
||||
{w(p.created_at)} · {t(`bk.kind.${p.kind}` as Key)} · {size(p.components.reduce((a, c) => a + c.bytes, 0))}
|
||||
{w(p.created_at)} · {p.realm === "wildcard" ? "Wildcard" : "CoA"} · {t(`bk.kind.${p.kind}` as Key)} · {size(p.components.reduce((a, c) => a + c.bytes, 0))}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex shrink-0 gap-1">
|
||||
|
||||
@@ -134,6 +134,8 @@ export function ModulesPage({ serverId, onChanged }: { serverId: string; onChang
|
||||
<StatusBadge status={m.status} />
|
||||
</div>
|
||||
<p className="mt-1.5 line-clamp-2 text-sm text-muted">{m.description[locale] ?? m.description.en}</p>
|
||||
{m.compatibility === "unsupported" && <p className="mt-2 text-xs text-warn">{t("realm.unsupported")}</p>}
|
||||
{m.compatibility === "experimental" && <p className="mt-2 text-xs text-warn">{t("realm.experimental")}</p>}
|
||||
</div>
|
||||
{m.installed && m.switchable && (
|
||||
<button
|
||||
@@ -146,7 +148,7 @@ export function ModulesPage({ serverId, onChanged }: { serverId: string; onChang
|
||||
<span className={cn("absolute top-0.5 h-5 w-5 rounded-full bg-white transition-all", m.enabled ? "left-[22px]" : "left-0.5")} />
|
||||
</button>
|
||||
)}
|
||||
{m.installed && !m.switchable && m.status !== "soon" && <span className="mt-1.5 shrink-0 text-xs text-muted">{t("mod.alwaysOn")}</span>}
|
||||
{m.installed && !m.switchable && m.status !== "soon" && m.compatibility !== "unsupported" && <span className="mt-1.5 shrink-0 text-xs text-muted">{t("mod.alwaysOn")}</span>}
|
||||
{!m.installed && m.status !== "soon" && <span className="mt-1.5 shrink-0 text-xs text-muted">{t("mod.notHere")}</span>}
|
||||
</div>
|
||||
<div className="mt-auto flex items-center gap-2">
|
||||
@@ -158,7 +160,7 @@ export function ModulesPage({ serverId, onChanged }: { serverId: string; onChang
|
||||
>
|
||||
<GithubMark className="h-4 w-4" />
|
||||
</button>
|
||||
{m.installed && m.status !== "soon" && (
|
||||
{m.installed && m.status !== "soon" && m.compatibility !== "unsupported" && (
|
||||
<Button size="sm" variant="ghost" aria-expanded={open === m.id} onClick={() => setOpen(open === m.id ? null : m.id)}>
|
||||
<Settings2 className="h-3.5 w-3.5" aria-hidden /> {t("mod.settings")}
|
||||
</Button>
|
||||
|
||||
@@ -8,6 +8,7 @@ import { applyServerUpdate, useServerUpdate } from "@/lib/serverUpdate";
|
||||
import { checkClient, useClientStatus } from "@/lib/clientUpdate";
|
||||
import { ClientDialog, type ClientDialogMode } from "@/screens/ClientDialog";
|
||||
import { RealmlistMenu } from "@/screens/RealmlistMenu";
|
||||
import { RealmPicker } from "@/screens/RealmPicker";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card } from "@/components/ui/card";
|
||||
|
||||
@@ -63,11 +64,12 @@ function Row({ label, s }: { label: string; s: ServiceStatus }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function Overview({ server, companions = true, onForget, onOpenUpdates }: { server: ServerSummary; /** the companions module is on */ companions?: boolean; onForget: () => Promise<void>; onOpenUpdates: () => void }) {
|
||||
export function Overview({ server, companions = true, onForget, onOpenUpdates, onRealmChanged }: { server: ServerSummary; /** the companions module is on */ companions?: boolean; onForget: () => Promise<void>; onOpenUpdates: () => void; onRealmChanged: () => void }) {
|
||||
const t = useT();
|
||||
const human = useHuman();
|
||||
const [status, setStatus] = useState<StatusView | null>(null);
|
||||
const [action, setAction] = useState<Action>(null);
|
||||
const [realmBusy, setRealmBusy] = useState(false);
|
||||
const [failure, setFailure] = useState<Failure | null>(null);
|
||||
const [showDetails, setShowDetails] = useState(false);
|
||||
const [pop, setPop] = useState<Population | null>(null);
|
||||
@@ -197,10 +199,10 @@ export function Overview({ server, companions = true, onForget, onOpenUpdates }:
|
||||
const all = [mysql, auth, world];
|
||||
const running = all.every((s) => s.state === "running");
|
||||
const anyUp = all.some((s) => s.state !== "stopped");
|
||||
const transitioning = action !== null || status.busy;
|
||||
const transitioning = action !== null || status.busy || realmBusy;
|
||||
const conflict = all.find((s) => s.conflict)?.conflict ?? null;
|
||||
|
||||
const headline = transitioning
|
||||
const headline = realmBusy ? t("realm.switching") : transitioning
|
||||
? action === "stopping"
|
||||
? t("status.stopping")
|
||||
: t("status.starting")
|
||||
@@ -215,6 +217,7 @@ export function Overview({ server, companions = true, onForget, onOpenUpdates }:
|
||||
<div className="w-full max-w-4xl">
|
||||
<h1 className="text-2xl font-semibold">{server.name}</h1>
|
||||
<p className="selectable mt-0.5 text-xs text-muted">{server.path}</p>
|
||||
<RealmPicker serverId={server.id} running={anyUp} disabled={transitioning || upd.applying} onBusy={setRealmBusy} onChanged={() => { onRealmChanged(); void poll(); }} />
|
||||
|
||||
<Card className="mt-6 p-7">
|
||||
<div className="mb-1 text-xs font-medium uppercase tracking-[0.14em] text-muted">{t("overview.server")}</div>
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Layers, Loader2 } from "lucide-react";
|
||||
import { api, asUiError, type RealmMode, type RealmProfiles } from "@/lib/api";
|
||||
import { useT } from "@/i18n";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card } from "@/components/ui/card";
|
||||
|
||||
export function RealmPicker({ serverId, running, disabled, onChanged, onBusy }: {
|
||||
serverId: string; running: boolean; disabled: boolean; onChanged: () => void; onBusy: (busy: boolean) => void;
|
||||
}) {
|
||||
const t = useT();
|
||||
const [view, setView] = useState<RealmProfiles | null>(null);
|
||||
const [selected, setSelected] = useState<RealmMode>("coa");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
void api.realmProfiles(serverId).then(v => { if (alive) { setView(v); setSelected(v.active); } }).catch(e => { if (alive) setError(asUiError(e).technical); });
|
||||
return () => { alive = false; };
|
||||
}, [serverId]);
|
||||
|
||||
async function select() {
|
||||
setBusy(true); onBusy(true); setError(null);
|
||||
try { const next = await api.realmSelect(serverId, selected, running); setView(next); onChanged(); }
|
||||
catch (e) {
|
||||
setError(asUiError(e).technical);
|
||||
// Selection may have committed even if the subsequent server restart failed.
|
||||
try { setView(await api.realmProfiles(serverId)); onChanged(); } catch { /* keep the operation error */ }
|
||||
}
|
||||
finally { setBusy(false); onBusy(false); }
|
||||
}
|
||||
|
||||
return <Card className="mt-5 p-5" aria-busy={busy}>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<Layers className="h-5 w-5 text-gold" aria-hidden />
|
||||
<label htmlFor="realm-profile" className="font-medium">{t("realm.profileLabel")}</label>
|
||||
<select id="realm-profile" value={selected} disabled={!view || disabled || busy} onChange={e => setSelected(e.target.value as RealmMode)} className="min-w-52 rounded-md border border-line bg-card-2 px-3 py-2 text-ink">
|
||||
<option value="coa">Conquest of Azeroth</option>
|
||||
<option value="wildcard" disabled={!view?.supported && !view?.wildcard_created}>Wildcard · Darkmoon</option>
|
||||
</select>
|
||||
{view && (selected !== view.active || view.recovery_pending) && <Button size="sm" disabled={disabled || busy} onClick={() => void select()}>
|
||||
{busy && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
|
||||
{busy ? t("realm.switching") : selected === "wildcard" && !view.wildcard_created ? t("realm.create") : running ? t("realm.restart") : t("realm.select")}
|
||||
</Button>}
|
||||
{view && <span className="ml-auto text-xs text-muted">{t("realm.active", { name: view.active === "coa" ? "CoA" : "Wildcard" })}</span>}
|
||||
</div>
|
||||
<p className="mt-3 text-sm text-muted">{t("realm.separate")}</p>
|
||||
{selected === "wildcard" && <p className="mt-2 text-sm text-warn">{t("realm.modules")}</p>}
|
||||
{view && !view.supported && <p className="mt-2 text-sm text-warn">{t("realm.update")}</p>}
|
||||
{view?.recovery_pending && <p className="mt-2 text-sm text-warn">{t("realm.recovery")}</p>}
|
||||
{error && <p className="mt-3 selectable text-sm text-bad" role="alert">{error}</p>}
|
||||
</Card>;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export function Shell(props: {
|
||||
const reloadModules = useCallback(() => {
|
||||
void api
|
||||
.modulesList(props.activeId)
|
||||
.then((list) => setHiddenPages(list.filter((m) => m.page && (!m.installed || (m.switchable && !m.enabled))).map((m) => m.page as string)))
|
||||
.then((list) => setHiddenPages(list.filter((m) => m.page && (!m.installed || m.compatibility === "unsupported" || (m.switchable && !m.enabled))).map((m) => m.page as string)))
|
||||
.catch(() => setHiddenPages([]));
|
||||
}, [props.activeId]);
|
||||
useEffect(() => {
|
||||
@@ -122,7 +122,7 @@ export function Shell(props: {
|
||||
|
||||
<main className="h-full flex-1 overflow-y-auto px-10 py-8">
|
||||
{page === "overview" ? (
|
||||
<Overview key={server.id} server={server} companions={!hiddenPages.includes("bots")} onForget={() => props.onForget(server.id)} onOpenUpdates={() => setPage("settings")} />
|
||||
<Overview key={server.id} server={server} companions={!hiddenPages.includes("bots")} onForget={() => props.onForget(server.id)} onOpenUpdates={() => setPage("settings")} onRealmChanged={reloadModules} />
|
||||
) : page === "bots" || page === "server" ? (
|
||||
<SettingsPage key={`${server.id}-${page}`} serverId={server.id} scope={page} title={t(current.label)} question={t(current.question)} />
|
||||
) : page === "console" ? (
|
||||
|
||||
Reference in new issue
Block a user