From 5443dcd20bd1df8de41123dd65c416142baea0b8 Mon Sep 17 00:00:00 2001 From: bennykok Date: Sat, 27 Jan 2024 22:33:42 +0800 Subject: [PATCH] feat: add loading text for machine operation --- web/src/components/MachineList.tsx | 182 +++++++++++++++-------------- 1 file changed, 97 insertions(+), 85 deletions(-) diff --git a/web/src/components/MachineList.tsx b/web/src/components/MachineList.tsx index 996f00e..81db3f4 100644 --- a/web/src/components/MachineList.tsx +++ b/web/src/components/MachineList.tsx @@ -115,16 +115,18 @@ export const columns: ColumnDef[] = [ {row.original.status} )} - {!row.original.disabled && row.original.status && row.original.status != "building" && ( - - {row.original.status} - - )} + {!row.original.disabled && + row.original.status && + row.original.status != "building" && ( + + {row.original.status} + + )} // ); @@ -194,7 +196,9 @@ export const columns: ColumnDef[] = [ { - callServerPromise(deleteMachine(machine.id)); + callServerPromise(deleteMachine(machine.id), { + loadingText: "Deleting machine", + }); }} > Delete Machine @@ -202,7 +206,9 @@ export const columns: ColumnDef[] = [ {machine.disabled ? ( { - callServerPromise(enableMachine(machine.id)); + callServerPromise(enableMachine(machine.id), { + loadingText: "Enabling machine", + }); }} > Enable Machine @@ -211,7 +217,9 @@ export const columns: ColumnDef[] = [ { - callServerPromise(disableMachine(machine.id)); + callServerPromise(disableMachine(machine.id), { + loadingText: "Disabling machine", + }); }} > Disable Machine @@ -219,27 +227,33 @@ export const columns: ColumnDef[] = [ )} {machine.type === "comfy-deploy-serverless" && ( <> - { - const id = toast.loading("Getting machine url...") - const url = await callServerPromise( - editWorkflowOnMachine(machine.id), - ); - if (url && typeof url !== "object") { - window.open(url, "_blank"); - } else if (url && typeof url === "object" && url.error) { - console.error(url.error); - } - toast.dismiss(id) - }}> + { + const url = await callServerPromise( + editWorkflowOnMachine(machine.id), + { + loadingText: "Getting machine url...", + }, + ); + if (url && typeof url !== "object") { + window.open(url, "_blank"); + } else if (url && typeof url === "object" && url.error) { + console.error(url.error); + } + }} + > Open ComfyUI { - callServerPromise(buildMachine({ - id: machine.id, - }), { - loadingText: "Starting machine build process" - }) + callServerPromise( + buildMachine({ + id: machine.id, + }), + { + loadingText: "Starting machine build process", + }, + ); }} > Rebuild @@ -250,57 +264,55 @@ export const columns: ColumnDef[] = [ Edit - { - machine.type === "comfy-deploy-serverless" ? ( - + ) : ( + - ) : ( - - ) - } - + }, + }} + /> + )} + ); }, }, @@ -315,7 +327,7 @@ export function MachineList({ }) { const [sorting, setSorting] = React.useState([]); const [columnFilters, setColumnFilters] = React.useState( - [] + [], ); const [columnVisibility, setColumnVisibility] = React.useState({}); @@ -356,7 +368,7 @@ export function MachineList({ dialogClassName="sm:max-w-[600px]" disabled={ data.some( - (machine) => machine.type === "comfy-deploy-serverless" + (machine) => machine.type === "comfy-deploy-serverless", ) && !userMetadata.betaFeaturesAccess } tooltip={ @@ -418,9 +430,9 @@ export function MachineList({ {header.isPlaceholder ? null : flexRender( - header.column.columnDef.header, - header.getContext() - )} + header.column.columnDef.header, + header.getContext(), + )} ); })} @@ -438,7 +450,7 @@ export function MachineList({ {flexRender( cell.column.columnDef.cell, - cell.getContext() + cell.getContext(), )} ))}