Canvas: Add option to deploy latest draft
Change-Id: Ia74c64354e1f80ec794140ce406fb21c16feb0da
diff --git a/apps/canvas/front/src/components/actions.tsx b/apps/canvas/front/src/components/actions.tsx
index 3047fdf..28d43dc 100644
--- a/apps/canvas/front/src/components/actions.tsx
+++ b/apps/canvas/front/src/components/actions.tsx
@@ -1,7 +1,7 @@
-import { nodeLabelFull, useEnv, useMessages, useProjectId, useStateStore } from "@/lib/state";
+import { nodeLabelFull, useMessages, useProjectId, useStateStore } from "@/lib/state";
import { Button } from "./ui/button";
import { useCallback, useEffect, useState } from "react";
-import { generateDodoConfig, AppNode } from "config";
+import { AppNode } from "config";
import { useNodes, useReactFlow } from "@xyflow/react";
import { useToast } from "@/hooks/use-toast";
import {
@@ -31,7 +31,6 @@
const store = useStateStore();
const projectId = useProjectId();
const nodes = useNodes<AppNode>();
- const env = useEnv();
const messages = useMessages();
const instance = useReactFlow();
const [ok, setOk] = useState(false);
@@ -98,18 +97,14 @@
}
setLoading(true);
try {
- const config = generateDodoConfig(projectId, nodes, env);
- if (config == null) {
- throw new Error("MUST NOT REACH!");
- }
const resp = await fetch(`/api/project/${projectId}/deploy`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
- state: instance.toObject(),
- config,
+ type: "graph",
+ graph: instance.toObject(),
}),
});
if (resp.ok) {
@@ -125,7 +120,7 @@
} finally {
setLoading(false);
}
- }, [projectId, instance, nodes, env, setLoading, info, error, monitor, store]);
+ }, [projectId, instance, setLoading, info, error, monitor, store]);
const save = useCallback(async () => {
if (projectId == null) {
return;
@@ -179,7 +174,6 @@
headers: {
"Content-Type": "application/json",
},
- body: JSON.stringify({ state: JSON.stringify(instance.toObject()) }),
});
if (resp.ok) {
clear();
@@ -188,7 +182,7 @@
} else {
error("Failed to delete project", await resp.text());
}
- }, [store, clear, projectId, info, error, instance]);
+ }, [store, clear, projectId, info, error]);
const reload = useCallback(async () => {
if (projectId == null) {
return;