fix(PageComponent/index.tsx): fix typo in import statement for scapeJSONParse function
feat(PageComponent/index.tsx): add functionality to generate a new flow and node from a selection and update the nodes and edges accordingly feat(PageComponent/index.tsx): add validation for selection and display error message if selection is invalid
This commit is contained in:
parent
7bdaa1bca6
commit
5933c2cefc
1 changed files with 26 additions and 1 deletions
|
|
@ -36,8 +36,11 @@ import { APIClassType } from "../../../../types/api";
|
||||||
import { FlowType, NodeType, targetHandleType } from "../../../../types/flow";
|
import { FlowType, NodeType, targetHandleType } from "../../../../types/flow";
|
||||||
import { TabsState } from "../../../../types/tabs";
|
import { TabsState } from "../../../../types/tabs";
|
||||||
import {
|
import {
|
||||||
|
generateFlow,
|
||||||
|
generateNodeFromFlow,
|
||||||
isValidConnection,
|
isValidConnection,
|
||||||
scapeJSONParse,
|
scapeJSONParse,
|
||||||
|
validateSelection,
|
||||||
} from "../../../../utils/reactflowUtils";
|
} from "../../../../utils/reactflowUtils";
|
||||||
import { isWrappedWithClass } from "../../../../utils/utils";
|
import { isWrappedWithClass } from "../../../../utils/utils";
|
||||||
import ConnectionLineComponent from "../ConnectionLineComponent";
|
import ConnectionLineComponent from "../ConnectionLineComponent";
|
||||||
|
|
@ -442,7 +445,29 @@ export default function Page({
|
||||||
></Controls>
|
></Controls>
|
||||||
)}
|
)}
|
||||||
<SelectionMenu isVisible={selectionMenuVisible} nodes={lastSelection?.nodes}
|
<SelectionMenu isVisible={selectionMenuVisible} nodes={lastSelection?.nodes}
|
||||||
onClick={()=>{console.log('click')}}/>
|
onClick={()=>{
|
||||||
|
if(validateSelection(lastSelection!).length===0){
|
||||||
|
const {newFlow} = generateFlow(lastSelection!,reactFlowInstance!,"new Component");
|
||||||
|
const newGroupNode = generateNodeFromFlow(newFlow)
|
||||||
|
setNodes((oldNodes)=>[...oldNodes.filter((oldNodes)=>!lastSelection?.nodes.some((selectionNode)=>selectionNode.id===oldNodes.id)),newGroupNode])
|
||||||
|
setEdges((oldEdges) =>
|
||||||
|
oldEdges.filter(
|
||||||
|
(oldEdge) =>
|
||||||
|
!lastSelection!.nodes.some(
|
||||||
|
(selectionNode) =>
|
||||||
|
selectionNode.id === oldEdge.target ||
|
||||||
|
selectionNode.id === oldEdge.source
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
setErrorData({
|
||||||
|
title: "Invalid selection",
|
||||||
|
list: validateSelection(lastSelection!),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}/>
|
||||||
</ReactFlow>
|
</ReactFlow>
|
||||||
{!view && (
|
{!view && (
|
||||||
<Chat flow={flow} reactFlowInstance={reactFlowInstance!} />
|
<Chat flow={flow} reactFlowInstance={reactFlowInstance!} />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue