fix(builder): Correctly display static links on new edges (#7851)

Fix static links on edge creation
pull/7836/head^2
Krzysztof Czerwinski 2024-08-21 10:24:01 +01:00 committed by GitHub
parent afc8338145
commit a1cbc101a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 3 deletions

View File

@ -52,6 +52,7 @@ export type CustomNodeData = {
errors?: { [key: string]: string | null }; errors?: { [key: string]: string | null };
setErrors: (errors: { [key: string]: string | null }) => void; setErrors: (errors: { [key: string]: string | null }) => void;
setIsAnyModalOpen?: (isOpen: boolean) => void; setIsAnyModalOpen?: (isOpen: boolean) => void;
isOutputStatic?: boolean;
}; };
const CustomNode: FC<NodeProps<CustomNodeData>> = ({ data, id }) => { const CustomNode: FC<NodeProps<CustomNodeData>> = ({ data, id }) => {

View File

@ -274,8 +274,7 @@ const FlowEditor: React.FC<{
const edgeColor = getTypeColor( const edgeColor = getTypeColor(
getOutputType(connection.source!, connection.sourceHandle!), getOutputType(connection.source!, connection.sourceHandle!),
); );
const sourcePos = getNode(connection.source!)?.position; const sourceNode = getNode(connection.source!);
console.log("sourcePos", sourcePos);
const newEdge: Edge<CustomEdgeData> = { const newEdge: Edge<CustomEdgeData> = {
id: formatEdgeID(connection), id: formatEdgeID(connection),
type: "custom", type: "custom",
@ -284,7 +283,11 @@ const FlowEditor: React.FC<{
strokeWidth: 2, strokeWidth: 2,
color: edgeColor, color: edgeColor,
}, },
data: { edgeColor, sourcePos }, data: {
edgeColor,
sourcePos: sourceNode!.position,
isStatic: sourceNode!.data.isOutputStatic,
},
...connection, ...connection,
source: connection.source!, source: connection.source!,
target: connection.target!, target: connection.target!,
@ -431,6 +434,7 @@ const FlowEditor: React.FC<{
), ),
); );
}, },
isOutputStatic: nodeSchema.staticOutput,
}, },
}; };

View File

@ -12,6 +12,7 @@ export type Block = {
categories: Category[]; categories: Category[];
inputSchema: BlockIORootSchema; inputSchema: BlockIORootSchema;
outputSchema: BlockIORootSchema; outputSchema: BlockIORootSchema;
staticOutput: boolean;
}; };
export type BlockIORootSchema = { export type BlockIORootSchema = {