fix: restore selected project files by default
This commit is contained in:
@@ -145,7 +145,7 @@ function FilePicker(props: { run: ProjectRun; directory: string; historical?: bo
|
|||||||
if (!active) return;
|
if (!active) return;
|
||||||
setSourceRoot(scan.root);
|
setSourceRoot(scan.root);
|
||||||
setFiles(scan.files);
|
setFiles(scan.files);
|
||||||
setSelected(new Set(scan.files.map((file) => file.relPath)));
|
setSelected(new Set(scan.files.filter((file) => file.kind === "text").map((file) => file.relPath)));
|
||||||
setSkipped(scan.skipped);
|
setSkipped(scan.skipped);
|
||||||
}
|
}
|
||||||
load().catch((error: Error) => showToast({ style: Toast.Style.Failure,
|
load().catch((error: Error) => showToast({ style: Toast.Style.Failure,
|
||||||
@@ -161,7 +161,12 @@ function FilePicker(props: { run: ProjectRun; directory: string; historical?: bo
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
async function exportFiles() {
|
async function exportFiles() {
|
||||||
if (!selected.size || !sourceRoot) return;
|
if (busy) return;
|
||||||
|
if (!selected.size) {
|
||||||
|
await showToast({ style: Toast.Style.Failure, title: "Keine Dateien ausgewählt" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!sourceRoot) return;
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
const toast = await showToast({ style: Toast.Style.Animated, title: "Klartext-Kopien werden erstellt" });
|
const toast = await showToast({ style: Toast.Style.Animated, title: "Klartext-Kopien werden erstellt" });
|
||||||
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
||||||
@@ -191,7 +196,7 @@ function FilePicker(props: { run: ProjectRun; directory: string; historical?: bo
|
|||||||
}
|
}
|
||||||
toast.style = Toast.Style.Success;
|
toast.style = Toast.Style.Success;
|
||||||
toast.title = `${selected.size} Klartext-Dateien in Downloads`;
|
toast.title = `${selected.size} Klartext-Dateien in Downloads`;
|
||||||
await showInFinder(targetRoot);
|
await showInFinder(targetRoot).catch(() => undefined);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (targetRoot) await fs.rm(targetRoot, { recursive: true, force: true });
|
if (targetRoot) await fs.rm(targetRoot, { recursive: true, force: true });
|
||||||
toast.style = Toast.Style.Failure;
|
toast.style = Toast.Style.Failure;
|
||||||
@@ -199,24 +204,34 @@ function FilePicker(props: { run: ProjectRun; directory: string; historical?: bo
|
|||||||
toast.message = (error as Error).message;
|
toast.message = (error as Error).message;
|
||||||
} finally { setBusy(false); }
|
} finally { setBusy(false); }
|
||||||
}
|
}
|
||||||
|
const textFiles = files.filter((file) => file.kind === "text");
|
||||||
|
const complexFiles = files.filter((file) => file.kind === "document");
|
||||||
|
const renderFile = (file: ProjectFile) => <List.Item key={file.relPath}
|
||||||
|
icon={selected.has(file.relPath) ? Icon.CheckCircle : Icon.Circle}
|
||||||
|
title={restorePath(file.relPath, props.run.mapping, props.run.matchModes)} subtitle={file.relPath}
|
||||||
|
accessories={file.kind === "document" ? [{ text: "Office · manuell auswählen" }] : []}
|
||||||
|
actions={<ActionPanel>
|
||||||
|
<Action title={selected.has(file.relPath) ? "Datei abwählen" : "Datei auswählen"} onAction={() => toggle(file.relPath)} />
|
||||||
|
<Action title="Auswahl nach Downloads wiederherstellen" icon={Icon.Download} onAction={exportFiles} />
|
||||||
|
<Action title="Nur Textdateien auswählen" onAction={() => setSelected(new Set(textFiles.map((item) => item.relPath)))} />
|
||||||
|
<Action title="Alle Dateien auswählen (inklusive Office)" onAction={() => setSelected(new Set(files.map((item) => item.relPath)))} />
|
||||||
|
<Action title="Keine auswählen" onAction={() => setSelected(new Set())} />
|
||||||
|
</ActionPanel>} />;
|
||||||
return <List isLoading={busy || !sourceRoot} navigationTitle={`${props.run.projectName}: Dateien für Klartext wählen`}
|
return <List isLoading={busy || !sourceRoot} navigationTitle={`${props.run.projectName}: Dateien für Klartext wählen`}
|
||||||
searchBarPlaceholder="Dateien filtern">
|
searchBarPlaceholder="Dateien filtern">
|
||||||
<List.Section title={`${selected.size} von ${files.length} Dateien ausgewählt · ${skipped} übersprungen`}>
|
<List.Section title={`${selected.size} von ${files.length} Dateien ausgewählt · ${skipped} übersprungen`}>
|
||||||
<List.Item key="export" icon={Icon.Download} title="Ausgewählte Dateien wiederherstellen"
|
<List.Item key="export" icon={Icon.Download} title="Ausgewählte Dateien wiederherstellen"
|
||||||
subtitle="Klartext-Kopien in Downloads/Velum erstellen"
|
subtitle="Klartext-Kopien in Downloads/Velum erstellen · Office-Dateien nur nach Auswahl"
|
||||||
actions={<ActionPanel><Action title="Auswahl nach Downloads wiederherstellen"
|
actions={<ActionPanel><Action title="Auswahl nach Downloads wiederherstellen"
|
||||||
icon={Icon.Download} onAction={exportFiles} /></ActionPanel>} />
|
icon={Icon.Download} onAction={exportFiles} /></ActionPanel>} />
|
||||||
<List.Item key="source" icon={Icon.Folder} title="Quelle für die Wiederherstellung" subtitle={sourceRoot}
|
<List.Item key="source" icon={Icon.Folder} title="Quelle für die Wiederherstellung" subtitle={sourceRoot}
|
||||||
actions={<ActionPanel><Action title="Quellordner im Finder anzeigen" onAction={() => showInFinder(sourceRoot)} /></ActionPanel>} />
|
actions={<ActionPanel><Action title="Quellordner im Finder anzeigen" onAction={() => showInFinder(sourceRoot)} /></ActionPanel>} />
|
||||||
{files.map((file) => <List.Item key={file.relPath}
|
</List.Section>
|
||||||
icon={selected.has(file.relPath) ? Icon.CheckCircle : Icon.Circle}
|
<List.Section title={`Textdateien · ${textFiles.length} · standardmäßig ausgewählt`}>
|
||||||
title={restorePath(file.relPath, props.run.mapping, props.run.matchModes)} subtitle={file.relPath}
|
{textFiles.map(renderFile)}
|
||||||
actions={<ActionPanel>
|
</List.Section>
|
||||||
<Action title={selected.has(file.relPath) ? "Datei abwählen" : "Datei auswählen"} onAction={() => toggle(file.relPath)} />
|
<List.Section title={`Office-Dateien · ${complexFiles.length} · bewusst auswählen`}>
|
||||||
<Action title="Auswahl nach Downloads rückübersetzen" icon={Icon.Download} onAction={exportFiles} />
|
{complexFiles.map(renderFile)}
|
||||||
<Action title="Alle auswählen" onAction={() => setSelected(new Set(files.map((item) => item.relPath)))} />
|
|
||||||
<Action title="Keine auswählen" onAction={() => setSelected(new Set())} />
|
|
||||||
</ActionPanel>} />)}
|
|
||||||
</List.Section>
|
</List.Section>
|
||||||
</List>;
|
</List>;
|
||||||
}
|
}
|
||||||
@@ -230,6 +245,8 @@ function ProjectHistory(props: { projectName: string; entries: SavedRun[] }) {
|
|||||||
title={new Date(run.createdAt).toLocaleString("de-AT")}
|
title={new Date(run.createdAt).toLocaleString("de-AT")}
|
||||||
subtitle={`${run.files.length} Dateien`}
|
subtitle={`${run.files.length} Dateien`}
|
||||||
actions={<ActionPanel>
|
actions={<ActionPanel>
|
||||||
|
<Action title="Gespeicherten Stand wiederherstellen" icon={Icon.Download}
|
||||||
|
onAction={() => push(<FilePicker run={run} directory={directory} historical />)} />
|
||||||
<Action.Push title="Übersetzungstabelle anzeigen" icon={Icon.List}
|
<Action.Push title="Übersetzungstabelle anzeigen" icon={Icon.List}
|
||||||
target={<TranslationTable title={`${props.projectName} · ${new Date(run.createdAt).toLocaleString("de-AT")}`}
|
target={<TranslationTable title={`${props.projectName} · ${new Date(run.createdAt).toLocaleString("de-AT")}`}
|
||||||
mapping={run.mapping} />} />
|
mapping={run.mapping} />} />
|
||||||
@@ -238,8 +255,6 @@ function ProjectHistory(props: { projectName: string; entries: SavedRun[] }) {
|
|||||||
<Action.CopyToClipboard title="Speicherpfad kopieren" content={runCopiesPath(run, directory)} />
|
<Action.CopyToClipboard title="Speicherpfad kopieren" content={runCopiesPath(run, directory)} />
|
||||||
{run.copyPath && <Action title="Aktuelle Dateien dieses Kopienordners wiederherstellen" icon={Icon.Download}
|
{run.copyPath && <Action title="Aktuelle Dateien dieses Kopienordners wiederherstellen" icon={Icon.Download}
|
||||||
onAction={() => push(<FilePicker run={run} directory={directory} />)} />}
|
onAction={() => push(<FilePicker run={run} directory={directory} />)} />}
|
||||||
<Action title="Gespeicherten Stand wiederherstellen" icon={Icon.Clock}
|
|
||||||
onAction={() => push(<FilePicker run={run} directory={directory} historical />)} />
|
|
||||||
</ActionPanel>} />)}
|
</ActionPanel>} />)}
|
||||||
</List.Section>
|
</List.Section>
|
||||||
</List>;
|
</List>;
|
||||||
@@ -269,10 +284,10 @@ export default function Command() {
|
|||||||
accessories={[{ text: `${run.files.length} Dateien` }, { text: new Date(run.createdAt).toLocaleString("de-AT") },
|
accessories={[{ text: `${run.files.length} Dateien` }, { text: new Date(run.createdAt).toLocaleString("de-AT") },
|
||||||
...(entries.length > 1 ? [{ text: `${entries.length} Stände` }] : [])]}
|
...(entries.length > 1 ? [{ text: `${entries.length} Stände` }] : [])]}
|
||||||
actions={<ActionPanel>
|
actions={<ActionPanel>
|
||||||
<Action.Push title="Übersetzungstabelle anzeigen" icon={Icon.List}
|
|
||||||
target={<TranslationTable title={run.projectName} mapping={run.mapping} />} />
|
|
||||||
<Action title="Projektdateien als Klartext wiederherstellen" icon={Icon.Download}
|
<Action title="Projektdateien als Klartext wiederherstellen" icon={Icon.Download}
|
||||||
onAction={() => push(<FilePicker run={run} directory={directory} />)} />
|
onAction={() => push(<FilePicker run={run} directory={directory} />)} />
|
||||||
|
<Action.Push title="Übersetzungstabelle anzeigen" icon={Icon.List}
|
||||||
|
target={<TranslationTable title={run.projectName} mapping={run.mapping} />} />
|
||||||
<Action title="Pseudonymisierte Kopien im Finder anzeigen" icon={Icon.Folder}
|
<Action title="Pseudonymisierte Kopien im Finder anzeigen" icon={Icon.Folder}
|
||||||
onAction={() => showInFinder(runCopiesPath(run, directory))} />
|
onAction={() => showInFinder(runCopiesPath(run, directory))} />
|
||||||
<Action.CopyToClipboard title="Speicherpfad kopieren" content={runCopiesPath(run, directory)} />
|
<Action.CopyToClipboard title="Speicherpfad kopieren" content={runCopiesPath(run, directory)} />
|
||||||
|
|||||||
Reference in New Issue
Block a user