Skip to content

Commit 989cdd8

Browse files
authored
Merge pull request #2 from Praashh/enhance/ui
feat: implement custom syntax-highlighted code block component and ad…
2 parents b3e0507 + 45dfb34 commit 989cdd8

18 files changed

Lines changed: 1203 additions & 423 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import crypto from "node:crypto";
2+
import { NextResponse } from "next/server";
3+
4+
export async function GET() {
5+
const authKey = process.env.TRANSLOADIT_KEY;
6+
const authSecret = process.env.TRANSLOADIT_SECRET;
7+
8+
if (!authKey || !authSecret) {
9+
return NextResponse.json(
10+
{ error: "Transloadit not configured" },
11+
{ status: 500 },
12+
);
13+
}
14+
15+
const rawParams = {
16+
auth: {
17+
key: authKey,
18+
expires: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
19+
},
20+
steps: {
21+
":original": {
22+
robot: "/upload/handle",
23+
result: true,
24+
},
25+
},
26+
};
27+
28+
const paramsStr = JSON.stringify(rawParams);
29+
const encoded = Buffer.from(paramsStr).toString("base64");
30+
const signature = crypto
31+
.createHmac("sha1", authSecret)
32+
.update(encoded)
33+
.digest("hex");
34+
35+
return NextResponse.json({ params: encoded, signature });
36+
}

app/app/flow/page.tsx

Lines changed: 140 additions & 123 deletions
Large diffs are not rendered by default.

app/app/workflows/[id]/canvas/page.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import {
2424
Redo2,
2525
Save,
2626
Search,
27-
Upload,
2827
Undo2,
28+
Upload,
2929
} from "lucide-react";
3030
import NodePropertiesPanel from "@/components/NodePropertiesPanel";
3131
import CropImageNode from "@/components/nodes/CropImageNode";
@@ -240,6 +240,7 @@ function CanvasEditorInner() {
240240
loadWorkflow,
241241
undo,
242242
redo,
243+
setSelectedNodes,
243244
} = useCanvasStore();
244245
const {
245246
startRun,
@@ -359,15 +360,31 @@ function CanvasEditorInner() {
359360
}
360361
}, [workflowId]);
361362

363+
// Track selection for single/multi-select runs
364+
const onSelectionChange = useCallback(
365+
({ nodes: selected }: { nodes: Node[] }) => {
366+
setSelectedNodes(selected.map((n) => n.id));
367+
},
368+
[setSelectedNodes],
369+
);
370+
362371
// Run execution
363372
const runWorkflow = useCallback(async () => {
364-
const nodeIds = useCanvasStore.getState().nodes.map((n) => n.id);
373+
const state = useCanvasStore.getState();
374+
const nodeIds =
375+
state.selectedNodeIds.length > 0
376+
? state.selectedNodeIds
377+
: state.nodes.map((n) => n.id);
365378

366379
try {
367380
const res = await fetch(`/api/workflows/${workflowId}/run`, {
368381
method: "POST",
369382
headers: { "Content-Type": "application/json" },
370-
body: JSON.stringify({}),
383+
body: JSON.stringify(
384+
nodeIds.length < useCanvasStore.getState().nodes.length
385+
? { selectedNodeIds: nodeIds }
386+
: {},
387+
),
371388
});
372389
if (!res.ok) return;
373390

@@ -616,6 +633,7 @@ function CanvasEditorInner() {
616633
isValidConnection={isValidConnection}
617634
deleteKeyCode="Delete"
618635
multiSelectionKeyCode="Shift"
636+
onSelectionChange={onSelectionChange}
619637
fitView
620638
colorMode="light"
621639
className="bg-white text-gray-900"

0 commit comments

Comments
 (0)