feat: update with error machine built dialog

This commit is contained in:
bennykok 2024-01-26 20:13:44 +08:00
parent 97aa88eac8
commit 731bdf3982

View File

@ -30,6 +30,7 @@ export function MachineBuildLog({
}) { }) {
const [logs, setLogs] = useState<LogsType>([]); const [logs, setLogs] = useState<LogsType>([]);
const [finished, setFinished] = useState(false); const [finished, setFinished] = useState(false);
const [status, setStatus] = useState<"failed" | "succuss">();
const wsEndpoint = endpoint.replace(/^http/, "ws"); const wsEndpoint = endpoint.replace(/^http/, "ws");
const query = { fly_instance_id: instance_id }; const query = { fly_instance_id: instance_id };
@ -56,6 +57,7 @@ export function MachineBuildLog({
setLogs((logs) => [...(logs ?? []), message.data]); setLogs((logs) => [...(logs ?? []), message.data]);
} else if (message?.event === "FINISHED") { } else if (message?.event === "FINISHED") {
setFinished(true); setFinished(true);
setStatus(message.status)
} }
}, [lastMessage]); }, [lastMessage]);
@ -68,20 +70,42 @@ export function MachineBuildLog({
<AlertDialog open={finished}> <AlertDialog open={finished}>
<AlertDialogContent> <AlertDialogContent>
<AlertDialogHeader> {
<AlertDialogTitle>Machine Built</AlertDialogTitle> status == "succuss" ? (
<AlertDialogDescription> <>
Your machine is built, you can now integrate your API, or directly run to check this machines. <AlertDialogHeader>
</AlertDialogDescription> <AlertDialogTitle>Machine Built</AlertDialogTitle>
</AlertDialogHeader> <AlertDialogDescription>
<AlertDialogFooter> Your machine is built, you can now integrate your API, or directly run to check this machines.
<AlertDialogAction onClick={() => { </AlertDialogDescription>
router.push("/workflows") </AlertDialogHeader>
}}>See Workflows</AlertDialogAction> <AlertDialogFooter>
<AlertDialogAction onClick={() => { <AlertDialogAction onClick={() => {
router.push("/machines") router.push("/workflows")
}}>See All Machines</AlertDialogAction> }}>See Workflows</AlertDialogAction>
</AlertDialogFooter> <AlertDialogAction onClick={() => {
router.push("/machines")
}}>See All Machines</AlertDialogAction>
</AlertDialogFooter></>
) : (
<>
<AlertDialogHeader>
<AlertDialogTitle>Machine Failed</AlertDialogTitle>
<AlertDialogDescription>
Something went wrong with the machine build, please check the log.
Possible cause could be conflits with custom nodes, build got stuck, timeout, or too many custom nodes installed.
Please attempt a rebuild or remove some of the custom nodes.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogAction onClick={() => {
router.push("/machines")
}}>Back to machines</AlertDialogAction>
</AlertDialogFooter></>
)
}
</AlertDialogContent> </AlertDialogContent>
</AlertDialog> </AlertDialog>