mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-22 19:25:56 +00:00
Custom races hold their V2 parts; the addon list shows every addon
- Subclasses/Hero Races and the /dev menu are parts of Custom Races (catalog part_of, hidden from the grid): their switch and settings sit inside the Custom Races settings. - The companion bots addon (CoABotUI) moves from the client facts into the addon list, with install/update from the server package; the /dev menu addon of the V2 patch is listed as installed by the patch, without its own buttons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
05630ec9eb
commit
2fd42f2acd
15 files changed
+125
-21
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { ExternalLink, Loader2 } from "lucide-react";
|
||||
import { api, asUiError, type AddonView } from "@/lib/api";
|
||||
import { api, asUiError, type AddonView, type ClientInfo } from "@/lib/api";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useI18n } from "@/i18n";
|
||||
|
||||
@@ -9,7 +9,7 @@ function megabytes(bytes: number): string {
|
||||
}
|
||||
|
||||
/** Addons from the Manager's catalog: each pinned to a commit of its author's repository and checked file by file. */
|
||||
export function AddonCatalog({ serverId }: { serverId: string }) {
|
||||
export function AddonCatalog({ serverId, companions, onCompanionsInstalled }: { serverId: string; companions?: ClientInfo["addon"] | null; onCompanionsInstalled?: () => void }) {
|
||||
const { t, locale } = useI18n();
|
||||
const [addons, setAddons] = useState<AddonView[] | null>(null);
|
||||
const [working, setWorking] = useState<string | null>(null);
|
||||
@@ -28,28 +28,49 @@ export function AddonCatalog({ serverId }: { serverId: string }) {
|
||||
finally { setWorking(null); }
|
||||
}
|
||||
|
||||
async function installCompanions() {
|
||||
setWorking("coa-companions"); setError(null);
|
||||
try { await api.installAddon(serverId); onCompanionsInstalled?.(); }
|
||||
catch (e) { setError(asUiError(e).technical); }
|
||||
finally { setWorking(null); }
|
||||
}
|
||||
|
||||
return <div className="mt-5 border-t border-line pt-4">
|
||||
<h3 className="text-sm font-semibold">{t("addons.title")}</h3>
|
||||
<p className="mt-1 text-xs text-muted">{t("addons.hint")}</p>
|
||||
<ul className="mt-3 space-y-3">
|
||||
{companions && <li className="rounded-md border border-line p-3">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="font-medium">CoA Companions (CoABotUI)</span>
|
||||
{companions.installed && companions.up_to_date !== false && <span className="text-xs text-ok">{companions.version ? t("client.installedVersion", { v: companions.version }) : t("addons.installed")}</span>}
|
||||
{companions.up_to_date === false && <span className="text-xs text-warn">{t("addons.update")}</span>}
|
||||
</div>
|
||||
<p className="mt-1 text-sm text-muted">{t("client.addonWhat")}</p>
|
||||
<p className="mt-1 text-xs text-muted">{t("addons.withServer")}</p>
|
||||
{(!companions.installed || companions.up_to_date === false) && <div className="mt-2"><Button size="sm" disabled={working !== null} onClick={() => void installCompanions()}>
|
||||
{working === "coa-companions" && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
|
||||
{companions.installed ? t("addons.doUpdate") : t("addons.doInstall")}
|
||||
</Button></div>}
|
||||
</li>}
|
||||
{addons?.map(a => <li key={a.id} className="rounded-md border border-line p-3">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="font-medium">{a.name}</span>
|
||||
<span className="text-xs text-muted">{t("addons.by", { author: a.author })} · {megabytes(a.size)} MB</span>
|
||||
<span className="text-xs text-muted">{t("addons.by", { author: a.author })}{a.size > 0 ? ` · ${megabytes(a.size)} MB` : ""}</span>
|
||||
{a.installed && !a.updateAvailable && <span className="text-xs text-ok">{t("addons.installed")}</span>}
|
||||
{a.updateAvailable && <span className="text-xs text-warn">{t("addons.update")}</span>}
|
||||
<button type="button" className="ml-auto text-muted hover:text-ink" title={a.repo} aria-label={`GitHub: ${a.name}`} onClick={() => void api.openLink(a.repo)}><ExternalLink className="h-4 w-4" aria-hidden /></button>
|
||||
</div>
|
||||
<p className="mt-1 text-sm text-muted">{a.description[locale] ?? a.description.en}</p>
|
||||
{a.needs === "playerbots" && <p className="mt-1 text-xs text-muted">{t("addons.needsSquid")}</p>}
|
||||
{a.bundled === "custom-races" && <p className="mt-1 text-xs text-muted">{a.installed ? t("addons.withRaces") : t("addons.withRacesMissing")}</p>}
|
||||
{a.foreignFolders.length > 0 && !a.installed && <p className="mt-1 text-xs text-warn">{t("addons.foreign", { folders: a.foreignFolders.join(", ") })}</p>}
|
||||
<div className="mt-2 flex gap-2">
|
||||
{!a.bundled && <div className="mt-2 flex gap-2">
|
||||
{(!a.installed || a.updateAvailable) && <Button size="sm" disabled={working !== null} onClick={() => void run(a.id, "install")}>
|
||||
{working === a.id && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
|
||||
{a.updateAvailable ? t("addons.doUpdate") : t("addons.doInstall")}
|
||||
</Button>}
|
||||
{a.installed && <Button size="sm" variant="ghost" disabled={working !== null} onClick={() => void run(a.id, "remove")}>{t("addons.doRemove")}</Button>}
|
||||
</div>
|
||||
</div>}
|
||||
</li>)}
|
||||
</ul>
|
||||
{error && <p className="mt-2 text-sm text-bad" role="alert">{error}</p>}
|
||||
|
||||
@@ -86,19 +86,11 @@ export function ClientCard({ serverId, remote = false }: { serverId: string; rem
|
||||
: t("client.versionUntracked")}
|
||||
{status?.update_available && <span className="ml-2 text-warn">{t("client.updateAvailable")}</span>}
|
||||
</dd>
|
||||
{!remote && <>
|
||||
<dt className="text-muted">{t("client.addon")}</dt>
|
||||
<dd>
|
||||
{info.addon.installed ? (info.addon.version ? t("client.installedVersion", { v: info.addon.version }) : t("client.installed")) : t("client.addonNotInstalled")}
|
||||
{info.addon.up_to_date === false && <span className="ml-2 text-warn">{t("client.updateAvailable")}</span>}
|
||||
<span className="mt-1 block text-xs text-muted">{t("client.addonWhat")}</span>
|
||||
</dd>
|
||||
</>}
|
||||
<dt className="text-muted">{t("client.otherAddons")}</dt>
|
||||
<dd>{t("client.leftAsIs", { n: info.other_addons })}</dd>
|
||||
</dl>
|
||||
<ClientGraphics key={info.path} serverId={serverId} />
|
||||
<AddonCatalog key={"addons-" + info.path} serverId={serverId} />
|
||||
<AddonCatalog key={"addons-" + info.path} serverId={serverId} companions={remote ? null : info.addon} onCompanionsInstalled={() => void refresh()} />
|
||||
{!remote && (
|
||||
<label className="mt-4 flex cursor-pointer items-center gap-2 text-sm">
|
||||
<input type="checkbox" checked={playAfter} onChange={(e) => setPlayAfter(e.target.checked)} className="h-4 w-4 accent-[#c9a24a]" />
|
||||
|
||||
@@ -87,6 +87,7 @@ export function ModulesPage({ serverId, onChanged, onRegisterGuard }: { serverId
|
||||
const { t, locale } = useI18n();
|
||||
const human = useHuman();
|
||||
const [modules, setModules] = useState<ModuleView[] | null>(null);
|
||||
const [parts, setParts] = useState<ModuleView[]>([]);
|
||||
const [open, setOpen] = useState<string | null>(null);
|
||||
const [error, setError] = useState<UiError | null>(null);
|
||||
const toggleLock = useRef(false);
|
||||
@@ -119,7 +120,9 @@ export function ModulesPage({ serverId, onChanged, onRegisterGuard }: { serverId
|
||||
|
||||
const load = useCallback(async () => {
|
||||
try {
|
||||
setModules((await api.modulesList(serverId)).filter((m) => !m.hidden));
|
||||
const all = await api.modulesList(serverId);
|
||||
setModules(all.filter((m) => !m.hidden));
|
||||
setParts(all.filter((m) => m.part_of));
|
||||
await loadRacesStatus();
|
||||
} catch (e) {
|
||||
setError(asUiError(e));
|
||||
@@ -328,6 +331,28 @@ export function ModulesPage({ serverId, onChanged, onRegisterGuard }: { serverId
|
||||
{selected.id === "custom-races" && <RaceAvailabilitySettings serverId={serverId}
|
||||
blocked={racesInstalling || toggling !== null} onSaved={() => setChanged(true)}
|
||||
onRegisterGuard={setRacesGuard} />}
|
||||
{parts.filter(p => p.part_of === selected.id && p.installed).map(p => (
|
||||
<section key={p.id} className="mt-6 border-t border-line pt-5" aria-label={p.name}>
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h3 className="font-semibold">{p.name}</h3>
|
||||
<p className="mt-1 text-sm text-muted">{p.description[locale] ?? p.description.en}</p>
|
||||
</div>
|
||||
{p.switchable && <button
|
||||
role="switch"
|
||||
aria-checked={p.enabled}
|
||||
aria-label={t("mod.switch", { name: p.name })}
|
||||
aria-busy={toggling === p.id}
|
||||
disabled={toggling !== null || racesInstalling}
|
||||
onClick={() => void toggle(p)}
|
||||
className={cn("relative mt-1 h-6 w-11 shrink-0 cursor-pointer rounded-full transition-colors", p.enabled ? "bg-gold" : "bg-white/15")}
|
||||
>
|
||||
<span className={cn("absolute top-0.5 h-5 w-5 rounded-full bg-white transition-all", p.enabled ? "left-[22px]" : "left-0.5")} />
|
||||
</button>}
|
||||
</div>
|
||||
{p.enabled && p.has_settings && <ModuleSettings serverId={serverId} module={p} onSaved={() => setChanged(true)} />}
|
||||
</section>
|
||||
))}
|
||||
</SettingsPanel>
|
||||
)}
|
||||
</Fragment>
|
||||
|
||||
Reference in new issue
Block a user