From d9d53ddf860da15cf271b57b4778da185d72c337 Mon Sep 17 00:00:00 2001 From: Christofon Date: Sat, 1 Apr 2023 16:15:28 +0200 Subject: [PATCH 01/12] FIX #13 --- src/components/App.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index b2ce7be..1689ef8 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -164,13 +164,16 @@ function App() { const [edges, setEdges, onEdgesChange] = useEdgesState([]); const onConnect = (connection: Edge | Connection) => { - // Check the lineage of the source node to make - // sure we aren't creating a recursive connection. + if ( + // Check the lineage of the source node to make + // sure we aren't creating a recursive connection. isFluxNodeInLineage(nodes, edges, { nodeToCheck: connection.target!, nodeToGetLineageOf: connection.source!, - }) + }) || + // Check if the target node already has a parent. + getFluxNodeParent(nodes, edges, connection.target!) !== undefined ) return; From f8386f929091443c5732a783ff4642a285259680 Mon Sep 17 00:00:00 2001 From: Christofon Date: Sat, 1 Apr 2023 16:29:18 +0200 Subject: [PATCH 02/12] enable edge manipulation --- src/components/App.tsx | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 1689ef8..acd46e5 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useEffect, useState, useCallback, useRef } from "react"; import ReactFlow, { addEdge, @@ -12,6 +12,7 @@ import ReactFlow, { ReactFlowInstance, ReactFlowJsonObject, useReactFlow, + updateEdge } from "reactflow"; import "reactflow/dist/style.css"; @@ -163,6 +164,29 @@ function App() { const [nodes, setNodes, onNodesChange] = useNodesState([]); const [edges, setEdges, onEdgesChange] = useEdgesState([]); + const edgeUpdateSuccessful = useRef(true); + + const onEdgeUpdateStart = useCallback(() => { + edgeUpdateSuccessful.current = false; + }, []); + + const onEdgeUpdate = useCallback((oldEdge: Edge, newConnection: Connection) => { + if (getFluxNodeParent(nodes, edges, newConnection.target!) !== undefined) { + return; + } + + edgeUpdateSuccessful.current = true; + setEdges((edges) => updateEdge(oldEdge, newConnection, edges)); + }, [nodes, edges]); + + const onEdgeUpdateEnd = useCallback((_: React.MouseEvent, edge: Edge) => { + if (!edgeUpdateSuccessful.current) { + setEdges((edges) => edges.filter((e) => e.id !== edge.id)); + } + + edgeUpdateSuccessful.current = true; + }, []); + const onConnect = (connection: Edge | Connection) => { if ( @@ -923,6 +947,9 @@ function App() { onEdgesChange={onEdgesChange} onEdgesDelete={takeSnapshot} onNodesDelete={takeSnapshot} + onEdgeUpdateStart={onEdgeUpdateStart} + onEdgeUpdate={onEdgeUpdate} + onEdgeUpdateEnd={onEdgeUpdateEnd} onConnect={onConnect} // Causes clicks to also trigger auto zoom. // onNodeDragStop={autoZoomIfNecessary} From f61d416bd4cc6793ebab6c3a8a3c808edbbc1e98 Mon Sep 17 00:00:00 2001 From: Christofon Date: Sat, 1 Apr 2023 19:32:19 +0200 Subject: [PATCH 03/12] adjust type --- src/components/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index acd46e5..17b824f 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -179,7 +179,7 @@ function App() { setEdges((edges) => updateEdge(oldEdge, newConnection, edges)); }, [nodes, edges]); - const onEdgeUpdateEnd = useCallback((_: React.MouseEvent, edge: Edge) => { + const onEdgeUpdateEnd = useCallback((_: unknown, edge: Edge) => { if (!edgeUpdateSuccessful.current) { setEdges((edges) => edges.filter((e) => e.id !== edge.id)); } From d2dc5dfed5062699ed4aebd6e98b7d3a042346e4 Mon Sep 17 00:00:00 2001 From: Christofon Date: Sat, 1 Apr 2023 22:26:00 +0200 Subject: [PATCH 04/12] implement `getConnectionAllowed` & replace checks --- src/components/App.tsx | 25 ++++++++++++------------- src/utils/fluxNode.ts | 24 ++++++++++++++++++++---- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 17b824f..9165d0f 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -46,7 +46,6 @@ import { newFluxNode, appendTextToFluxNodeAsGPT, getFluxNodeLineage, - isFluxNodeInLineage, addFluxNode, modifyFluxNode, getFluxNodeChildren, @@ -57,6 +56,7 @@ import { deleteSelectedFluxNodes, addUserNodeLinkedToASystemNode, markFluxNodeAsDoneGenerating, + getConnectionAllowed, } from "../utils/fluxNode"; import { FluxNodeData, @@ -171,7 +171,11 @@ function App() { }, []); const onEdgeUpdate = useCallback((oldEdge: Edge, newConnection: Connection) => { - if (getFluxNodeParent(nodes, edges, newConnection.target!) !== undefined) { + const connectionAllowed = getConnectionAllowed(nodes, edges, { + source: newConnection.source!, + target: newConnection.target! + }); + if (!connectionAllowed) { return; } @@ -188,18 +192,13 @@ function App() { }, []); const onConnect = (connection: Edge | Connection) => { - - if ( - // Check the lineage of the source node to make - // sure we aren't creating a recursive connection. - isFluxNodeInLineage(nodes, edges, { - nodeToCheck: connection.target!, - nodeToGetLineageOf: connection.source!, - }) || - // Check if the target node already has a parent. - getFluxNodeParent(nodes, edges, connection.target!) !== undefined - ) + const connectionAllowed = getConnectionAllowed(nodes, edges, { + source: connection.source!, + target: connection.target! + }); + if (!connectionAllowed) { return; + } takeSnapshot(); setEdges((eds) => addEdge({ ...connection }, eds)); diff --git a/src/utils/fluxNode.ts b/src/utils/fluxNode.ts index a8fab84..e6d2f5d 100644 --- a/src/utils/fluxNode.ts +++ b/src/utils/fluxNode.ts @@ -80,8 +80,8 @@ export function addUserNodeLinkedToASystemNode( x: nodesCopy.length > 0 ? nodesCopy.reduce((prev, current) => - prev.position.x > current.position.x ? prev : current - ).position.x + NEW_TREE_X_OFFSET + prev.position.x > current.position.x ? prev : current + ).position.x + NEW_TREE_X_OFFSET : window.innerWidth / 2 / 2 - 75, y: 500, fluxNodeType: FluxNodeType.System, @@ -285,6 +285,22 @@ export function isFluxNodeInLineage( return lineage.some((node) => node.id === nodeToCheck); } +export function getConnectionAllowed( + existingNodes: Node[], + existingEdges: Edge[], + { source, target }: { source: string, target: string } +): boolean { + return ( + // Check the lineage of the source node to make + // sure we aren't creating a recursive connection. + !isFluxNodeInLineage(existingNodes, existingEdges, { + nodeToCheck: target, + nodeToGetLineageOf: source, + // Check if the target node already has a parent. + }) && getFluxNodeParent(existingNodes, existingEdges, target) === undefined + ); +} + /*////////////////////////////////////////////////////////////// RENDERERS //////////////////////////////////////////////////////////////*/ @@ -302,8 +318,8 @@ export function displayNameFromFluxNodeType( return isGPT4 === undefined ? "GPT (edited)" : isGPT4 - ? "GPT-4 (edited)" - : "GPT-3.5 (edited)"; + ? "GPT-4 (edited)" + : "GPT-3.5 (edited)"; case FluxNodeType.System: return "System"; } From e2d9e6ccee0df9b967a6c3841277c44425650ed5 Mon Sep 17 00:00:00 2001 From: t11s Date: Sat, 1 Apr 2023 14:26:57 -0700 Subject: [PATCH 05/12] nit: small style nits --- src/components/App.tsx | 30 +++++++++++++++--------------- src/utils/fluxNode.ts | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 85af8da..b6e4807 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -12,7 +12,7 @@ import ReactFlow, { ReactFlowInstance, ReactFlowJsonObject, useReactFlow, - updateEdge + updateEdge, } from "reactflow"; import "reactflow/dist/style.css"; @@ -173,18 +173,18 @@ function App() { edgeUpdateSuccessful.current = false; }, []); - const onEdgeUpdate = useCallback((oldEdge: Edge, newConnection: Connection) => { - const connectionAllowed = getConnectionAllowed(nodes, edges, { - source: newConnection.source!, - target: newConnection.target! - }); - if (!connectionAllowed) { + const onEdgeUpdate = (oldEdge: Edge, newConnection: Connection) => { + if ( + !getConnectionAllowed(nodes, edges, { + source: newConnection.source!, + target: newConnection.target!, + }) + ) return; - } edgeUpdateSuccessful.current = true; setEdges((edges) => updateEdge(oldEdge, newConnection, edges)); - }, [nodes, edges]); + }; const onEdgeUpdateEnd = useCallback((_: unknown, edge: Edge) => { if (!edgeUpdateSuccessful.current) { @@ -195,13 +195,13 @@ function App() { }, []); const onConnect = (connection: Edge | Connection) => { - const connectionAllowed = getConnectionAllowed(nodes, edges, { - source: connection.source!, - target: connection.target! - }); - if (!connectionAllowed) { + if ( + !getConnectionAllowed(nodes, edges, { + source: connection.source!, + target: connection.target!, + }) + ) return; - } takeSnapshot(); setEdges((eds) => addEdge({ ...connection }, eds)); diff --git a/src/utils/fluxNode.ts b/src/utils/fluxNode.ts index 5f39fbf..fd23e89 100644 --- a/src/utils/fluxNode.ts +++ b/src/utils/fluxNode.ts @@ -80,8 +80,8 @@ export function addUserNodeLinkedToASystemNode( x: nodesCopy.length > 0 ? nodesCopy.reduce((prev, current) => - prev.position.x > current.position.x ? prev : current - ).position.x + NEW_TREE_X_OFFSET + prev.position.x > current.position.x ? prev : current + ).position.x + NEW_TREE_X_OFFSET : window.innerWidth / 2 / 2 - 75, y: 500, fluxNodeType: FluxNodeType.System, @@ -322,7 +322,7 @@ export function isFluxNodeInLineage( export function getConnectionAllowed( existingNodes: Node[], existingEdges: Edge[], - { source, target }: { source: string, target: string } + { source, target }: { source: string; target: string } ): boolean { return ( // Check the lineage of the source node to make From 8347a3e7f53824f9506a92e44af28819fd1a7a5f Mon Sep 17 00:00:00 2001 From: Christofon Date: Sun, 2 Apr 2023 10:46:54 +0200 Subject: [PATCH 06/12] merge changes --- src/components/App.tsx | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index b163eb3..51d13cb 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -202,28 +202,6 @@ function App() { }) ) return; - } - - edgeUpdateSuccessful.current = true; - setEdges((edges) => updateEdge(oldEdge, newConnection, edges)); - }, [nodes, edges]); - - const onEdgeUpdateEnd = useCallback((_: unknown, edge: Edge) => { - if (!edgeUpdateSuccessful.current) { - setEdges((edges) => edges.filter((e) => e.id !== edge.id)); - } - - edgeUpdateSuccessful.current = true; - }, []); - - const onConnect = (connection: Edge | Connection) => { - const connectionAllowed = getConnectionAllowed(nodes, edges, { - source: connection.source!, - target: connection.target! - }); - if (!connectionAllowed) { - return; - } takeSnapshot(); setEdges((eds) => addEdge({ ...connection }, eds)); @@ -1079,4 +1057,4 @@ function App() { ); } -export default App; +export default App; \ No newline at end of file From 8c3415b08a06b07bd1763cb4e677a3778e05f5f1 Mon Sep 17 00:00:00 2001 From: Christofon Date: Sun, 2 Apr 2023 16:52:52 +0200 Subject: [PATCH 07/12] bug: make snapshot before manipulating edges --- src/components/App.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 51d13cb..909dd19 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -183,16 +183,18 @@ function App() { return; edgeUpdateSuccessful.current = true; + takeSnapshot(); setEdges((edges) => updateEdge(oldEdge, newConnection, edges)); }; - const onEdgeUpdateEnd = useCallback((_: unknown, edge: Edge) => { + const onEdgeUpdateEnd = (_: unknown, edge: Edge) => { if (!edgeUpdateSuccessful.current) { + takeSnapshot(); setEdges((edges) => edges.filter((e) => e.id !== edge.id)); } edgeUpdateSuccessful.current = true; - }, []); + }; const onConnect = (connection: Edge | Connection) => { if ( From eb7872a94545357b6ade0d3f79387351cc5950e7 Mon Sep 17 00:00:00 2001 From: t11s Date: Sun, 2 Apr 2023 14:32:13 -0700 Subject: [PATCH 08/12] Update src/components/App.tsx --- src/components/App.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 909dd19..51fd8dc 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -182,8 +182,10 @@ function App() { ) return; - edgeUpdateSuccessful.current = true; takeSnapshot(); + + edgeUpdateSuccessful.current = true; + setEdges((edges) => updateEdge(oldEdge, newConnection, edges)); }; From 0e1b6249c33a73117a9276098189966863098e90 Mon Sep 17 00:00:00 2001 From: t11s Date: Sun, 2 Apr 2023 14:32:18 -0700 Subject: [PATCH 09/12] Update src/components/App.tsx --- src/components/App.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/App.tsx b/src/components/App.tsx index 51fd8dc..ea3f32a 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -192,6 +192,7 @@ function App() { const onEdgeUpdateEnd = (_: unknown, edge: Edge) => { if (!edgeUpdateSuccessful.current) { takeSnapshot(); + setEdges((edges) => edges.filter((e) => e.id !== edge.id)); } From 1c9a6a7ccf04c4b7e6c604ca17fe4488a6346c0b Mon Sep 17 00:00:00 2001 From: t11s Date: Sun, 2 Apr 2023 14:33:29 -0700 Subject: [PATCH 10/12] Update src/components/App.tsx --- src/components/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index ea3f32a..27135cb 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1062,4 +1062,4 @@ function App() { ); } -export default App; \ No newline at end of file +export default App; From 812575a1d42813dcdada20090882fab2af9dfc11 Mon Sep 17 00:00:00 2001 From: Christofon Date: Thu, 13 Apr 2023 23:04:02 +0200 Subject: [PATCH 11/12] WIP: import/export nodes --- src/components/App.tsx | 134 +++++++++++++++++++++++-- src/components/modals/ExportModal.tsx | 85 ++++++++++++++++ src/components/utils/NavigationBar.tsx | 9 ++ src/utils/fluxNode.ts | 16 +++ 4 files changed, 234 insertions(+), 10 deletions(-) create mode 100644 src/components/modals/ExportModal.tsx diff --git a/src/components/App.tsx b/src/components/App.tsx index fbe0c7b..3de3f1f 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -41,6 +41,7 @@ import { addUserNodeLinkedToASystemNode, getConnectionAllowed, setFluxNodeStreamId, + getEdgesForFluxNodes, } from "../utils/fluxNode"; import { useLocalStorage } from "../utils/lstore"; import { mod } from "../utils/mod"; @@ -59,6 +60,7 @@ import { import { Prompt } from "./Prompt"; import { APIKeyModal } from "./modals/APIKeyModal"; import { SettingsModal } from "./modals/SettingsModal"; +import { ExportModal } from "./modals/ExportModal"; import { BigButton } from "./utils/BigButton"; import { NavigationBar } from "./utils/NavigationBar"; import { CheckCircleIcon } from "@chakra-ui/icons"; @@ -340,12 +342,12 @@ function App() { x: (currentNodeChildren.length > 0 ? // If there are already children we want to put the - // next child to the right of the furthest right one. - currentNodeChildren.reduce((prev, current) => - prev.position.x > current.position.x ? prev : current - ).position.x + - (responses / 2) * 180 + - 90 + // next child to the right of the furthest right one. + currentNodeChildren.reduce((prev, current) => + prev.position.x > current.position.x ? prev : current + ).position.x + + (responses / 2) * 180 + + 90 : currentNode.position.x) + (i - (responses - 1) / 2) * 180, // Add OVERLAP_RANDOMNESS_MAX of randomness to the y position so that nodes don't overlap. @@ -669,10 +671,10 @@ function App() { x: selectedNodeChildren.length > 0 ? // If there are already children we want to put the - // next child to the right of the furthest right one. - selectedNodeChildren.reduce((prev, current) => - prev.position.x > current.position.x ? prev : current - ).position.x + 180 + // next child to the right of the furthest right one. + selectedNodeChildren.reduce((prev, current) => + prev.position.x > current.position.x ? prev : current + ).position.x + 180 : selectedNode.position.x, // Add OVERLAP_RANDOMNESS_MAX of randomness to // the y position so that nodes don't overlap. @@ -858,6 +860,106 @@ function App() { [settings] ); + /*////////////////////////////////////////////////////////////// + IMPORT/EXPORT MODAL LOGIC + //////////////////////////////////////////////////////////////*/ + + const { + isOpen: isExportModalOpen, + onOpen: onOpenExportModal, + onClose: onCloseExportModal, + } = useDisclosure(); + + const getExportData = () => { + const selectedNodes = nodes.filter((node) => node.selected); + + const exportData: Object = { + nodes: selectedNodes.length > 0 ? selectedNodes : nodes, + edges: getEdgesForFluxNodes(selectedNodes.length > 0 ? selectedNodes : nodes, edges), + }; + + return JSON.stringify(exportData); + }; + + function nodesOverlap( + nodeA: Node, + nodeB: Node, + padding: number = 20 + ) { + const xOverlap = Math.abs(nodeA.position.x - nodeB.position.x) < padding; + const yOverlap = Math.abs(nodeA.position.y - nodeB.position.y) < padding; + + return xOverlap && yOverlap; + } + + function adjustPosition(overlappingNode: Node, + offsetX: number = 200, + offsetY: number = 200) { + return { + ...overlappingNode, + position: { + x: overlappingNode.position.x + offsetX, + y: overlappingNode.position.y + offsetY + } + }; + } + + function adjustPositionImportedNodes( + existingNodes: Node[], + importedNodes: Node[] + ) { + let adjustedImportedNodes = importedNodes; + + for (const existingNode of existingNodes) { + adjustedImportedNodes = adjustedImportedNodes.map(importedNode => { + if (nodesOverlap(existingNode, importedNode)) { + return adjustPosition(importedNode); + } else { + return importedNode; + } + }); + } + + return [...existingNodes, ...adjustedImportedNodes]; + } + + const importData = (data: string) => { + // Make import reversible + takeSnapshot(); + try { + const parsedData = JSON.parse(data); + + // Generate new IDs for the imported nodes. + parsedData.nodes.forEach((node: Node) => { + const oldNodeId = node.id; + node.id = Math.random().toString(36).substr(2, 16); + + // Update the source and target of any edges that point to the old node ID. + parsedData.edges.forEach((edge: Edge) => { + if (edge.source === oldNodeId) edge.source = node.id; + if (edge.target === oldNodeId) edge.target = node.id; + }); + }); + + // Generate new IDs for the imported edges. + parsedData.edges.forEach((edge: Edge) => { + edge.id = Math.random().toString(36).substr(2, 16); + }); + + setNodes(adjustPositionImportedNodes(nodes, parsedData.nodes)); + setEdges([...edges, ...parsedData.edges]); + } catch (e) { + toast({ + title: "Failed to import!", + description: "Please try again.", + status: "error", + ...TOAST_CONFIG, + }); + console.log(e); + } + + }; + /*////////////////////////////////////////////////////////////// API KEY LOGIC //////////////////////////////////////////////////////////////*/ @@ -1001,6 +1103,16 @@ function App() { apiKey={apiKey} setApiKey={setApiKey} /> + newUserNodeLinkedToANewSystemNode() } + exportModalOpen={() => onOpenExportModal()} newConnectedToSelectedNode={newConnectedToSelectedNode} deleteSelectedNodes={deleteSelectedNodes} submitPrompt={() => submitPrompt(false)} @@ -1099,6 +1212,7 @@ function App() { onEdgeUpdate={onEdgeUpdate} onEdgeUpdateEnd={onEdgeUpdateEnd} onConnect={onConnect} + // onInit={setRfInstance} nodeTypes={REACT_FLOW_NODE_TYPES} // Causes clicks to also trigger auto zoom. // onNodeDragStop={autoZoomIfNecessary} diff --git a/src/components/modals/ExportModal.tsx b/src/components/modals/ExportModal.tsx new file mode 100644 index 0000000..8c57f38 --- /dev/null +++ b/src/components/modals/ExportModal.tsx @@ -0,0 +1,85 @@ +import { useState, useEffect } from "react"; +import { copySnippetToClipboard } from "../../utils/clipboard"; +import { CopyIcon } from "@chakra-ui/icons"; +import { + Modal, + ModalOverlay, + ModalHeader, + ModalCloseButton, + ModalContent, + Button, + Textarea +} from "@chakra-ui/react"; + +import { Column, Row } from "../../utils/chakra"; + +export function ExportModal({ + isOpen, + onClose, + exportData, + importData, +}: { + isOpen: boolean; + onClose: () => void; + exportData: string; + importData: (data: string) => void; +}) { + const [data, setData] = useState(exportData); + + let handleInputChange = (e: React.ChangeEvent) => { + let inputValue = e.target.value + setData(inputValue) + } + + return ( + + + + Import/Export + + + + + + + + + + + ); +} + +const CopyButton = ({ data }: { data: string }) => { + const [copied, setCopied] = useState(false); + + const handleCopyButtonClick = async (e: React.MouseEvent) => { + e.stopPropagation(); // Prevent this from triggering edit mode in the parent. + + if (await copySnippetToClipboard(data)) setCopied(true); + }; + + useEffect(() => { + if (copied) { + const timer = setTimeout(() => setCopied(false), 2000); + return () => clearTimeout(timer); + } + }, [copied]); + + return ( + + ); +}; \ No newline at end of file diff --git a/src/components/utils/NavigationBar.tsx b/src/components/utils/NavigationBar.tsx index 13712c3..3ac3c64 100644 --- a/src/components/utils/NavigationBar.tsx +++ b/src/components/utils/NavigationBar.tsx @@ -24,6 +24,7 @@ import paradigm from "/paradigm.svg"; export function NavigationBar({ newUserNodeLinkedToANewSystemNode, + exportModalOpen, newConnectedToSelectedNode, submitPrompt, regenerate, @@ -42,6 +43,7 @@ export function NavigationBar({ onOpenSettingsModal, }: { newUserNodeLinkedToANewSystemNode: () => void; + exportModalOpen: () => void; newConnectedToSelectedNode: (nodeType: FluxNodeType) => void; submitPrompt: () => void; regenerate: () => void; @@ -188,6 +190,13 @@ export function NavigationBar({ + + + + Import/Export + + + diff --git a/src/utils/fluxNode.ts b/src/utils/fluxNode.ts index 02aa010..e93e587 100644 --- a/src/utils/fluxNode.ts +++ b/src/utils/fluxNode.ts @@ -338,6 +338,22 @@ export function getFluxNodeLineage( return lineage; } +// returns all the edges for a given nodes +export function getEdgesForFluxNodes( + nodes: Node[], + existingEdges: Edge[], +): Edge[] { + const edges: Edge[] = []; + + existingEdges.forEach((edge) => { + if (nodes.find((node) => node.id === edge.source) && nodes.find((node) => node.id === edge.target)) { + edges.push(edge); + } + }); + + return edges; +} + export function isFluxNodeInLineage( existingNodes: Node[], existingEdges: Edge[], From 277989c323e9b5ca434c7bc2b2a9cabeab1f9e32 Mon Sep 17 00:00:00 2001 From: Christofon Date: Thu, 13 Apr 2023 23:20:17 +0200 Subject: [PATCH 12/12] change event type --- src/components/modals/ExportModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/modals/ExportModal.tsx b/src/components/modals/ExportModal.tsx index 8c57f38..5dccacd 100644 --- a/src/components/modals/ExportModal.tsx +++ b/src/components/modals/ExportModal.tsx @@ -26,7 +26,7 @@ export function ExportModal({ }) { const [data, setData] = useState(exportData); - let handleInputChange = (e: React.ChangeEvent) => { + let handleInputChange = (e: React.ChangeEvent) => { let inputValue = e.target.value setData(inputValue) }