mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-25 19:25:56 +00:00
Phase 1/2: Tauri shell, React UI (welcome, read-only import, overview with start/stop), e2e driver
Verified in the native window against a disposable fixture: import writes only <folder>.manager + registry; start surfaces a human 'database update required' message; stop returns to Offline. Live install untouched throughout. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bbf06793ba
commit
2e8803a067
50 files changed
+7331
-9
No files matched your search
+56
@@ -0,0 +1,56 @@
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { api, type ServerSummary } from "@/lib/api";
|
||||
import { Welcome } from "@/screens/Welcome";
|
||||
import { ImportServer } from "@/screens/ImportServer";
|
||||
import { Shell } from "@/screens/Shell";
|
||||
|
||||
type View = "welcome" | "import";
|
||||
|
||||
export default function App() {
|
||||
const [servers, setServers] = useState<ServerSummary[] | null>(null);
|
||||
const [view, setView] = useState<View>("welcome");
|
||||
const [activeId, setActiveId] = useState<string | null>(null);
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
const list = await api.list().catch(() => []);
|
||||
setServers(list);
|
||||
setActiveId((cur) => (cur && list.some((s) => s.id === cur) ? cur : (list[0]?.id ?? null)));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
void refresh();
|
||||
}, [refresh]);
|
||||
|
||||
if (servers === null) return null;
|
||||
|
||||
if (servers.length > 0 && view === "welcome" && activeId) {
|
||||
return (
|
||||
<Shell
|
||||
servers={servers}
|
||||
activeId={activeId}
|
||||
onSelect={setActiveId}
|
||||
onAddAnother={() => setView("import")}
|
||||
onForget={async (id) => {
|
||||
await api.forget(id);
|
||||
await refresh();
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (view === "import") {
|
||||
return (
|
||||
<ImportServer
|
||||
canCancel={servers.length > 0}
|
||||
onCancel={() => setView("welcome")}
|
||||
onAdded={async (s) => {
|
||||
await refresh();
|
||||
setActiveId(s.id);
|
||||
setView("welcome");
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return <Welcome onImport={() => setView("import")} />;
|
||||
}
|
||||
Reference in new issue
Block a user