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:
@@ -6,27 +6,30 @@
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { onDestroy, onMount } from "svelte";
|
||||
import { t } from "$lib/i18n";
|
||||
import { message, t } from "$lib/i18n";
|
||||
import Icon from "$lib/ui/Icon.svelte";
|
||||
import { showActionMenu } from "$lib/ui/managedActionMenu";
|
||||
import { PRIORITY_LEVELS, onProjectManagementChange, readProjectManagement, writeProjectManagement, type PriorityLevels, type ProjectManagementSettings } from "./pmSettings";
|
||||
import { readBoardCatalog, writeDefaultBoard, type BoardSummary } from "./pmBoards";
|
||||
|
||||
let { compact = false }: { compact?: boolean } = $props();
|
||||
// The errors here are catalog keys without values (pmBoards.ts) or host text. The full `errorText()` of the feature
|
||||
// (pm/ui/text.ts) is not necessary, and this component must load no feature module.
|
||||
const errorText = (reason: unknown) => $t(reason instanceof Error ? reason.message : String(reason));
|
||||
|
||||
const levelNames: Record<PriorityLevels, string> = { 2: "2 — High and Low", 3: "3 — High, Medium, and Low", 5: "5 — Highest through Lowest" };
|
||||
const levelNames: Record<PriorityLevels, string> = { 2: message("2 — High and Low"), 3: message("3 — High, Medium, and Low"), 5: message("5 — Highest through Lowest") };
|
||||
let settings = $state<ProjectManagementSettings>(readProjectManagement());
|
||||
let boards = $state<BoardSummary[]>([]);
|
||||
let defaultBoard = $state("");
|
||||
let boardsReady = $state(false);
|
||||
let boardNote = $state("");
|
||||
let saving = $state(false);
|
||||
let message = $state("");
|
||||
let notice = $state("");
|
||||
let error = $state("");
|
||||
let closeMenu = () => {};
|
||||
let disposed = false;
|
||||
const active = $derived(boards.filter(board => !board.archived));
|
||||
const boardName = $derived(defaultBoard ? active.find(board => board.id === defaultBoard)?.name ?? "Unavailable board (opens All tasks)" : "All tasks");
|
||||
const boardName = $derived(defaultBoard ? active.find(board => board.id === defaultBoard)?.name ?? $t("Unavailable board (opens All tasks)") : $t("All tasks"));
|
||||
|
||||
function picker(event: MouseEvent, label: string, choices: { label: string; checked: boolean; run: () => void }[]) {
|
||||
closeMenu();
|
||||
@@ -39,15 +42,15 @@
|
||||
function saveLevels(priorityLevels: PriorityLevels) {
|
||||
error = "";
|
||||
settings = { ...settings, priorityLevels };
|
||||
writeProjectManagement(settings).then(() => { message = $t("Changes saved."); })
|
||||
.catch(() => { error = $t("Could not save these settings. Your previous settings still apply. Try again."); message = ""; settings = readProjectManagement(); });
|
||||
writeProjectManagement(settings).then(() => { notice = $t("Changes saved."); })
|
||||
.catch(() => { error = $t("Could not save these settings. Your previous settings still apply. Try again."); notice = ""; settings = readProjectManagement(); });
|
||||
}
|
||||
|
||||
async function saveDefault(id: string) {
|
||||
const previous = defaultBoard;
|
||||
error = ""; saving = true; defaultBoard = id;
|
||||
try { await writeDefaultBoard(id || null); if (!disposed) message = $t("Changes saved."); }
|
||||
catch (reason) { if (!disposed) { defaultBoard = previous; message = ""; error = reason instanceof Error ? reason.message : String(reason); } }
|
||||
try { await writeDefaultBoard(id || null); if (!disposed) notice = $t("Changes saved."); }
|
||||
catch (reason) { if (!disposed) { defaultBoard = previous; notice = ""; error = errorText(reason); } }
|
||||
finally { saving = false; }
|
||||
}
|
||||
|
||||
@@ -60,7 +63,7 @@
|
||||
boardsReady = true;
|
||||
boardNote = "";
|
||||
} catch (reason) {
|
||||
if (!disposed) boardNote = /no workspace/i.test(String(reason)) ? "Open a workspace to choose its default board." : reason instanceof Error ? reason.message : String(reason);
|
||||
if (!disposed) boardNote = /no workspace/i.test(String(reason)) ? $t("Open a workspace to choose its default board.") : errorText(reason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,21 +77,21 @@
|
||||
<div class="pm-settings">
|
||||
{#if !compact}
|
||||
<h2>{$t("Project Management")}</h2>
|
||||
<p class="intro">The boards of each workspace stay in .runestone/pm in the workspace.</p>
|
||||
<p class="intro">{$t("The boards of each workspace stay in {folder} in the workspace.", { folder: ".runestone/pm" })}</p>
|
||||
{/if}
|
||||
<div class="card">
|
||||
<div class="setting-row">
|
||||
<div><span class="name" id="pm-priority-label">Priority levels</span><p id="pm-priority-description">Existing card priorities stay unchanged when you change this setting.</p></div>
|
||||
<button class="picker" type="button" aria-label="Priority levels" aria-describedby="pm-priority-description" aria-haspopup="menu"
|
||||
onclick={event => picker(event, "Priority levels", PRIORITY_LEVELS.map(levels => ({ label: levelNames[levels], checked: settings.priorityLevels === levels, run: () => saveLevels(levels) })))}>
|
||||
{levelNames[settings.priorityLevels]}<Icon icon="chevron-down" />
|
||||
<div><span class="name" id="pm-priority-label">{$t("Priority levels")}</span><p id="pm-priority-description">{$t("Existing card priorities stay unchanged when you change this setting.")}</p></div>
|
||||
<button class="picker" type="button" aria-label={$t("Priority levels")} aria-describedby="pm-priority-description" aria-haspopup="menu"
|
||||
onclick={event => picker(event, $t("Priority levels"), PRIORITY_LEVELS.map(levels => ({ label: $t(levelNames[levels]), checked: settings.priorityLevels === levels, run: () => saveLevels(levels) })))}>
|
||||
{$t(levelNames[settings.priorityLevels])}<Icon icon="chevron-down" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<div><span class="name" id="pm-default-label">Default board</span><p id="pm-default-description">{boardNote || "Choose the board that opens in this workspace. Restored tabs keep their board."}</p></div>
|
||||
<button class="picker" type="button" aria-label="Default board" aria-describedby="pm-default-description" aria-haspopup="menu" disabled={!boardsReady || saving}
|
||||
onclick={event => picker(event, "Default board", [
|
||||
{ label: "All tasks", checked: !defaultBoard, run: () => void saveDefault("") },
|
||||
<div><span class="name" id="pm-default-label">{$t("Default board")}</span><p id="pm-default-description">{boardNote || $t("Choose the board that opens in this workspace. Restored tabs keep their board.")}</p></div>
|
||||
<button class="picker" type="button" aria-label={$t("Default board")} aria-describedby="pm-default-description" aria-haspopup="menu" disabled={!boardsReady || saving}
|
||||
onclick={event => picker(event, $t("Default board"), [
|
||||
{ label: $t("All tasks"), checked: !defaultBoard, run: () => void saveDefault("") },
|
||||
...active.map(board => ({ label: board.name, checked: defaultBoard === board.id, run: () => void saveDefault(board.id) })),
|
||||
])}>
|
||||
{boardName}<Icon icon="chevron-down" />
|
||||
@@ -96,7 +99,7 @@
|
||||
</div>
|
||||
</div>
|
||||
{#if error}<p class="error" role="alert">{error}</p>{/if}
|
||||
<p class="saved" role="status">{message}</p>
|
||||
<p class="saved" role="status">{notice}</p>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
Reference in New Issue
Block a user