-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Right-click to Duplicate (v0.2.6.7) (#150)
* Auto-change shortname upon model settings edit * Adding context menu to nodes on right-click * Add BaseNode and subclass all CF nodes with BaseNode component * Add BaseNode to CSVNode * Move HF and Aleph up in LLM list. * Rebuild react
- Loading branch information
Showing
28 changed files
with
239 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
{ | ||
"files": { | ||
"main.css": "/static/css/main.60127273.css", | ||
"main.js": "/static/js/main.ee990fc8.js", | ||
"main.css": "/static/css/main.8665fcca.css", | ||
"main.js": "/static/js/main.3027e2a4.js", | ||
"static/js/787.4c72bb55.chunk.js": "/static/js/787.4c72bb55.chunk.js", | ||
"index.html": "/index.html", | ||
"main.60127273.css.map": "/static/css/main.60127273.css.map", | ||
"main.ee990fc8.js.map": "/static/js/main.ee990fc8.js.map", | ||
"main.8665fcca.css.map": "/static/css/main.8665fcca.css.map", | ||
"main.3027e2a4.js.map": "/static/js/main.3027e2a4.js.map", | ||
"787.4c72bb55.chunk.js.map": "/static/js/787.4c72bb55.chunk.js.map" | ||
}, | ||
"entrypoints": [ | ||
"static/css/main.60127273.css", | ||
"static/js/main.ee990fc8.js" | ||
"static/css/main.8665fcca.css", | ||
"static/js/main.3027e2a4.js" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><script async src="https://www.googletagmanager.com/gtag/js?id=G-RN3FDBLMCR"></script><script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-RN3FDBLMCR")</script><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="A visual programming environment for prompt engineering"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>ChainForge</title><script defer="defer" src="/static/js/main.ee990fc8.js"></script><link href="/static/css/main.60127273.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html> | ||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><script async src="https://www.googletagmanager.com/gtag/js?id=G-RN3FDBLMCR"></script><script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-RN3FDBLMCR")</script><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="A visual programming environment for prompt engineering"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>ChainForge</title><script defer="defer" src="/static/js/main.3027e2a4.js"></script><link href="/static/css/main.8665fcca.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
...t-server/build/static/js/main.ee990fc8.js → ...t-server/build/static/js/main.3027e2a4.js
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...rver/build/static/js/main.ee990fc8.js.map → ...rver/build/static/js/main.3027e2a4.js.map
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* The base class for every node in ChainForge. | ||
* Used to wrap common behavior like right-click context menu. | ||
*/ | ||
|
||
import { useCallback, useMemo, useState, useRef } from "react"; | ||
import { Menu } from '@mantine/core'; | ||
import { IconCopy, IconX } from '@tabler/icons-react'; | ||
import AreYouSureModal from "./AreYouSureModal"; | ||
import useStore from './store'; | ||
|
||
export const BaseNode = ({children, classNames, nodeId, style}) => { | ||
|
||
const removeNode = useStore((state) => state.removeNode); | ||
const duplicateNode = useStore((state) => state.duplicateNode); | ||
|
||
const [contextMenuStyle, setContextMenuStyle] = useState({left: -100, top:0}); | ||
const [contextMenuOpened, setContextMenuOpened] = useState(false); | ||
|
||
// For 'delete node' confirmation popup | ||
const deleteConfirmModal = useRef(null); | ||
|
||
// Class styles for ChainForge nodes | ||
const classes = useMemo(() => { | ||
return "cfnode " + (classNames ?? ""); | ||
}, [classNames]); | ||
|
||
// Duplicate the node | ||
const handleDuplicateNode = useCallback(() => { | ||
duplicateNode(nodeId, { x: 28, y: 28 }); | ||
}, [nodeId, duplicateNode]); | ||
|
||
// Remove the node, after user confirmation dialog | ||
const handleRemoveNode = useCallback(() => { | ||
// Open the 'are you sure' modal: | ||
if (deleteConfirmModal && deleteConfirmModal.current) | ||
deleteConfirmModal.current.trigger(); | ||
}, [deleteConfirmModal]); | ||
|
||
const handleOpenContextMenu = (e) => { | ||
// Ignore all right-clicked elements that aren't divs: | ||
// (for instance, textfields should still have normal right-click) | ||
if (e.target.localName !== "div") | ||
return; | ||
|
||
e.preventDefault(); | ||
setContextMenuStyle({ | ||
dropdown: { | ||
position: 'absolute', | ||
left: e.pageX + 'px !important', | ||
top: e.pageY + 'px !important', | ||
boxShadow: '2px 2px 4px #ccc', | ||
} | ||
}); | ||
setContextMenuOpened(true); | ||
}; | ||
|
||
// A BaseNode is just a div with "cfnode" as a class, and optional other className(s) for the specific node. | ||
// It adds a context menu to all nodes upon right-click of the node itself (the div), to duplicate or delete the node. | ||
return (<div className={classes} onPointerDown={() => setContextMenuOpened(false)} onContextMenu={handleOpenContextMenu} style={style}> | ||
<AreYouSureModal ref={deleteConfirmModal} | ||
title="Delete node" | ||
message="Are you sure you want to delete this node? This action is irreversible." | ||
onConfirm={() => removeNode(nodeId)} /> | ||
<Menu opened={contextMenuOpened} withinPortal={true} onChange={setContextMenuOpened} styles={contextMenuStyle}> | ||
{children} | ||
<Menu.Dropdown> | ||
<Menu.Item key='duplicate' onClick={handleDuplicateNode}><IconCopy size='10pt' /> Duplicate Node</Menu.Item> | ||
<Menu.Item key='delete' onClick={handleRemoveNode}><IconX size='10pt' /> Delete Node</Menu.Item> | ||
</Menu.Dropdown> | ||
</Menu> | ||
</div>); | ||
}; | ||
|
||
export default BaseNode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.