diff --git a/web/src/components/MachineList.tsx b/web/src/components/MachineList.tsx index 0d52026..996f00e 100644 --- a/web/src/components/MachineList.tsx +++ b/web/src/components/MachineList.tsx @@ -235,9 +235,11 @@ export const columns: ColumnDef[] = [ { - buildMachine({ + callServerPromise(buildMachine({ id: machine.id, - }); + }), { + loadingText: "Starting machine build process" + }) }} > Rebuild diff --git a/web/src/components/callServerPromise.tsx b/web/src/components/callServerPromise.tsx index 17c0117..d1f83ab 100644 --- a/web/src/components/callServerPromise.tsx +++ b/web/src/components/callServerPromise.tsx @@ -2,7 +2,13 @@ import { toast } from "sonner"; -export async function callServerPromise(result: Promise) { +export async function callServerPromise(result: Promise, props?: { + loadingText: string +}) { + let id: string | number + if (props?.loadingText) { + id = toast.loading(props.loadingText) + } return result .then((x) => { if ((x as { message: string })?.message !== undefined) { @@ -15,5 +21,8 @@ export async function callServerPromise(result: Promise) { .catch((error) => { toast.error(error.message); return null; + }).finally(() => { + if (id != undefined) + toast.dismiss(id) }); }