diff --git a/package.json b/package.json index 5172669..ede837d 100644 --- a/package.json +++ b/package.json @@ -89,6 +89,12 @@ "description": "Zwischenablage übernehmen, Projekt oder Sitzung wählen und wiederherstellen.", "mode": "view" }, + { + "name": "show-translation-tables", + "title": "Übersetzungstabellen anzeigen", + "description": "Gespeicherte Zuordnungen je Projekt oder Sitzung durchsuchen.", + "mode": "view" + }, { "name": "manage-sessions", "title": "Sitzungen verwalten", diff --git a/src/manage-sessions.tsx b/src/manage-sessions.tsx index 12630b6..7f48f74 100644 --- a/src/manage-sessions.tsx +++ b/src/manage-sessions.tsx @@ -25,6 +25,7 @@ import { } from "./sessions"; import type { VelumSession } from "./types"; import { mappingSummary, sessionSubtitle } from "./ui"; +import { TranslationTable } from "./show-translation-tables"; export default function Command() { const [sessions, setSessions] = useState([]); @@ -145,6 +146,11 @@ export default function Command() { accessories={[{ text: `${countMappingEntries(session.mapping)}` }]} actions={ + } + /> + } /> showInFinder(runCopiesPath(run, directory))} /> @@ -265,6 +269,8 @@ export default function Command() { accessories={[{ text: `${run.files.length} Dateien` }, { text: new Date(run.createdAt).toLocaleString("de-AT") }, ...(entries.length > 1 ? [{ text: `${entries.length} Stände` }] : [])]} actions={ + } /> push()} /> >(); + for (const entry of Object.entries(mapping).sort(([a], [b]) => + a.localeCompare(b), + )) { + const type = entry[1].type || "Sonstige"; + const entries = groups.get(type) ?? []; + entries.push(entry); + groups.set(type, entries); + } + + return ( + + + {[...groups] + .sort(([a], [b]) => a.localeCompare(b)) + .map(([type, entries]) => ( + + {entries.map(([placeholder, entry]) => ( + + + + + + } + /> + } + /> + + + + } + /> + ))} + + ))} + + ); +} + +export default function Command() { + const [projects, setProjects] = useState([]); + const [sessions, setSessions] = useState([]); + const [busy, setBusy] = useState(true); + + useEffect(() => { + Promise.all([listAllRuns(), listSessions()]) + .then(([runs, savedSessions]) => { + const latest = new Map(); + for (const { run } of runs) { + const path = canonicalProjectPath(run.projectPath); + if (!latest.has(path)) + latest.set(path, { + id: path, + title: run.projectName, + subtitle: `${path} · ${new Date(run.createdAt).toLocaleString("de-AT")}`, + mapping: run.mapping, + }); + } + setProjects( + [...latest.values()].sort((a, b) => a.title.localeCompare(b.title)), + ); + setSessions( + savedSessions.map((session) => ({ + id: session.id, + title: session.name, + subtitle: `${Object.keys(session.mapping).length} Zuordnungen · ${new Date(session.updatedAt).toLocaleString("de-AT")}`, + mapping: session.mapping, + })), + ); + }) + .catch((error: Error) => + showToast({ + style: Toast.Style.Failure, + title: "Übersetzungstabellen nicht lesbar", + message: error.message, + }), + ) + .finally(() => setBusy(false)); + }, []); + + return ( + + + + {projects.map((source) => ( + + + } + /> + + } + /> + ))} + + + {sessions.map((source) => ( + + + } + /> + + } + /> + ))} + + + ); +}