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:
@@ -10,6 +10,12 @@ import {
|
||||
readOptional,
|
||||
saveDocument,
|
||||
} from "./persistence.ts";
|
||||
import { format, message } from "./message.ts";
|
||||
|
||||
/** The issue of one file: its path and its problem. */
|
||||
export function fileIssue(path: string, problem: string) {
|
||||
return format(message("In {path}: {problem}"), { path, problem });
|
||||
}
|
||||
|
||||
export function cardPath(id: string) {
|
||||
const key = Array.from(new TextEncoder().encode(id), (byte) =>
|
||||
@@ -34,9 +40,7 @@ export function cardOrigin(source: string): OriginalFile | undefined {
|
||||
.some((part: string) => !part || part === "." || part === "..") ||
|
||||
origin.backup !== `.runestone/pm/backups/${origin.path}`
|
||||
)
|
||||
throw new Error(
|
||||
"The card migration record is invalid. Keep the original note.",
|
||||
);
|
||||
throw new Error(message("The card migration record is invalid. Keep the original note."));
|
||||
return origin;
|
||||
}
|
||||
/** Read one hidden card file. It throws when the file is invalid or when its name does not match the card ID. */
|
||||
@@ -44,7 +48,7 @@ export function parseCard(path: string, source: string): Task {
|
||||
cardOrigin(source);
|
||||
const task = readTask(path, source);
|
||||
if (!task || cardPath(task.id) !== path)
|
||||
throw new Error("The hidden card ID does not match its storage path.");
|
||||
throw new Error(message("The hidden card ID does not match its storage path."));
|
||||
return task;
|
||||
}
|
||||
export async function prepareCards(workspace: Workspace) {
|
||||
@@ -75,14 +79,14 @@ export async function readCards(
|
||||
const documents = await mapConcurrent(entries, async (entry) => {
|
||||
try {
|
||||
const result = sources.get(entry.rel_path)!;
|
||||
if (result.error || result.source === undefined) throw new Error(result.error ?? "The card is unavailable.");
|
||||
if (result.error || result.source === undefined) throw new Error(result.error ?? message("The card is unavailable."));
|
||||
const source = result.source;
|
||||
const cached = previous.get(entry.rel_path);
|
||||
if (cached?.source === source) return { task: cached };
|
||||
return { task: parseCard(entry.rel_path, source) };
|
||||
} catch (error) {
|
||||
return {
|
||||
issue: `${entry.rel_path}: ${error instanceof Error ? error.message : String(error)}`,
|
||||
issue: fileIssue(entry.rel_path, error instanceof Error ? error.message : String(error)),
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -111,19 +115,19 @@ export async function migrateCards(workspace: Workspace, tasks: Task[]) {
|
||||
if (isHiddenCard(task.path)) continue;
|
||||
if ((await workspace.read(task.path)) !== task.source)
|
||||
throw new Error(
|
||||
`The card changed: ${task.path}. Refresh before migration.`,
|
||||
format(message("The card changed: {path}. Refresh before migration."), { path: task.path }),
|
||||
);
|
||||
const destination = await readOptional(workspace, cardPath(task.id));
|
||||
if (destination !== null) {
|
||||
const origin = cardOrigin(destination);
|
||||
if (origin?.path !== task.path || origin.source !== task.source)
|
||||
throw new Error(
|
||||
`A different hidden card already uses the ID from ${task.path}.`,
|
||||
format(message("A different hidden card already uses the ID from {path}."), { path: task.path }),
|
||||
);
|
||||
}
|
||||
if (split(task.source).doc.has("runestone_pm_origin"))
|
||||
throw new Error(
|
||||
`The note already contains a migration record: ${task.path}. Review it before migration.`,
|
||||
format(message("The note already contains a migration record: {path}. Review it before migration."), { path: task.path }),
|
||||
);
|
||||
}
|
||||
for (const task of tasks) {
|
||||
@@ -149,15 +153,15 @@ export async function migrateCards(workspace: Workspace, tasks: Task[]) {
|
||||
copied.body !== task.body
|
||||
)
|
||||
throw new Error(
|
||||
`The card copy differs from ${task.path}. Keep the original.`,
|
||||
format(message("The card copy differs from {path}. Keep the original."), { path: task.path }),
|
||||
);
|
||||
if ((await workspace.read(task.path)) !== task.source)
|
||||
throw new Error(`The card changed: ${task.path}. Retry migration.`);
|
||||
throw new Error(format(message("The card changed: {path}. Retry migration."), { path: task.path }));
|
||||
await prepareCards(workspace);
|
||||
await saveDocument(workspace, path, source, null);
|
||||
if ((await workspace.read(path)) !== source)
|
||||
throw new Error(
|
||||
`The saved card check failed: ${task.path}. Keep the original.`,
|
||||
format(message("The saved card check failed: {path}. Keep the original."), { path: task.path }),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user