Spaces:
Configuration error
Configuration error
Commit
Β·
7d7e6b7
1
Parent(s):
7496675
π On Node Delete bug fixes
Browse files
frontend/src/components/Nodes/Custom.js
CHANGED
@@ -67,7 +67,7 @@ export default function CustomNodeIframe({id, data}){
|
|
67 |
<div className={` flex ${!collapsed ? '' : 'w-0 hidden'}`}>
|
68 |
<div title="Adjust Node Size" className="duration-300 cursor-pointer shadow-xl border-2 dark:border-white border-white h-10 w-10 mr-2 -mt-3 bg-Warm-Violet rounded-xl" onClick={() => {setSizeAdjuster((size) => !size)}}><TbResize className="h-full w-full text-white p-1"/></div>
|
69 |
<a href={data.host} target="_blank" rel="noopener noreferrer"><div title="Gradio Host Site" className="duration-300 cursor-pointer shadow-xl border-2 dark:border-white border-white h-10 w-10 mr-2 -mt-3 bg-Warm-Pink rounded-xl"><BiCube className="h-full w-full text-white p-1"/></div></a>
|
70 |
-
<div title="Delete Node" className="duration-300 cursor-pointer shadow-xl border-2 dark:border-white border-white h-10 w-10 mr-2 -mt-3 bg-Warm-Red rounded-xl" onClick={() => data.delete([{id
|
71 |
<div title="Refresh Node" className="duration-300 cursor-pointer shadow-xl border-2 dark:border-white border-white h-10 w-10 mr-2 -mt-3 bg-Warm-Orange rounded-xl" onClick={() => {setRefresh((old) => old++)}}><BiRefresh className="h-full w-full text-white p-1"/></div>
|
72 |
</div>
|
73 |
</div>
|
|
|
67 |
<div className={` flex ${!collapsed ? '' : 'w-0 hidden'}`}>
|
68 |
<div title="Adjust Node Size" className="duration-300 cursor-pointer shadow-xl border-2 dark:border-white border-white h-10 w-10 mr-2 -mt-3 bg-Warm-Violet rounded-xl" onClick={() => {setSizeAdjuster((size) => !size)}}><TbResize className="h-full w-full text-white p-1"/></div>
|
69 |
<a href={data.host} target="_blank" rel="noopener noreferrer"><div title="Gradio Host Site" className="duration-300 cursor-pointer shadow-xl border-2 dark:border-white border-white h-10 w-10 mr-2 -mt-3 bg-Warm-Pink rounded-xl"><BiCube className="h-full w-full text-white p-1"/></div></a>
|
70 |
+
<div title="Delete Node" className="duration-300 cursor-pointer shadow-xl border-2 dark:border-white border-white h-10 w-10 mr-2 -mt-3 bg-Warm-Red rounded-xl" onClick={() => {data.delete([{id}])}}><BsTrash className="h-full w-full text-white p-1"/></div>
|
71 |
<div title="Refresh Node" className="duration-300 cursor-pointer shadow-xl border-2 dark:border-white border-white h-10 w-10 mr-2 -mt-3 bg-Warm-Orange rounded-xl" onClick={() => {setRefresh((old) => old++)}}><BiRefresh className="h-full w-full text-white p-1"/></div>
|
72 |
</div>
|
73 |
</div>
|
frontend/src/components/ReactFlow/ReactFlowEnv.js
CHANGED
@@ -36,6 +36,13 @@ export default function ReactEnviorment() {
|
|
36 |
const reactFlowWrapper = useRef(null);
|
37 |
const [tool, setTool] = useState(false)
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
useEffect(() => {
|
40 |
const restore = () => {
|
41 |
const flow = JSON.parse(localStorage.getItem('flowkey'));
|
@@ -49,9 +56,8 @@ export default function ReactEnviorment() {
|
|
49 |
}
|
50 |
}
|
51 |
restore()
|
52 |
-
},[])
|
53 |
|
54 |
-
const deleteEdge = (id) => setEdges((eds) => eds.filter(e => e.id !== id))
|
55 |
|
56 |
|
57 |
const onNodesChange = useCallback(
|
@@ -79,7 +85,7 @@ export default function ReactEnviorment() {
|
|
79 |
console.log(error)
|
80 |
})
|
81 |
},
|
82 |
-
[setEdges]
|
83 |
);
|
84 |
|
85 |
|
@@ -89,8 +95,6 @@ export default function ReactEnviorment() {
|
|
89 |
event.dataTransfer.dropEffect = 'move';
|
90 |
}, []);
|
91 |
|
92 |
-
const deleteNodeContains = (id) =>{setNodes((nds) => nds.filter(n => !n.id.includes(`${id}-`) ))}
|
93 |
-
const deleteNode = (id) =>{setNodes((nds) => nds.filter(n => n.id !== id ))}
|
94 |
|
95 |
const onSave = useCallback(() => {
|
96 |
if (reactFlowInstance) {
|
@@ -152,7 +156,7 @@ export default function ReactEnviorment() {
|
|
152 |
setNodes((nds) => nds.concat(newNode));
|
153 |
}
|
154 |
},
|
155 |
-
[reactFlowInstance, nodes]);
|
156 |
|
157 |
return (
|
158 |
<div className={`${theme ? "dark" : ""}`}>
|
|
|
36 |
const reactFlowWrapper = useRef(null);
|
37 |
const [tool, setTool] = useState(false)
|
38 |
|
39 |
+
const deleteNodeContains = (id) =>{setNodes((nds) => nds.filter(n => !n.id.includes(`${id}-`) ))}
|
40 |
+
const deleteEdge = useCallback((id) => setEdges((eds) => eds.filter(e => e.id !== id)), [setEdges])
|
41 |
+
const deleteNode = useCallback((id) =>{
|
42 |
+
setNodes(() => nodes.filter(n => n.id !== id ))
|
43 |
+
}, [setNodes, nodes])
|
44 |
+
|
45 |
+
|
46 |
useEffect(() => {
|
47 |
const restore = () => {
|
48 |
const flow = JSON.parse(localStorage.getItem('flowkey'));
|
|
|
56 |
}
|
57 |
}
|
58 |
restore()
|
59 |
+
},[deleteNode, deleteEdge])
|
60 |
|
|
|
61 |
|
62 |
|
63 |
const onNodesChange = useCallback(
|
|
|
85 |
console.log(error)
|
86 |
})
|
87 |
},
|
88 |
+
[setEdges, deleteEdge]
|
89 |
);
|
90 |
|
91 |
|
|
|
95 |
event.dataTransfer.dropEffect = 'move';
|
96 |
}, []);
|
97 |
|
|
|
|
|
98 |
|
99 |
const onSave = useCallback(() => {
|
100 |
if (reactFlowInstance) {
|
|
|
156 |
setNodes((nds) => nds.concat(newNode));
|
157 |
}
|
158 |
},
|
159 |
+
[reactFlowInstance, nodes, deleteNode]);
|
160 |
|
161 |
return (
|
162 |
<div className={`${theme ? "dark" : ""}`}>
|