Files
AutoMetabuilder/frontend/autometabuilder/components/workflow/NodePorts.tsx
copilot-swe-agent[bot] 6e9ff896e7 Phase 9: Implement atomic hooks-based workflow canvas components
- Created custom hooks: useWorkflowGraph, useWorkflowPlugins, usePluginSearch, useTabNavigation
- Decomposed canvas logic into: useCanvasNodes, useCanvasEdges, useCanvasDragDrop
- Built atomic node components: NodeHeader, NodeBody, NodePorts
- Created canvas UI components: CanvasInfoPanel, CanvasHintPanel
- Split builder into: LoadingState, ErrorState, WorkflowBuilderHeader, WorkflowBuilderTabs, WorkflowBuilderContent
- Added React Flow for n8n-style visual canvas with drag-and-drop
- All components now under 100 LOC following PROMPT.md guidelines

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
2026-01-10 12:25:36 +00:00

33 lines
867 B
TypeScript

import { Handle, Position } from "reactflow";
import { WorkflowPluginPort } from "../../lib/types";
type NodePortsProps = {
ports: WorkflowPluginPort[];
type: "input" | "output";
};
export default function NodePorts({ ports, type }: NodePortsProps) {
const isInput = type === "input";
const position = isInput ? Position.Left : Position.Right;
const handleType = isInput ? "target" : "source";
return (
<>
{ports.map((port, index) => (
<Handle
key={`${type}-${port.key}`}
type={handleType}
position={position}
id={port.key}
style={{
top: `${((index + 1) * 100) / (ports.length + 1)}%`,
width: 10,
height: 10,
backgroundColor: port.required ? "#f44336" : isInput ? "#4caf50" : "#2196f3",
}}
/>
))}
</>
);
}