feat: run Velum project jobs in the background and process DOCX locally
This commit is contained in:
45
src/project-relocation-form.tsx
Normal file
45
src/project-relocation-form.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Action, ActionPanel, confirmAlert, Form, Icon, showToast, Toast, useNavigation } from "@raycast/api";
|
||||
import { useState } from "react";
|
||||
import { relocateProject } from "./lib/project-relocation";
|
||||
|
||||
export function RelocateProjectForm(props: { projectName: string; oldPath: string; onMoved: () => Promise<void> }) {
|
||||
const { pop } = useNavigation();
|
||||
const [busy, setBusy] = useState(false);
|
||||
async function save(values: { newPath: string[] }) {
|
||||
const newPath = values.newPath?.[0];
|
||||
if (!newPath) {
|
||||
await showToast({ style: Toast.Style.Failure, title: "Bitte den neuen Projektordner wählen" });
|
||||
return;
|
||||
}
|
||||
if (!(await confirmAlert({
|
||||
title: "Projektordner aktualisieren?",
|
||||
message: `Alle gespeicherten Projektstände und Regeln werden künftig ${newPath} zugeordnet. `
|
||||
+ `Bisheriger Pfad: ${props.oldPath}. Die Dateien im gewählten Ordner werden nicht verändert.`,
|
||||
primaryAction: { title: "Projektpfad aktualisieren" },
|
||||
}))) return;
|
||||
setBusy(true);
|
||||
const toast = await showToast({ style: Toast.Style.Animated, title: "Projektpfad wird aktualisiert" });
|
||||
try {
|
||||
const result = await relocateProject(props.oldPath, newPath);
|
||||
await props.onMoved();
|
||||
toast.style = Toast.Style.Success;
|
||||
toast.title = "Projektordner aktualisiert";
|
||||
toast.message = `${result.runsMoved} Projektstände übernommen`
|
||||
+ (result.copiesRelinked ? ` · ${result.copiesRelinked} Kopienordner neu gefunden` : "")
|
||||
+ (result.copiesMissing ? ` · ${result.copiesMissing} Kopienordner nicht gefunden; gespeicherte Stände bleiben verfügbar` : "");
|
||||
pop();
|
||||
} catch (error) {
|
||||
toast.style = Toast.Style.Failure;
|
||||
toast.title = "Projektpfad nicht aktualisiert";
|
||||
toast.message = (error as Error).message;
|
||||
} finally { setBusy(false); }
|
||||
}
|
||||
return <Form isLoading={busy} navigationTitle={`${props.projectName}: Projektordner ändern`}
|
||||
actions={<ActionPanel><Action.SubmitForm title="Projektpfad aktualisieren" icon={Icon.Folder}
|
||||
onSubmit={save} /></ActionPanel>}>
|
||||
<Form.Description title="Bisheriger Projektordner" text={props.oldPath} />
|
||||
<Form.FilePicker id="newPath" title="Neuer Projektordner" allowMultipleSelection={false}
|
||||
canChooseDirectories canChooseFiles={false} />
|
||||
<Form.Description text="Gespeicherte Stände, Ausnahmen und Projektbegriffe bleiben erhalten. Dateien im neuen Ordner werden weder analysiert noch geändert." />
|
||||
</Form>;
|
||||
}
|
||||
Reference in New Issue
Block a user