Add map import and export with durable refresh progress

This commit is contained in:
2026-10-07 19:44:49 +05:00
parent dac8650ac1
commit 1307436e65
37 changed files with 2207 additions and 85 deletions

View File

@@ -4,7 +4,7 @@ import { useI18n } from "@/components/I18nProvider";
import { useEffect, useRef, useState } from "react";
import Image from "next/image";
import { api } from "./StartGame";
import { api, StartGame } from "./StartGame";
import type { DatasetManifest } from "@/shared/protocol";
import type { ProcessingJob } from "@/shared/processing-progress";
import { ProcessingProgress } from "./ProcessingProgress";
@@ -13,7 +13,10 @@ import { OwnerContributions } from "./OwnerContributions";
import Link from "next/link";
import { MapRefresh } from "./MapRefresh";
import { MapAppeal } from "./MapAppeal";
import { ExportMap } from "./MapTransfer";
type Draft = {
imported_from_id: string | null;
imported_owner_name: string | null;
id: string;
name: string;
description: string;
@@ -147,9 +150,39 @@ export function DraftEditor({ id }: { id: string }) {
<div className="editor-navigation">
<Link href="/dashboard">{t("← Your maps")}</Link>
<a href="#locations">{t("Choose locations")}</a>
{!draft.parent_dataset_id && <a href="#map-tools">{t("Map tools")}</a>}
{!draft.imported_from_id && !draft.parent_dataset_id && (
<a href="#map-tools">{t("Map tools")}</a>
)}
</div>
<span className="badge">{t(statusMessage(draft.state))}</span>
{!draft.imported_from_id &&
!draft.parent_dataset_id &&
draft.map &&
!draft.banned_at && (
<ExportMap
id={id}
disabled={
busy ||
refreshing ||
["uploading", "processing", "failed"].includes(draft.state)
}
/>
)}
{draft.imported_from_id && (
<section className="editor-panel">
<h2>
{t("Owned by {owner}", {
owner: draft.imported_owner_name ?? "Explorer",
})}
</h2>
<p className="muted">
{t(
"This shared map is private and playable without moderator review. Only the original owner can submit it for public review.",
)}
</p>
{draft.state === "draft" && <StartGame datasetId={id} />}
</section>
)}
{!draft.parent_dataset_id &&
(draft.report_strikes > 0 || draft.banned_at) && (
<MapAppeal
@@ -333,7 +366,12 @@ export function DraftEditor({ id }: { id: string }) {
</button>
<button
className="button primary"
disabled={busy || refreshing || selected.length < minimum}
disabled={
busy ||
refreshing ||
selected.length < minimum ||
!!draft.imported_from_id
}
onClick={() => save(true)}
>
{draft.parent_dataset_id
@@ -342,21 +380,23 @@ export function DraftEditor({ id }: { id: string }) {
</button>
</div>
)}
{!draft.parent_dataset_id && (
{!draft.imported_from_id && !draft.parent_dataset_id && (
<div id="map-tools">
<MapRefresh
id={id}
refreshKey={version}
job={draft.upload_jobs}
disabled={busy || !editable || refreshing}
onQueued={() => {
setMessage(
"Map refresh queued. Keep this page open to follow progress.",
"Map refresh queued. Progress and the result are saved; you can reopen this page later.",
);
setVersion((v) => v + 1);
}}
/>
</div>
)}
{!draft.parent_dataset_id && (
{!draft.imported_from_id && !draft.parent_dataset_id && (
<OwnerContributions
id={id}
allowed={draft.allow_contributions}