feat: ensure open in comfy ui will carry over the auth token

This commit is contained in:
bennykok
2024-01-27 11:38:10 +08:00
parent ac5aba2aa9
commit 8f7f06470c
3 changed files with 31 additions and 14 deletions
+16 -7
View File
@@ -40,6 +40,7 @@ import {
updateCustomMachine,
updateMachine,
} from "@/server/curdMachine";
import { editWorkflowOnMachine } from "@/server/editWorkflowOnMachine";
import type {
ColumnDef,
ColumnFiltersState,
@@ -57,6 +58,7 @@ import {
import { ArrowUpDown, MoreHorizontal } from "lucide-react";
import * as React from "react";
import { useState } from "react";
import { toast } from "sonner";
import type { z } from "zod";
export type Machine = MachineType;
@@ -218,15 +220,22 @@ export const columns: ColumnDef<Machine>[] = [
{machine.type === "comfy-deploy-serverless" && (
<>
<DropdownMenuItem asChild>
<a
target="_blank"
href={machine.endpoint.replace(
"comfyui-api",
"comfyui-app"
)} rel="noreferrer"
<button
onClick={async () => {
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)
}}
>
Open ComfyUI
</a>
</button>
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
+1 -1
View File
@@ -402,7 +402,7 @@ export function OpenEditButton({
onClick={async () => {
setIsLoading(true);
const url = await callServerPromise(
editWorkflowOnMachine(workflow_version_id, machine),
editWorkflowOnMachine(machine, workflow_version_id),
);
if (url && typeof url !== "object") {
window.open(url, "_blank");