Translate Project Management and add its tests and guide
- Every interface string of Project Management goes through the catalog: 539 new rows with fr, ja, and zh-CN. - Storage and model messages use a local message() marker and stay free of host imports. The interface translates them. - A board renders again when the language changes. Dates use the interface language. - Fix: the ribbon button waits for the feature switches at startup, and the settings code loads no feature module. - Add six smoke tests: board state, cards, menus, drag and drop, views, and language. - Add docs/guides/project-management.md and UI-060. Update the user, plugin, SDK, host, development, and interface docs and CLAUDE.md. - Name the fake board view of tree/renameUndo "Board fixture", because the native Project Management button is now in the ribbon.
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
saveDocument,
|
||||
ensurePrivateStorage,
|
||||
} from "./persistence.ts";
|
||||
import { format, message } from "./message.ts";
|
||||
|
||||
/** Retain originals until the user checks the boards and removes the listed files. */
|
||||
export async function migrateStorage(
|
||||
@@ -22,7 +23,7 @@ export async function migrateStorage(
|
||||
cards: Task[] = [],
|
||||
) {
|
||||
if (!workspace.readOptional || !workspace.create)
|
||||
throw new Error("Update RuneStone before migrating Project Management storage.");
|
||||
throw new Error(message("Update RuneStone before migrating Project Management storage."));
|
||||
const snapshot = await readCatalog(workspace);
|
||||
const legacy = boards.filter((board) => !isManagedBoard(board.path));
|
||||
const legacyLabels = await readOptional(workspace, legacyLabelsPath);
|
||||
@@ -32,10 +33,10 @@ export async function migrateStorage(
|
||||
// Validate every source before creating backups or publishing any changes.
|
||||
for (const board of legacy) {
|
||||
if (snapshot.value.deletedBoardIds?.includes(board.id))
|
||||
throw new Error("This board was deleted. Refresh Project Management before migration.");
|
||||
throw new Error(message("This board was deleted. Refresh Project Management before migration."));
|
||||
if ((await workspace.read(board.path)) !== board.source)
|
||||
throw new Error(
|
||||
`The board changed: ${board.path}. Refresh before migration.`,
|
||||
format(message("The board changed: {path}. Refresh before migration."), { path: board.path }),
|
||||
);
|
||||
const existing = snapshot.value.boards.find(
|
||||
(item) => item.value.id === board.id,
|
||||
@@ -46,7 +47,7 @@ export async function migrateStorage(
|
||||
existing.original.source !== board.source)
|
||||
)
|
||||
throw new Error(
|
||||
`A different board already uses the ID from ${board.path}.`,
|
||||
format(message("A different board already uses the ID from {path}."), { path: board.path }),
|
||||
);
|
||||
}
|
||||
if (legacyLabels !== null && savedLabels !== null) {
|
||||
@@ -55,9 +56,7 @@ export async function migrateStorage(
|
||||
original?.path !== legacyLabelsPath ||
|
||||
original?.source !== legacyLabels
|
||||
)
|
||||
throw new Error(
|
||||
"Hidden labels and legacy labels both exist. Resolve their differences before migration.",
|
||||
);
|
||||
throw new Error(message("Hidden labels and legacy labels both exist. Resolve their differences before migration."));
|
||||
}
|
||||
await ensurePrivateStorage(workspace);
|
||||
let changed = false;
|
||||
@@ -79,10 +78,10 @@ export async function migrateStorage(
|
||||
for (const board of legacy)
|
||||
if ((await workspace.read(board.path)) !== board.source)
|
||||
throw new Error(
|
||||
`The board changed: ${board.path}. Refresh before migration.`,
|
||||
format(message("The board changed: {path}. Refresh before migration."), { path: board.path }),
|
||||
);
|
||||
if (legacyLabels !== (await readOptional(workspace, legacyLabelsPath)))
|
||||
throw new Error("Legacy labels changed. Refresh before migration.");
|
||||
throw new Error(message("Legacy labels changed. Refresh before migration."));
|
||||
if (changed) await writeCatalog(workspace, snapshot.value, snapshot.source);
|
||||
if (labelBackup) {
|
||||
const source =
|
||||
@@ -93,7 +92,7 @@ export async function migrateStorage(
|
||||
) + "\n";
|
||||
await saveDocument(workspace, labelsPath, source, null);
|
||||
if ((await workspace.read(labelsPath)) !== source)
|
||||
throw new Error("The saved label check failed. Retry migration.");
|
||||
throw new Error(message("The saved label check failed. Retry migration."));
|
||||
}
|
||||
const saved = await readCatalog(workspace);
|
||||
for (const board of legacy) {
|
||||
@@ -105,19 +104,19 @@ export async function migrateStorage(
|
||||
entry?.original?.source !== board.source ||
|
||||
JSON.stringify(entry) !== JSON.stringify(expected)
|
||||
)
|
||||
throw new Error("The saved board check failed. Retry migration.");
|
||||
throw new Error(message("The saved board check failed. Retry migration."));
|
||||
}
|
||||
await migrateCards(workspace, cards);
|
||||
const files = await migrationFiles(workspace);
|
||||
for (const file of files) {
|
||||
if ((await workspace.read(file.backup)) !== file.source)
|
||||
throw new Error(
|
||||
`Backup check failed for ${file.path}. Keep the original.`,
|
||||
format(message("The backup check failed for {path}. Keep the original."), { path: file.path }),
|
||||
);
|
||||
const current = await readOptional(workspace, file.path);
|
||||
if (current !== null && current !== file.source)
|
||||
throw new Error(
|
||||
`The original changed: ${file.path}. Keep both versions.`,
|
||||
format(message("The original changed: {path}. Keep both versions."), { path: file.path }),
|
||||
);
|
||||
}
|
||||
return files;
|
||||
|
||||
Reference in New Issue
Block a user