Fixed Issues with Node Configuration Sidebar trying to use node label instead of "id"

This commit is contained in:
Nicole Rappe 2025-05-15 00:58:21 -06:00
parent 51caa741cc
commit 9aff34e8de
2 changed files with 17 additions and 20 deletions

View File

@ -43,17 +43,19 @@ export default function FlowEditor({
}) {
// Node Configuration Sidebar State
const [drawerOpen, setDrawerOpen] = useState(false);
const [selectedNodeLabel, setSelectedNodeLabel] = useState(null);
const [selectedNodeId, setSelectedNodeId] = useState(null);
useEffect(() => {
window.BorealisOpenDrawer = (label) => {
setSelectedNodeLabel(label);
window.BorealisOpenDrawer = (id) => {
setSelectedNodeId(id);
setDrawerOpen(true);
};
return () => {
delete window.BorealisOpenDrawer;
};
}, [nodes]);
}, []);
const selectedNode = nodes.find((n) => n.id === selectedNodeId);
const wrapperRef = useRef(null);
const { project } = useReactFlow();
@ -352,7 +354,6 @@ export default function FlowEditor({
if (nodeCountEl) nodeCountEl.innerText = nodes.length;
}, [nodes]);
const selectedNode = nodes.find((n) => n.data?.label === selectedNodeLabel);
const nodeDef = selectedNode
? Object.values(categorizedNodes).flat().find((def) => def.type === selectedNode.type)
: null;
@ -367,11 +368,12 @@ export default function FlowEditor({
<NodeConfigurationSidebar
drawerOpen={drawerOpen}
setDrawerOpen={setDrawerOpen}
title={selectedNode?.data?.label || ""}
title={selectedNode ? selectedNode.data?.label || selectedNode.id : ""}
nodeData={
selectedNode && nodeDef
? {
...nodeDef,
config: nodeDef.config,
usage_documentation: nodeDef.usage_documentation,
...selectedNode.data,
nodeId: selectedNode.id
}

View File

@ -66,7 +66,7 @@ const DataNode = ({ id, data }) => {
size="small"
onClick={() =>
window.BorealisOpenDrawer &&
window.BorealisOpenDrawer(data?.label || "Unknown Node", { ...data, nodeId: id })
window.BorealisOpenDrawer(id, { ...data, nodeId: id })
}
sx={{ padding: 0, marginRight: "-3px", color: "#58a6ff", width: "20px", height: "20px" }}
>
@ -88,19 +88,14 @@ export default {
{ key: "value", label: "Value", type: "text" }
],
usage_documentation: `
### DataNode Usage
### Description:
This node acts as a basic live data emitter. When connected to an upstream node, it inherits its value, otherwise it accepts user-defined input of either a number or a string.
This node acts as a live data emitter. When connected to an upstream source, it inherits its value. Otherwise, it accepts user-defined input.
**Acceptable Inputs**:
- **Static Value** (*Number or String*)
- **Use Cases**:
- Static constants
- Pass-through conduit
- Manual value input
- **Behavior**:
- Automatically updates on interval
- Emits data through BorealisValueBus
Ensure no input edge if manual input is required.
**Behavior**:
- **Pass-through Conduit** (*If Upstream Node is Connected*) > Value cannot be manually changed while connected to an upstream node.
- Uses global Borealis "**Update Rate**" for updating value if connected to an upstream node.
`.trim()
};