Server Migration: real analysis and a real modular copy

The page was a mock: it never read the database (always 0 accounts),
showed a hard-coded schema and core version, looked for server files in
the wrong folder, and its "transfer" reported accounts, characters and
tables as moved without moving anything. Its locale was fixed to "ru".

- remove server_migration.rs and its three commands
- modular_copy::preview: classic/modular core, version, database state,
  counts and schemas from a running database (read only), database size,
  settings files, extra worlds; nothing is started or changed
- the page shows that and hands over to the same modular-copy install
  screen as "Manage another server"; texts in en and ru via i18n
- the modular copy now carries world settings changed in Server
  Configuration (Settings/worldserver.conf.template was not copied)
- E2E preview_bare_and_copy_e2e checks the preview and the carried
  setting; passes against preview core 0.261108.9501

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ДмитрийandClaude Opus 5.5 committed 2026-11-11 09:22:22 +05:00
1 parent 6091e545f8
commit fdbf38ee4e
14 files changed
+495 -1260

No files matched your search

+9 -1
View File
@@ -21,6 +21,8 @@ function Main() {
const [activeId, setActiveId] = useState<string | null>(null);
// A classic server the owner chose: the install screen makes a modular copy of it next to it.
const [copyFrom, setCopyFrom] = useState<string | null>(null);
// Where Cancel on that install screen goes back to: the import screen or the server's own pages.
const [copyBack, setCopyBack] = useState<View>("import");
const refresh = useCallback(async () => {
const list = await api.list().catch(() => []);
@@ -46,6 +48,11 @@ function Main() {
activeId={activeId}
onSelect={setActiveId}
onAddAnother={() => setView("add")}
onCopy={(path) => {
setCopyFrom(path);
setCopyBack("welcome");
setView("install");
}}
onForget={async (id) => {
await api.forget(id);
await refresh();
@@ -60,7 +67,7 @@ function Main() {
canCancel
copyFrom={copyFrom ?? undefined}
onCancel={() => {
setView(copyFrom ? "import" : servers.length > 0 ? "add" : "welcome");
setView(copyFrom ? copyBack : servers.length > 0 ? "add" : "welcome");
setCopyFrom(null);
}}
onDone={async (s) => {
@@ -85,6 +92,7 @@ function Main() {
}}
onCopy={(path) => {
setCopyFrom(path);
setCopyBack("import");
setView("install");
}}
/>
+1
View File
@@ -50,6 +50,7 @@ export {};
if(cmd==="play") return {ok:true,exit_code:null,code:null,human:null,output:""};
if(cmd==="list_servers") return added?[{id:"1",name:"CoA-Repack",path:report.path}]:[];
if(cmd==="scan_server") return report;
if(cmd==="modular_copy_preview"){await new Promise(r=>setTimeout(r,400));const p=String(args.path);if(!/repack|server/i.test(p))return {path:p,classic:false,modular:false,version:null,database:"missing",accounts:null,characters:null,schemas:[],database_bytes:0,config_files:[],extra_worlds:[]};const run=!/stopped/i.test(p);return {path:p,classic:true,modular:false,version:"0.261108.95",database:run?"running":"stopped",accounts:run?12:null,characters:run?37:null,schemas:run?["acore_auth","acore_characters","acore_playerbots","acore_world"]:[],database_bytes:6.3*2**30,config_files:["Core/configs/modules/mod-coa-content-scaling.conf","Core/configs/modules/playerbots.conf","Settings/realm-profile.json"],extra_worlds:run?[]:["secondary"]};}
if(cmd==="add_server"){added=true;return {id:"1",name:"CoA-Repack",path:report.path};}
if(cmd==="server_status"){const s=running?"running":"stopped";return {observed:{mysql:svc("mysql",3307,s),auth:svc("auth",3724,s),world:svc("world",8085,s),secondary_world:simultaneous?svc("world-secondary",8086,s):null,reborn_world:withReborn?svc("world-reborn",8087,s):null},busy:false,path_exists:true};}
if(cmd==="start_server"){await new Promise((r: any)=>setTimeout(r,1500));running=true;return {ok:true,exit_code:0,code:null,human:null,output:""};}
+44 -1
View File
@@ -865,7 +865,50 @@ const en = {
"realm.confirmDelete": "Remove the realmlist “{name}”? The game client keeps whatever file it has now.",
"nav.modules": "Modules",
"nav.migration": "Server Migration",
"q.migration": "Migrate data from an existing server into this Preview realm",
"q.migration": "Move a server with the classic core to the modular core: a copy next to it",
"migrate.title": "Server migration",
"migrate.subtitle": "A server with the classic core is not converted in place. A new server with the modular core is installed next to it, and its accounts, characters, world, bots and module settings are copied into it.",
"migrate.source": "Which server to move",
"migrate.browse": "Browse…",
"migrate.inspect": "Check",
"migrate.dialogTitle": "Choose the server's main folder",
"migrate.readOnly": "Checking only reads the folder; a running database is only asked for counts. Nothing is started or changed.",
"migrate.classic.title": "Classic core: it can be copied",
"migrate.classic.text": "The copy becomes a new server with the modular core. This server stays as it is.",
"migrate.modular.title": "Already the modular core",
"migrate.modular.text": "Nothing to move. To manage this server here, add it with “Manage another server”.",
"migrate.none.title": "No server found here",
"migrate.none.text": "This folder has no Core\\worldserver.exe of a Windows server. Choose the server's main folder.",
"migrate.fact.version": "Version",
"migrate.fact.database": "Database",
"migrate.fact.accounts": "Accounts",
"migrate.fact.characters": "Characters",
"migrate.unknown": "unknown",
"migrate.countLater": "counted while copying",
"migrate.db.running": "running",
"migrate.db.stopped": "stopped",
"migrate.db.missing": "not found",
"migrate.db.missingText": "This server has no database folder (mysql\\data), so there is nothing to copy.",
"migrate.copied": "What is copied",
"migrate.copied.schemas": "Every game database: {list}.",
"migrate.copied.allSchemas": "Every game database (accounts, characters, world, bots); the list is read while copying.",
"migrate.copied.settings": "Module settings and realm profiles: {n} files.",
"install.copy.worldSkipped": "World settings the new version did not take:",
"install.copy.worldSettings": "World settings carried over: {n}.",
"migrate.copied.world": "World settings changed in Server Configuration (rates and the like).",
"migrate.copied.ports": "Ports and the console login, as the old server has them.",
"migrate.copied.modules": "The modules the old server has switched on are built for the modular core during the copy.",
"migrate.copied.worlds": "Extra worlds ({list}): their databases go along and they stay switched on.",
"migrate.notCopied": "What is not copied",
"migrate.notCopied.conf": "worldserver.conf and authserver.conf themselves: the new server makes them from its own templates. Values changed in Server Configuration are set on the new server.",
"migrate.notCopied.merge": "Nothing is merged into {name} or any other existing server: the copy is always a new server in a new folder.",
"migrate.risks": "Before you start",
"migrate.risk.oldKept": "The old server is only read. Its folder and database are not changed, and you can keep using it.",
"migrate.risk.ports": "Both servers use the same ports: run only one of them at a time.",
"migrate.risk.running": "Its database is running and is read as it is at that moment. Stop its world first so players and bots do not change data while it is copied.",
"migrate.risk.stopped": "Its database is stopped: its files ({gb} GB) are copied once more while they are read, so that much extra space is needed.",
"migrate.risk.build": "Modules are compiled on this PC with Microsoft's C++ build tools; the SQUID bots alone can take up to an hour.",
"migrate.start": "Make the modular copy",
"q.modules": "What extra features does the server have?",
"mod.ahbot.types": "Item types for sale",
"mod.ahbot.typesHint": "Choose types for new listings. Existing auctions remain. Enabling a type restores its previous weights in this session, or the configured defaults.",
+44 -1
View File
@@ -849,7 +849,50 @@ const ru: Partial<Record<keyof typeof en, string>> = {
"realm.confirmDelete": "Удалить реалмлист «{name}»? В игровом клиенте останется текущий файл.",
"nav.modules": "Модули",
"nav.migration": "Перенос сервера",
"q.migration": "Перенос данных из существующего сервера в этот мир Preview",
"q.migration": "Перенос сервера с классическим ядром на модульное: копия рядом",
"migrate.title": "Перенос сервера",
"migrate.subtitle": "Сервер с классическим ядром не переделывается на месте. Рядом ставится новый сервер с модульным ядром, и в него копируются аккаунты, персонажи, мир, боты и настройки модулей.",
"migrate.source": "Какой сервер перенести",
"migrate.browse": "Обзор…",
"migrate.inspect": "Проверить",
"migrate.dialogTitle": "Выберите основную папку сервера",
"migrate.readOnly": "Проверка только читает папку; у запущенной базы лишь спрашивает количество. Ничего не запускается и не меняется.",
"migrate.classic.title": "Классическое ядро: можно скопировать",
"migrate.classic.text": "Копия станет новым сервером с модульным ядром. Этот сервер останется как есть.",
"migrate.modular.title": "Уже модульное ядро",
"migrate.modular.text": "Переносить нечего. Чтобы управлять этим сервером здесь, добавьте его через «Manage another server».",
"migrate.none.title": "Сервер не найден",
"migrate.none.text": "В этой папке нет Core\\worldserver.exe Windows-сервера. Выберите основную папку сервера.",
"migrate.fact.version": "Версия",
"migrate.fact.database": "База данных",
"migrate.fact.accounts": "Аккаунтов",
"migrate.fact.characters": "Персонажей",
"migrate.unknown": "неизвестна",
"migrate.countLater": "посчитаем при копировании",
"migrate.db.running": "запущена",
"migrate.db.stopped": "остановлена",
"migrate.db.missing": "не найдена",
"migrate.db.missingText": "У этого сервера нет папки базы данных (mysql\\data), копировать нечего.",
"migrate.copied": "Что копируется",
"migrate.copied.schemas": "Все игровые базы: {list}.",
"migrate.copied.allSchemas": "Все игровые базы (аккаунты, персонажи, мир, боты); список прочитаем при копировании.",
"migrate.copied.settings": "Настройки модулей и профили миров: файлов — {n}.",
"install.copy.worldSkipped": "Настройки мира, которые новая версия не приняла:",
"install.copy.worldSettings": "Перенесено настроек мира: {n}.",
"migrate.copied.world": "Настройки мира, изменённые в Server Configuration (рейты и т. п.).",
"migrate.copied.ports": "Порты и вход в консоль, как у старого сервера.",
"migrate.copied.modules": "Модули, включённые на старом сервере, собираются под модульное ядро во время копирования.",
"migrate.copied.worlds": "Дополнительные миры ({list}): их базы копируются, и они остаются включёнными.",
"migrate.notCopied": "Что не копируется",
"migrate.notCopied.conf": "Сами worldserver.conf и authserver.conf: новый сервер делает их из своих шаблонов. Значения, изменённые в Server Configuration, задаются на новом сервере.",
"migrate.notCopied.merge": "Ничего не сливается в {name} или другой существующий сервер: копия — всегда новый сервер в новой папке.",
"migrate.risks": "Перед началом",
"migrate.risk.oldKept": "Старый сервер только читается. Его папка и база не меняются, им можно продолжать пользоваться.",
"migrate.risk.ports": "У обоих серверов одинаковые порты: запускайте только один из них.",
"migrate.risk.running": "Его база запущена и будет прочитана в том виде, в каком она в этот момент. Сначала остановите его мир, чтобы игроки и боты не меняли данные во время копирования.",
"migrate.risk.stopped": "Его база остановлена: её файлы ({gb} ГБ) на время чтения копируются ещё раз, нужно столько же свободного места.",
"migrate.risk.build": "Модули компилируются на этом ПК инструментами сборки C++ от Microsoft; одни только боты SQUID могут собираться до часа.",
"migrate.start": "Сделать модульную копию",
"q.modules": "Какие дополнительные возможности есть у сервера?",
"mod.ahbot.types": "Типы предметов в продаже",
"mod.ahbot.typesHint": "Выберите типы для новых лотов. Уже выставленные лоты останутся. При включении возвращаются прежние веса этой сессии или значения по умолчанию.",
+16 -73
View File
@@ -510,6 +510,8 @@ export interface CopyReport {
characters: number;
config_files: string[];
read_from: string;
world_settings: string[];
world_settings_skipped: string[];
}
export interface InstallStep {
@@ -698,73 +700,19 @@ export interface CrashItem {
}
export type SourceClassification = "CSM_MANAGED_COA" | "LEGACY_EMBEDDED_COA" | "STANDARD_AZEROTH_CORE" | "UNKNOWN_CUSTOM";
export interface DetectedModule {
id: string;
name: string;
detected_via: string;
version?: string | null;
has_database_data: boolean;
is_supported_by_preview: boolean;
}
export interface SourceInspectionReport {
source_path: string;
source_type: SourceClassification;
core_version?: string | null;
schema_version?: string | null;
accounts_count: number;
characters_count: number;
detected_modules: DetectedModule[];
module_tables: Record<string, string[]>;
custom_race_support: boolean;
compatibility_notes: string[];
}
export interface MigrationScope {
accounts_and_characters: boolean;
module_owned_data: boolean;
server_configuration: boolean;
selected_modules: string[];
}
export type ConflictResolutionPolicy = "remap_colliding_guids" | "skip_colliding_guids" | "overwrite_existing";
export interface AdapterPlan {
module_id: string;
source_tables: string[];
dest_tables: string[];
data_loss_risks: string[];
requires_conversion: boolean;
}
export interface MigrationPlan {
plan_id: string;
source_path: string;
dest_realm_path: string;
source_report: SourceInspectionReport;
scope: MigrationScope;
conflict_policy: ConflictResolutionPolicy;
adapters: AdapterPlan[];
tables_to_migrate: string[];
quarantined_tables: string[];
estimated_disk_mb: number;
warnings: string[];
}
export interface MigrationExecutionReport {
success: boolean;
backup_path?: string | null;
accounts_transferred: number;
characters_transferred: number;
items_transferred: number;
modules_migrated: string[];
tables_migrated: string[];
quarantined_tables: string[];
warnings: string[];
errors: string[];
duration_ms: number;
/** What a modular copy of a server would take, read without changing anything (`modular_copy::preview`). */
export interface CopyPreview {
path: string;
classic: boolean;
modular: boolean;
version: string | null;
database: "running" | "stopped" | "missing";
accounts: number | null;
characters: number | null;
schemas: string[];
database_bytes: number;
config_files: string[];
extra_worlds: string[];
}
export type SolverVerdict =
@@ -919,12 +867,7 @@ export const api = {
invoke<InstalledPreviewPlugin[]>("preview_list_installed_plugins", { realmId }),
previewExportDiagnostics: (realmId?: string) =>
invoke<string>("preview_export_diagnostics", { realmId: realmId ?? null }),
previewMigrationInspect: (sourcePath: string) =>
invoke<SourceInspectionReport>("preview_migration_inspect", { sourcePath }),
previewMigrationPlan: (sourcePath: string, destRealmId: string, scope: MigrationScope, conflictPolicy: ConflictResolutionPolicy) =>
invoke<MigrationPlan>("preview_migration_plan", { sourcePath, destRealmId, scope, conflictPolicy }),
previewMigrationExecute: (plan: MigrationPlan) =>
invoke<MigrationExecutionReport>("preview_migration_execute", { plan }),
modularCopyPreview: (path: string) => invoke<CopyPreview>("modular_copy_preview", { path }),
previewCheckUpdates: (realmId: string) =>
invoke<SolverVerdict>("preview_check_updates", { realmId }),
};
+7
View File
@@ -143,8 +143,15 @@ export function InstallServer(props: { canCancel: boolean; copyFrom?: string; on
{copied && (
<p className="mt-3 text-sm text-muted">
{t("install.copy.done", { accounts: copied.accounts, characters: copied.characters, settings: copied.config_files.length })}
{" "}{t("install.copy.worldSettings", { n: copied.world_settings.length })}
</p>
)}
{copied && copied.world_settings_skipped.length > 0 && (
<Card className="mt-6 border-warn/40 p-4 text-left">
<p className="text-sm text-warn">{t("install.copy.worldSkipped")}</p>
<pre className="selectable mt-2 max-h-32 overflow-auto whitespace-pre-wrap rounded bg-black/40 p-2 text-xs">{copied.world_settings_skipped.join("\n")}</pre>
</Card>
)}
{classicCore && (
<Card className="mt-6 border-warn/40 p-4 text-left" role="alert">
<p className="font-medium text-warn">{t("install.classicCoreTitle")}</p>
+155 -547
View File
@@ -1,581 +1,189 @@
import { useState } from "react";
import { open } from "@tauri-apps/plugin-dialog";
import {
AlertCircle,
AlertTriangle,
ArrowRight,
CheckCircle2,
Database,
FileCheck,
FolderOpen,
Loader2,
RotateCcw,
Server,
Shield,
ShieldCheck,
Users,
} from "lucide-react";
import { AlertTriangle, ArrowRight, Check, Database, FolderOpen, Info, Loader2 } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import {
api,
type ConflictResolutionPolicy,
type MigrationExecutionReport,
type MigrationPlan,
type MigrationScope,
type SourceInspectionReport,
} from "@/lib/api";
import { cn } from "@/lib/utils";
import { api, asUiError, type CopyPreview, type ServerSummary, type UiError } from "@/lib/api";
import { useHuman, useT } from "@/i18n";
export interface ServerMigrationWizardProps {
currentRealmId: string;
onClose?: () => void;
onSuccess?: () => void;
}
/**
* Moving a server to the modular core. A server with the classic core is never converted in place: a new server is
* installed next to it and its data is copied there (`modular_copy`). This page shows what the old server holds and
* what the copy takes, then hands over to the same install screen "Manage another server" uses for a modular copy.
*/
export function ServerMigrationWizard(props: {
servers: ServerSummary[];
currentName: string;
onCopy: (path: string) => void;
}) {
const t = useT();
const human = useHuman();
const [path, setPath] = useState("");
const [busy, setBusy] = useState(false);
const [info, setInfo] = useState<CopyPreview | null>(null);
const [error, setError] = useState<UiError | null>(null);
type WizardStep = "source" | "inspect" | "scope" | "plan" | "executing" | "result";
export function ServerMigrationWizard({
currentRealmId,
onClose,
onSuccess,
}: ServerMigrationWizardProps) {
const locale = "ru";
const [step, setStep] = useState<WizardStep>("source");
const [sourcePath, setSourcePath] = useState("");
const [inspecting, setInspecting] = useState(false);
const [report, setReport] = useState<SourceInspectionReport | null>(null);
// Scope
const [scope, setScope] = useState<MigrationScope>({
accounts_and_characters: true,
module_owned_data: true,
server_configuration: true,
selected_modules: [],
});
// Conflict policy
const [conflictPolicy, setConflictPolicy] = useState<ConflictResolutionPolicy>(
"remap_colliding_guids"
);
// Plan & Execution
const [planning, setPlanning] = useState(false);
const [plan, setPlan] = useState<MigrationPlan | null>(null);
const [executing, setExecuting] = useState(false);
const [execReport, setExecReport] = useState<MigrationExecutionReport | null>(null);
const [errorMsg, setErrorMsg] = useState<string | null>(null);
async function handlePickSource() {
setErrorMsg(null);
async function inspect(p: string) {
if (!p.trim()) return;
setPath(p);
setError(null);
setInfo(null);
setBusy(true);
try {
const selected = await open({
directory: true,
multiple: false,
title: locale === "ru" ? "Выберите каталог исходного сервера" : "Select Source Server Directory",
});
if (typeof selected === "string") {
setSourcePath(selected);
}
setInfo(await api.modularCopyPreview(p.trim()));
} catch (e) {
setErrorMsg(String(e));
setError(asUiError(e));
} finally {
setBusy(false);
}
}
async function handleInspect() {
if (!sourcePath.trim()) return;
setErrorMsg(null);
setInspecting(true);
try {
const res = await api.previewMigrationInspect(sourcePath);
setReport(res);
// Auto-select detected modules
setScope((prev) => ({
...prev,
selected_modules: res.detected_modules.map((m) => m.id),
}));
setStep("inspect");
} catch (e: any) {
setErrorMsg(e?.human?.message || e?.technical || String(e));
} finally {
setInspecting(false);
}
async function browse() {
const picked = await open({ directory: true, multiple: false, title: t("migrate.dialogTitle") });
if (typeof picked === "string") await inspect(picked);
}
async function handleCreatePlan() {
if (!report) return;
setErrorMsg(null);
setPlanning(true);
try {
const res = await api.previewMigrationPlan(sourcePath, currentRealmId, scope, conflictPolicy);
setPlan(res);
setStep("plan");
} catch (e: any) {
setErrorMsg(e?.human?.message || e?.technical || String(e));
} finally {
setPlanning(false);
}
}
async function handleExecute() {
if (!plan) return;
setErrorMsg(null);
setExecuting(true);
setStep("executing");
try {
const res = await api.previewMigrationExecute(plan);
setExecReport(res);
setStep("result");
if (res.success && onSuccess) {
onSuccess();
}
} catch (e: any) {
setErrorMsg(e?.human?.message || e?.technical || String(e));
setStep("plan");
} finally {
setExecuting(false);
}
}
const gb = (bytes: number) => (bytes / 1024 ** 3).toFixed(1);
const count = (n: number | null) => (n === null ? t("migrate.countLater") : String(n));
return (
<div className="flex h-full flex-col max-w-4xl mx-auto p-6 space-y-6">
{/* Header */}
<div className="flex items-center justify-between border-b border-line pb-4">
<div>
<h2 className="text-xl font-bold tracking-tight text-ink flex items-center gap-2">
<RotateCcw className="h-6 w-6 text-gold" />
{locale === "ru" ? "Центр переноса сервера" : "Server Migration Center"}
<span className="rounded bg-sky-500/20 px-2 py-0.5 text-xs font-mono font-medium text-sky-400">
MIGRATION WIZARD
</span>
</h2>
<p className="mt-1 text-xs text-muted">
{locale === "ru"
? "Перенос персонажей, аккаунтов, данных модулей и конфигураций в изолированный модульный сервер Preview."
: "Migrate characters, accounts, module data and configs into an isolated modular Preview realm."}
</p>
</div>
{onClose && (
<Button size="sm" variant="ghost" onClick={onClose} className="text-xs">
{locale === "ru" ? "Закрыть" : "Close"}
</Button>
<div className="mx-auto flex max-w-3xl flex-col gap-5 px-8 py-8">
<div>
<h1 className="text-2xl font-semibold">{t("migrate.title")}</h1>
<p className="mt-1 text-sm text-muted">{t("migrate.subtitle")}</p>
</div>
<Card className="flex flex-col gap-3 p-5">
<h2 className="font-semibold">{t("migrate.source")}</h2>
{props.servers.length > 0 && (
<div className="flex flex-wrap gap-2">
{props.servers.map((s) => (
<Button key={s.id} variant="secondary" size="sm" disabled={busy} onClick={() => void inspect(s.path)}>
{s.name}
</Button>
))}
</div>
)}
</div>
<div className="flex gap-2">
<input
className="flex-1 rounded-md border border-line bg-bg px-3 py-2 font-mono text-sm outline-none focus:border-gold"
value={path}
placeholder="C:\Games\CoA Server"
onChange={(e) => setPath(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && void inspect(path)}
/>
<Button variant="secondary" onClick={() => void browse()} disabled={busy}>
<FolderOpen className="mr-2 h-4 w-4" aria-hidden /> {t("migrate.browse")}
</Button>
<Button onClick={() => void inspect(path)} disabled={busy || !path.trim()}>
{busy ? <Loader2 className="h-4 w-4 animate-spin" aria-hidden /> : t("migrate.inspect")}
</Button>
</div>
<p className="text-xs text-muted">{t("migrate.readOnly")}</p>
</Card>
{errorMsg && (
<Card className="border-bad/40 bg-bad/5 p-4 text-xs text-bad flex items-start gap-2.5">
<AlertCircle className="h-4 w-4 shrink-0 mt-0.5" />
<div className="flex-1">
<p className="font-semibold">{locale === "ru" ? "Ошибка переноса" : "Migration Error"}</p>
<p className="mt-0.5 whitespace-pre-wrap">{errorMsg}</p>
</div>
{error && (
<Card className="border-bad/40 p-4" role="alert">
<p className="font-medium text-bad">{human(error.human).title}</p>
<p className="mt-1 text-sm text-muted">{human(error.human).message}</p>
</Card>
)}
{/* Stepper Progress */}
<div className="flex items-center justify-between text-xs font-medium text-muted px-2">
<span className={cn(step === "source" && "text-gold font-bold")}>1. Исходный сервер</span>
<ArrowRight className="h-3 w-3 text-line" />
<span className={cn(step === "inspect" && "text-gold font-bold")}>2. Анализ данных</span>
<ArrowRight className="h-3 w-3 text-line" />
<span className={cn(step === "scope" && "text-gold font-bold")}>3. Область переноса</span>
<ArrowRight className="h-3 w-3 text-line" />
<span className={cn(step === "plan" && "text-gold font-bold")}>4. План и риски</span>
<ArrowRight className="h-3 w-3 text-line" />
<span className={cn((step === "executing" || step === "result") && "text-gold font-bold")}>5. Перенос</span>
</div>
{/* STEP 1: SELECT SOURCE */}
{step === "source" && (
<Card className="p-6 space-y-4">
<h3 className="text-sm font-semibold text-ink flex items-center gap-2">
<FolderOpen className="h-4 w-4 text-gold" />
{locale === "ru" ? "Шаг 1: Укажите каталог исходного сервера" : "Step 1: Select Source Server"}
</h3>
<p className="text-xs text-muted">
{locale === "ru"
? "Поддерживаются серверы под управлением CoA Server Manager, устаревшие CoA-серверы со встроенными ботами, а также стандартные серверы AzerothCore."
: "Supports CSM-managed servers, legacy embedded CoA installations, and standard AzerothCore."}
</p>
<div className="flex items-center gap-3">
<input
type="text"
value={sourcePath}
onChange={(e) => setSourcePath(e.target.value)}
placeholder="C:\games\CoA Server или путь к серверу..."
className="flex-1 rounded-md border border-line bg-bg px-3 py-2 text-xs text-ink focus:border-gold focus:outline-none font-mono"
/>
<Button size="sm" variant="secondary" onClick={handlePickSource}>
<FolderOpen className="h-3.5 w-3.5 mr-1.5" />
{locale === "ru" ? "Обзор..." : "Browse..."}
</Button>
</div>
<div className="rounded-lg bg-white/5 border border-line p-3 text-xs text-muted space-y-1">
<p className="font-semibold text-ink flex items-center gap-1.5">
<ShieldCheck className="h-4 w-4 text-ok" />
{locale === "ru" ? "Гарантия безопасности данных" : "Safety Guarantee"}
</p>
<p>
{locale === "ru"
? "Анализ выполняется строго в режиме чтения (Read-Only). Никакие скрипты и изменения на исходном сервере не выполняются."
: "Source server inspection is strictly read-only. No scripts or writes are performed."}
</p>
</div>
<div className="flex justify-end pt-2">
<Button
size="sm"
variant="primary"
disabled={!sourcePath.trim() || inspecting}
onClick={handleInspect}
>
{inspecting && <Loader2 className="h-3.5 w-3.5 mr-1.5 animate-spin" />}
{locale === "ru" ? "Проанализировать сервер" : "Inspect Server"}
<ArrowRight className="h-3.5 w-3.5 ml-1.5" />
</Button>
</div>
</Card>
)}
{/* STEP 2: INSPECTION REPORT */}
{step === "inspect" && report && (
<Card className="p-6 space-y-4">
<h3 className="text-sm font-semibold text-ink flex items-center gap-2">
<Server className="h-4 w-4 text-gold" />
{locale === "ru" ? "Шаг 2: Результаты анализа исходного сервера" : "Step 2: Source Inspection Results"}
</h3>
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
<div className="rounded-lg border border-line bg-card p-3">
<span className="text-[11px] text-muted">{locale === "ru" ? "Тип сервера" : "Server Type"}</span>
<p className="mt-1 font-mono text-xs font-semibold text-ink">
{report.source_type === "CSM_MANAGED_COA" && "CSM Managed CoA"}
{report.source_type === "LEGACY_EMBEDDED_COA" && "Legacy CoA (Embedded)"}
{report.source_type === "STANDARD_AZEROTH_CORE" && "Standard AzerothCore"}
{report.source_type === "UNKNOWN_CUSTOM" && "Custom Layout"}
</p>
</div>
<div className="rounded-lg border border-line bg-card p-3">
<span className="text-[11px] text-muted">{locale === "ru" ? "Аккаунтов" : "Accounts"}</span>
<p className="mt-1 font-mono text-xs font-semibold text-ink flex items-center gap-1.5">
<Users className="h-3.5 w-3.5 text-gold" />
{report.accounts_count}
</p>
</div>
<div className="rounded-lg border border-line bg-card p-3">
<span className="text-[11px] text-muted">{locale === "ru" ? "Персонажей" : "Characters"}</span>
<p className="mt-1 font-mono text-xs font-semibold text-ink flex items-center gap-1.5">
<Users className="h-3.5 w-3.5 text-sky-400" />
{report.characters_count}
</p>
</div>
<div className="rounded-lg border border-line bg-card p-3">
<span className="text-[11px] text-muted">{locale === "ru" ? "Схема БД" : "DB Schema"}</span>
<p className="mt-1 font-mono text-xs font-semibold text-ink">
{report.schema_version ?? "2026_10_28_00"}
</p>
</div>
</div>
{/* Detected Modules */}
<div>
<h4 className="text-xs font-semibold text-ink mb-2">
{locale === "ru" ? "Обнаруженные модули и таблицы:" : "Detected Modules & Tables:"}
</h4>
{report.detected_modules.length === 0 ? (
<p className="text-xs text-muted italic">
{locale === "ru" ? "Сторонние модули не обнаружены." : "No external modules detected."}
</p>
{info && (
<Card className="flex flex-col gap-4 p-5">
<div className="flex items-start gap-3">
{info.classic ? (
<Check className="mt-0.5 h-5 w-5 text-ok" aria-hidden />
) : (
<div className="divide-y divide-line border border-line rounded-lg">
{report.detected_modules.map((m) => (
<div key={m.id} className="p-3 flex items-center justify-between text-xs">
<div>
<p className="font-semibold text-ink">{m.name} <span className="font-mono text-[11px] text-muted">({m.id})</span></p>
<p className="text-[11px] text-muted">Обнаружен через: {m.detected_via}</p>
</div>
<span className="rounded bg-ok/10 text-ok border border-ok/30 px-2 py-0.5 text-[11px] font-medium">
✓ Адаптер готов
</span>
</div>
))}
</div>
<Info className="mt-0.5 h-5 w-5 text-warn" aria-hidden />
)}
</div>
<div className="flex justify-between pt-2">
<Button size="sm" variant="ghost" onClick={() => setStep("source")}>
{locale === "ru" ? "Назад" : "Back"}
</Button>
<Button size="sm" variant="primary" onClick={() => setStep("scope")}>
{locale === "ru" ? "Настроить перенос" : "Configure Scope"}
<ArrowRight className="h-3.5 w-3.5 ml-1.5" />
</Button>
</div>
</Card>
)}
{/* STEP 3: SCOPE & CONFLICT RESOLUTION */}
{step === "scope" && report && (
<Card className="p-6 space-y-5">
<h3 className="text-sm font-semibold text-ink flex items-center gap-2">
<Database className="h-4 w-4 text-gold" />
{locale === "ru" ? "Шаг 3: Выбор категорий данных и политика конфликтов" : "Step 3: Migration Scope"}
</h3>
<div className="space-y-3">
<label className="flex items-start gap-3 p-3 rounded-lg border border-line bg-card cursor-pointer hover:border-gold/40">
<input
type="checkbox"
checked={scope.accounts_and_characters}
onChange={(e) => setScope({ ...scope, accounts_and_characters: e.target.checked })}
className="mt-0.5 h-4 w-4 rounded border-line text-gold focus:ring-gold"
/>
<div>
<p className="text-xs font-semibold text-ink">
{locale === "ru" ? "Аккаунты и персонажи" : "Accounts & Characters"}
</p>
<p className="text-[11px] text-muted">
{locale === "ru"
? "Учетные записи, персонажи, инвентарь, таланты, заклинания, символы, навыки, репутация, квесты и питомцы."
: "Accounts, characters, inventory, spells, talents, glyphs, skills, reputation, quests, and pets."}
</p>
</div>
</label>
<label className="flex items-start gap-3 p-3 rounded-lg border border-line bg-card cursor-pointer hover:border-gold/40">
<input
type="checkbox"
checked={scope.module_owned_data}
onChange={(e) => setScope({ ...scope, module_owned_data: e.target.checked })}
className="mt-0.5 h-4 w-4 rounded border-line text-gold focus:ring-gold"
/>
<div>
<p className="text-xs font-semibold text-ink">
{locale === "ru" ? "Данные модулей" : "Module-owned Data"}
</p>
<p className="text-[11px] text-muted">
{locale === "ru"
? "Сохраненные боты (Companions/Playerbots), данные масштабирования контента, таблицы аукцион-бота и зачарователя."
: "Saved bot configurations, content scaling overrides, AH bot data, and NPC enchanter states."}
</p>
</div>
</label>
<label className="flex items-start gap-3 p-3 rounded-lg border border-line bg-card cursor-pointer hover:border-gold/40">
<input
type="checkbox"
checked={scope.server_configuration}
onChange={(e) => setScope({ ...scope, server_configuration: e.target.checked })}
className="mt-0.5 h-4 w-4 rounded border-line text-gold focus:ring-gold"
/>
<div>
<p className="text-xs font-semibold text-ink">
{locale === "ru" ? "Конфигурация сервера (.conf)" : "Server Configurations (.conf)"}
</p>
<p className="text-[11px] text-muted">
{locale === "ru"
? "Пользовательские настройки модулей из configs/modules (с сохранением безопасных значений)."
: "Preserve customized configs from configs/modules/."}
</p>
</div>
</label>
</div>
{/* Conflict Policy */}
<div className="border-t border-line pt-4 space-y-2">
<h4 className="text-xs font-semibold text-ink">
{locale === "ru" ? "Политика разрешения конфликтов GUID:" : "GUID Conflict Resolution Policy:"}
</h4>
<div className="grid gap-2 sm:grid-cols-3">
<button
type="button"
onClick={() => setConflictPolicy("remap_colliding_guids")}
className={cn(
"p-3 rounded-lg border text-left text-xs transition-colors",
conflictPolicy === "remap_colliding_guids"
? "border-gold bg-gold/10 text-gold"
: "border-line bg-card text-muted hover:text-ink"
)}
>
<p className="font-semibold text-ink">Переназначить GUID</p>
<p className="text-[11px] text-muted mt-1">
Безопасное смещение ID персонажей и предметов. Ничего не теряется.
</p>
</button>
<button
type="button"
onClick={() => setConflictPolicy("skip_colliding_guids")}
className={cn(
"p-3 rounded-lg border text-left text-xs transition-colors",
conflictPolicy === "skip_colliding_guids"
? "border-gold bg-gold/10 text-gold"
: "border-line bg-card text-muted hover:text-ink"
)}
>
<p className="font-semibold text-ink">Пропустить дубликаты</p>
<p className="text-[11px] text-muted mt-1">
Персонажи с существующими GUID не импортируются.
</p>
</button>
<button
type="button"
onClick={() => setConflictPolicy("overwrite_existing")}
className={cn(
"p-3 rounded-lg border text-left text-xs transition-colors",
conflictPolicy === "overwrite_existing"
? "border-bad bg-bad/10 text-bad"
: "border-line bg-card text-muted hover:text-ink"
)}
>
<p className="font-semibold text-ink">Перезаписать (Опасно)</p>
<p className="text-[11px] text-muted mt-1">
Заменяет существующих персонажей на целевом сервере.
</p>
</button>
</div>
</div>
<div className="flex justify-between pt-2">
<Button size="sm" variant="ghost" onClick={() => setStep("inspect")}>
{locale === "ru" ? "Назад" : "Back"}
</Button>
<Button size="sm" variant="primary" disabled={planning} onClick={handleCreatePlan}>
{planning && <Loader2 className="h-3.5 w-3.5 mr-1.5 animate-spin" />}
{locale === "ru" ? "Сформировать план" : "Generate Plan"}
<ArrowRight className="h-3.5 w-3.5 ml-1.5" />
</Button>
</div>
</Card>
)}
{/* STEP 4: PLAN & RISKS */}
{step === "plan" && plan && (
<Card className="p-6 space-y-4">
<h3 className="text-sm font-semibold text-ink flex items-center gap-2">
<FileCheck className="h-4 w-4 text-gold" />
{locale === "ru" ? "Шаг 4: План переноса и подтверждение" : "Step 4: Preflight Plan"}
</h3>
<div className="rounded-lg border border-gold/30 bg-gold/5 p-4 text-xs space-y-2">
<p className="font-semibold text-gold flex items-center gap-1.5">
<Shield className="h-4 w-4" />
{locale === "ru" ? "Автоматическое создание точки восстановления" : "Automatic Restore Point"}
</p>
<p className="text-muted">
{locale === "ru"
? "Перед началом переноса будет создана полная резервная копия целевой базы данных и файлов. В случае любой ошибки состояние будет полностью восстановлено."
: "A complete backup of the destination realm will be created before any changes. Full rollback is guaranteed on failure."}
</p>
</div>
{plan.warnings.length > 0 && (
<div className="space-y-1">
<h4 className="text-xs font-semibold text-ink flex items-center gap-1.5">
<AlertTriangle className="h-3.5 w-3.5 text-warn" />
{locale === "ru" ? "Предупреждения и риски:" : "Warnings:"}
</h4>
<ul className="list-disc list-inside text-xs text-muted space-y-1">
{plan.warnings.map((w, idx) => (
<li key={idx}>{w}</li>
))}
</ul>
</div>
)}
<div>
<h4 className="text-xs font-semibold text-ink mb-1.5">
{locale === "ru" ? "Таблицы к переносу (" + plan.tables_to_migrate.length + "):" : "Tables to Migrate:"}
</h4>
<div className="flex flex-wrap gap-1.5">
{plan.tables_to_migrate.map((t) => (
<span key={t} className="rounded bg-white/5 border border-line px-2 py-0.5 text-[11px] font-mono text-muted">
{t}
</span>
))}
</div>
</div>
<div className="flex justify-between pt-3 border-t border-line">
<Button size="sm" variant="ghost" onClick={() => setStep("scope")}>
{locale === "ru" ? "Назад" : "Back"}
</Button>
<Button size="sm" variant="primary" disabled={executing} onClick={handleExecute} className="bg-ok hover:bg-ok/90 text-white">
{executing && <Loader2 className="h-3.5 w-3.5 mr-1.5 animate-spin" />}
{locale === "ru" ? "Подтвердить и перенести" : "Start Migration"}
</Button>
</div>
</Card>
)}
{/* STEP 5: EXECUTING */}
{step === "executing" && (
<Card className="p-8 text-center space-y-4">
<Loader2 className="h-8 w-8 text-gold animate-spin mx-auto" />
<h3 className="text-base font-bold text-ink">
{locale === "ru" ? "Выполняется перенос сервера..." : "Migrating Server Data..."}
</h3>
<p className="text-xs text-muted max-w-md mx-auto">
{locale === "ru"
? "Создание резервной копии, перенос персонажей, адаптация таблиц модулей и проверка ссылочной целостности."
: "Creating backup, remapping character GUIDs, executing module adapters, and verifying integrity."}
</p>
</Card>
)}
{/* STEP 6: RESULT */}
{step === "result" && execReport && (
<Card className="p-6 space-y-5">
<div className="flex items-center gap-3">
<CheckCircle2 className="h-8 w-8 text-ok shrink-0" />
<div>
<h3 className="text-base font-bold text-ink">
{locale === "ru" ? "Перенос сервера успешно завершен!" : "Migration Completed Successfully!"}
</h3>
<p className="text-xs text-muted">
{locale === "ru"
? `Все выбранные данные перенесены за ${(execReport.duration_ms / 1000).toFixed(1)} с.`
: `All data migrated in ${(execReport.duration_ms / 1000).toFixed(1)}s.`}
<h2 className="font-semibold">
{info.classic ? t("migrate.classic.title") : info.modular ? t("migrate.modular.title") : t("migrate.none.title")}
</h2>
<p className="text-sm text-muted">
{info.classic ? t("migrate.classic.text") : info.modular ? t("migrate.modular.text") : t("migrate.none.text")}
</p>
<p className="selectable mt-1 break-all text-xs text-muted">{info.path}</p>
</div>
</div>
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
<div className="rounded-lg border border-line bg-card p-3">
<span className="text-[11px] text-muted">Аккаунтов</span>
<p className="font-mono text-sm font-bold text-ink">{execReport.accounts_transferred}</p>
</div>
<div className="rounded-lg border border-line bg-card p-3">
<span className="text-[11px] text-muted">Персонажей</span>
<p className="font-mono text-sm font-bold text-ink">{execReport.characters_transferred}</p>
</div>
<div className="rounded-lg border border-line bg-card p-3">
<span className="text-[11px] text-muted">Модулей адаптировано</span>
<p className="font-mono text-sm font-bold text-ok">{execReport.modules_migrated.length}</p>
</div>
<div className="rounded-lg border border-line bg-card p-3">
<span className="text-[11px] text-muted">Таблиц перенесено</span>
<p className="font-mono text-sm font-bold text-ink">{execReport.tables_migrated.length}</p>
</div>
</div>
{execReport.backup_path && (
<div className="rounded-lg bg-white/5 border border-line p-3 text-xs text-muted">
<p className="font-semibold text-ink">{locale === "ru" ? "Точка восстановления:" : "Restore Point:"}</p>
<p className="font-mono text-[11px] break-all">{execReport.backup_path}</p>
</div>
{(info.classic || info.modular) && (
<dl className="grid grid-cols-2 gap-3 text-sm sm:grid-cols-4">
<Fact label={t("migrate.fact.version")} value={info.version ?? t("migrate.unknown")} />
<Fact label={t("migrate.fact.database")} value={t(`migrate.db.${info.database}`)} />
<Fact label={t("migrate.fact.accounts")} value={count(info.accounts)} />
<Fact label={t("migrate.fact.characters")} value={count(info.characters)} />
</dl>
)}
<div className="flex justify-end pt-2">
<Button size="sm" variant="primary" onClick={onClose}>
{locale === "ru" ? "Готово" : "Finish"}
</Button>
</div>
{info.classic && info.database === "missing" && (
<p className="flex items-start gap-2 text-sm text-bad">
<AlertTriangle className="mt-0.5 h-4 w-4 shrink-0" aria-hidden /> {t("migrate.db.missingText")}
</p>
)}
{info.classic && info.database !== "missing" && (
<>
<div>
<h3 className="flex items-center gap-2 text-sm font-semibold">
<Database className="h-4 w-4" aria-hidden /> {t("migrate.copied")}
</h3>
<ul className="mt-2 list-disc space-y-1 pl-5 text-sm text-muted">
<li>
{info.schemas.length > 0
? t("migrate.copied.schemas", { list: info.schemas.join(", ") })
: t("migrate.copied.allSchemas")}
</li>
<li>{t("migrate.copied.settings", { n: info.config_files.length })}</li>
<li>{t("migrate.copied.world")}</li>
<li>{t("migrate.copied.ports")}</li>
<li>{t("migrate.copied.modules")}</li>
{info.extra_worlds.length > 0 && (
<li>{t("migrate.copied.worlds", { list: info.extra_worlds.join(", ") })}</li>
)}
</ul>
</div>
<div>
<h3 className="text-sm font-semibold">{t("migrate.notCopied")}</h3>
<ul className="mt-2 list-disc space-y-1 pl-5 text-sm text-muted">
<li>{t("migrate.notCopied.conf")}</li>
<li>{t("migrate.notCopied.merge", { name: props.currentName })}</li>
</ul>
</div>
<div>
<h3 className="flex items-center gap-2 text-sm font-semibold text-warn">
<AlertTriangle className="h-4 w-4" aria-hidden /> {t("migrate.risks")}
</h3>
<ul className="mt-2 list-disc space-y-1 pl-5 text-sm text-muted">
<li>{t("migrate.risk.oldKept")}</li>
<li>{t("migrate.risk.ports")}</li>
{info.database === "running" ? (
<li>{t("migrate.risk.running")}</li>
) : (
<li>{t("migrate.risk.stopped", { gb: gb(info.database_bytes) })}</li>
)}
<li>{t("migrate.risk.build")}</li>
</ul>
</div>
<div className="flex justify-end">
<Button onClick={() => props.onCopy(info.path)}>
{t("migrate.start")} <ArrowRight className="ml-2 h-4 w-4" aria-hidden />
</Button>
</div>
</>
)}
</Card>
)}
</div>
);
}
function Fact(props: { label: string; value: string }) {
return (
<div className="rounded-md border border-line p-3">
<dt className="text-xs text-muted">{props.label}</dt>
<dd className="mt-1 font-mono text-sm">{props.value}</dd>
</div>
);
}
+3 -1
View File
@@ -46,6 +46,8 @@ export function Shell(props: {
activeId: string;
onSelect: (id: string) => void;
onAddAnother: () => void;
/** Make a modular copy of a classic server (the install screen takes over). */
onCopy: (path: string) => void;
onForget: (id: string) => Promise<void>;
}) {
const t = useT();
@@ -174,7 +176,7 @@ export function Shell(props: {
) : page === "players" ? (
<PlayersPage key={server.id} serverId={server.id} />
) : page === "migration" ? (
<ServerMigrationWizard key={server.id} currentRealmId={server.id} onClose={() => setPage("overview")} />
<ServerMigrationWizard key={server.id} servers={props.servers} currentName={server.name} onCopy={props.onCopy} />
) : page === "backups" ? (
<BackupsPage key={server.id} serverId={server.id} />
) : (