From 5427bc76230b97bb7d52e2f148f405e25c119d70 Mon Sep 17 00:00:00 2001 From: Lemon-miaow Date: Fri, 3 Jul 2026 01:51:53 +0800 Subject: [PATCH] feat(servers): support claiming servers directly from ServersPage list --- panel/src/pages/servers/ServersPage.tsx | 76 ++++++++++++++++--------- 1 file changed, 50 insertions(+), 26 deletions(-) diff --git a/panel/src/pages/servers/ServersPage.tsx b/panel/src/pages/servers/ServersPage.tsx index cf9bfa6..a62b41b 100644 --- a/panel/src/pages/servers/ServersPage.tsx +++ b/panel/src/pages/servers/ServersPage.tsx @@ -12,6 +12,7 @@ import { Users, AlertTriangle, UserRound, + Hand, } from "lucide-react"; import { useTranslation } from "react-i18next"; import { Card, CardContent } from "@/components/ui/card"; @@ -108,7 +109,7 @@ function Stat({ export function ServersPage() { const { t } = useTranslation(["ops", "servers"]); - const { isAdmin } = useTier(); + const { isAdmin, identity } = useTier(); const cfg = useConfig(); const fetchFn = useMemo(() => (isAdmin ? api.fleet : api.myServers), [isAdmin]); @@ -146,6 +147,8 @@ export function ServersPage() { playersMax: s.playersMax, owner: s.owner, endpointAddress: s.endpointAddress, + claimable: !s.owner, + owned: s.owner === identity?.email, })); } else { return (data as ServerInfo[]).map((s) => ({ @@ -162,7 +165,7 @@ export function ServersPage() { owned: s.owned, })); } - }, [data, isAdmin, t]); + }, [data, isAdmin, t, identity]); const stats = useMemo(() => { const counts: Record = { @@ -429,10 +432,10 @@ function ServerRow({ }) { const { t } = useTranslation("ops"); const { t: ts } = useTranslation("servers"); - const [busy, setBusy] = useState(null); + const [busy, setBusy] = useState(null); const [error, setError] = useState(null); - async function act(kind: "wake" | "stop", fn: () => Promise) { + async function act(kind: "wake" | "stop" | "claim", fn: () => Promise) { setBusy(kind); setError(null); try { @@ -514,30 +517,51 @@ function ServerRow({
- {live ? ( - + {server.claimable && !server.owned ? ( + <> + + + ) : ( - + <> + {live ? ( + + ) : ( + + )} + {(server.owned || isAdmin) && ( + + + + )} + )} - - -