fix: clearer listing states, joining options chosen before publishing

Portable characters are on by default in a new listing; account creation and
portable characters are shown in the publish form (and in publish all) and
saved right after the realm is published.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ДмитрийandClaude Sonnet 5.5 committed 2026-10-27 18:22:51 +05:00
1 parent 4fcf0dde3f
commit 8e1eb825df
4 files changed
+59 -21

No files matched your search

+9 -8
View File
@@ -1113,17 +1113,18 @@ const en = {
"registry.publishAll": "Publish all realms",
"registry.publishAllText": "One description, language and region for every realm that is not listed yet. Each realm is listed under the server name; the realms that start next to the main one get their realm name added.",
"registry.publishAllButton": "Publish {n} realms",
"registry.alreadyListed": "Already listed",
"registry.alreadyListed": "Already published",
"registry.configure": "Configure",
"registry.publishShort": "Publish",
"registry.short.starting": "Starting",
"registry.short.waiting_for_realm": "Waiting for the realm",
"registry.short.realm_stopped": "Listed as offline",
"registry.short.online": "Listed and online",
"registry.short.starting": "Publishing…",
"registry.accessFailed": "The realm is published, but its joining options were not saved: {reason}",
"registry.short.waiting_for_realm": "Not published",
"registry.short.realm_stopped": "Published, realm is off",
"registry.short.online": "Published",
"registry.short.retrying": "Registry unreachable",
"registry.short.rejected": "Refused",
"registry.short.unpublishing": "Removing",
"registry.short.disabled": "Not listed",
"registry.short.rejected": "Refused by the registry",
"registry.short.unpublishing": "Removing from the list",
"registry.short.disabled": "Not published",
"registry.text": "Publish this realm in the central list so that players can find it. Only its name, description, language, region, rates, modules, player counts, version and capabilities are shared: no passwords, no characters, no accounts. The realm keeps running if the list is unreachable.",
"registry.url": "Registry address",
"registry.urlSave": "Save address",
+10 -9
View File
@@ -1095,17 +1095,18 @@ const ru: Partial<Record<keyof typeof en, string>> = {
"registry.publishAll": "Опубликовать все реалмы",
"registry.publishAllText": "Одно описание, язык и регион для каждого реалма, которого ещё нет в списке. Реалмы публикуются под названием сервера; к реалмам, которые запускаются рядом с основным, добавляется название реалма.",
"registry.publishAllButton": "Опубликовать реалмов: {n}",
"registry.alreadyListed": "Уже в списке",
"registry.alreadyListed": "Уже опубликован",
"registry.configure": "Настроить",
"registry.publishShort": "Опубликовать",
"registry.short.starting": "Запускается",
"registry.short.waiting_for_realm": "Ждёт реалм",
"registry.short.realm_stopped": "В списке как офлайн",
"registry.short.online": "В списке, онлайн",
"registry.short.retrying": "Реестр недоступен",
"registry.short.rejected": "Отклонён",
"registry.short.unpublishing": "Удаляется",
"registry.short.disabled": "Не в списке",
"registry.short.starting": "Публикуется…",
"registry.accessFailed": "Реалм опубликован, но настройки входа игроков не сохранены: {reason}",
"registry.short.waiting_for_realm": "Не опубликован",
"registry.short.realm_stopped": "Опубликован, реалм выключен",
"registry.short.online": "Опубликован",
"registry.short.retrying": "Нет связи с реестром",
"registry.short.rejected": "Реестр отклонил",
"registry.short.unpublishing": "Снимается с публикации",
"registry.short.disabled": "Не опубликован",
"registry.text": "Опубликуйте этот реалм в общем списке, чтобы игроки могли его найти. Передаются только название, описание, язык, регион, рейты, модули, число игроков и ботов, версия и возможности реалма: никаких паролей, персонажей и аккаунтов. Если список недоступен, реалм продолжает работать.",
"registry.url": "Адрес реестра",
"registry.urlSave": "Сохранить адрес",
+39 -3
View File
@@ -62,6 +62,19 @@ function ListingFields({ idPrefix, name, setName, description, setDescription, l
</>;
}
/** Who may join and how: shown before publishing, so the choice is made once, not found later. */
function JoinChoices({ existingOnly, setExistingOnly, allowPortable, setAllowPortable }: { existingOnly: boolean; setExistingOnly: (v: boolean) => void; allowPortable: boolean; setAllowPortable: (v: boolean) => void }) {
const t = useT();
return (
<div className="mt-4 rounded-md border border-line p-3 text-sm">
<p className="font-medium">{t("access.title")}</p>
<p className="mt-1 text-xs text-muted">{t("access.text")}</p>
<label className="mt-3 flex items-start gap-2"><input type="checkbox" checked={existingOnly} onChange={(e) => setExistingOnly(e.target.checked)} className="mt-1" /><span>{t("access.existingOnly")}<span className="block text-xs text-muted">{t("access.existingOnlyHint")}</span></span></label>
<label className="mt-3 flex items-start gap-2"><input type="checkbox" checked={allowPortable} onChange={(e) => setAllowPortable(e.target.checked)} className="mt-1" /><span>{t("access.allowPortable")}<span className="block text-xs text-muted">{t("access.allowPortableHint")}</span></span></label>
</div>
);
}
/** Publishing, stopping and the access options of one realm. */
export function PublishRealmDialog({ realm, onClose }: { realm: PublishRealm; onClose: () => void }) {
const t = useT();
@@ -75,7 +88,8 @@ export function PublishRealmDialog({ realm, onClose }: { realm: PublishRealm; on
const [region, setRegion] = useState("");
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const [allowPortable, setAllowPortable] = useState(false);
// New listings start with portable characters allowed and accounts created for new players; the choice is shown before publishing.
const [allowPortable, setAllowPortable] = useState(true);
const [existingOnly, setExistingOnly] = useState(false);
const [route, setRoute] = useState("");
const [accessSaved, setAccessSaved] = useState(false);
@@ -103,6 +117,17 @@ export function PublishRealmDialog({ realm, onClose }: { realm: PublishRealm; on
setError(null);
try { await action(); await refresh(); } catch (e) { setError(asUiError(e).technical); } finally { setBusy(false); }
}
async function publish() {
setBusy(true);
setError(null);
try {
await realmRegistry.publish(localId, name, description, language, region.trim() === "" ? null : region.trim());
// Saving the joining options needs the listing to exist; if it cannot be saved now (for example the server is running), the options stay available below.
try { await control.setAccess(localId, existingOnly, allowPortable, route.trim() === "" ? null : route.trim()); }
catch (e) { setError(t("registry.accessFailed", { reason: asControlError(e).message })); }
await refresh();
} catch (e) { setError(asUiError(e).technical); } finally { setBusy(false); }
}
return (
<Modal title={t("registry.dialogTitle", { realm: realm.label })} onClose={onClose}>
@@ -110,8 +135,9 @@ export function PublishRealmDialog({ realm, onClose }: { realm: PublishRealm; on
{!published && <div className="mt-4">
<ListingFields idPrefix={`pub-${localId}`} name={name} setName={setName} description={description} setDescription={setDescription} language={language} setLanguage={setLanguage} region={region} setRegion={setRegion} />
<JoinChoices existingOnly={existingOnly} setExistingOnly={setExistingOnly} allowPortable={allowPortable} setAllowPortable={setAllowPortable} />
<div className="mt-4">
<Button variant="primary" disabled={busy || !status?.url || name.trim() === ""} onClick={() => void run(() => realmRegistry.publish(localId, name, description, language, region.trim() === "" ? null : region.trim()))}>
<Button variant="primary" disabled={busy || !status?.url || name.trim() === ""} onClick={() => void publish()}>
{busy && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}{t("registry.publish")}
</Button>
{!status?.url && <p className="mt-2 text-xs text-muted">{t("registry.noUrl")}</p>}
@@ -159,6 +185,8 @@ export function PublishAllDialog({ realms, onClose }: { realms: PublishRealm[];
const [description, setDescription] = useState("");
const [language, setLanguage] = useState("en");
const [region, setRegion] = useState("");
const [allowPortable, setAllowPortable] = useState(true);
const [existingOnly, setExistingOnly] = useState(false);
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const todo = realms.filter((r) => !isListed(status?.realms.find((s) => s.local_id === r.localId)));
@@ -167,8 +195,15 @@ export function PublishAllDialog({ realms, onClose }: { realms: PublishRealm[];
setBusy(true); setError(null);
try {
for (const r of todo) await realmRegistry.publish(r.localId, r.defaultName, description, language, region.trim() === "" ? null : region.trim());
// The joining options are saved realm by realm; one that cannot be saved now (for example the server is running) does not stop the others.
const failed: string[] = [];
for (const r of todo) {
try { await control.setAccess(r.localId, existingOnly, allowPortable, null); }
catch (e) { failed.push(`${r.label}: ${asControlError(e).message}`); }
}
await refresh();
onClose();
if (failed.length === 0) onClose();
else setError(t("registry.accessFailed", { reason: failed.join(" · ") }));
} catch (e) { setError(asUiError(e).technical); await refresh(); } finally { setBusy(false); }
}
@@ -180,6 +215,7 @@ export function PublishAllDialog({ realms, onClose }: { realms: PublishRealm[];
</ul>
{todo.length > 0 && <div className="mt-4">
<ListingFields idPrefix="pub-all" name="" setName={() => undefined} description={description} setDescription={setDescription} language={language} setLanguage={setLanguage} region={region} setRegion={setRegion} hideName />
<JoinChoices existingOnly={existingOnly} setExistingOnly={setExistingOnly} allowPortable={allowPortable} setAllowPortable={setAllowPortable} />
<div className="mt-4">
<Button variant="primary" disabled={busy || !status?.url} onClick={() => void publishAll()}>
{busy && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}{t("registry.publishAllButton", { n: todo.length })}