Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/IoPorts/IoPorts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ const Port = ({
nodesDispatch?.({
type: NodesActionType.ADD_CONNECTION,
input: { nodeId: connectToNodeId, portName: connectToPortName },
output: { nodeId: outputNodeId, portName: outputPortName }
output: { nodeId: outputNodeId, portName: outputPortName },
portType: type
});
}
}
Expand All @@ -397,7 +398,8 @@ const Port = ({
nodesDispatch?.({
type: NodesActionType.ADD_CONNECTION,
output: { nodeId, portName: name },
input: { nodeId: inputNodeId, portName: inputPortName }
input: { nodeId: inputNodeId, portName: inputPortName },
portType: type
});
triggerRecalculation();
}
Expand Down
20 changes: 14 additions & 6 deletions src/nodesReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
import FlumeCache from "./Cache";
import { ToastAction, ToastActionTypes } from "./toastsReducer";

const addConnection = (nodes: NodeMap, input, output, portTypes) => {
const addConnection = (nodes: NodeMap, input, output, portType: string) => {
const newNodes = {
...nodes,
[input.nodeId]: {
Expand All @@ -35,7 +35,8 @@ const addConnection = (nodes: NodeMap, input, output, portTypes) => {
...(nodes[input.nodeId].connections.inputs[input.portName] || []),
{
nodeId: output.nodeId,
portName: output.portName
portName: output.portName,
portType
}
]
}
Expand All @@ -52,7 +53,8 @@ const addConnection = (nodes: NodeMap, input, output, portTypes) => {
[]),
{
nodeId: input.nodeId,
portName: input.portName
portName: input.portName,
portType
}
]
}
Expand Down Expand Up @@ -285,10 +287,16 @@ type ProposedConnection = { nodeId: string; portName: string };

export type NodesAction =
| {
type: NodesActionType.ADD_CONNECTION | NodesActionType.REMOVE_CONNECTION;
type: NodesActionType.ADD_CONNECTION;
input: ProposedConnection;
output: ProposedConnection;
portType: string;
}
| {
type: NodesActionType.REMOVE_CONNECTION;
input: ProposedConnection;
output: ProposedConnection;
}
| {
type: NodesActionType.DESTROY_TRANSPUT;
transput: ProposedConnection;
Expand Down Expand Up @@ -340,14 +348,14 @@ const nodesReducer = (
) => {
switch (action.type) {
case NodesActionType.ADD_CONNECTION: {
const { input, output } = action;
const { input, output, portType } = action;
const inputIsNotConnected = !nodes[input.nodeId].connections.inputs[
input.portName
];
if (inputIsNotConnected) {
const allowCircular =
circularBehavior === "warn" || circularBehavior === "allow";
const newNodes = addConnection(nodes, input, output, portTypes);
const newNodes = addConnection(nodes, input, output, portType);
const isCircular = checkForCircularNodes(newNodes, output.nodeId);
if (isCircular && !allowCircular) {
dispatchToasts?.({
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export interface NodeTypeConfig
export type Connection = {
nodeId: string;
portName: string;
portType: string;
};

export type ConnectionMap = { [portName: string]: Connection[] };
Expand Down