////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: /Data/WebUI/src/Node_Configuration_Sidebar.jsx import { Box, Typography, Tabs, Tab, TextField, MenuItem, IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from "@mui/material"; import React, { useState } from "react"; import { useReactFlow } from "reactflow"; import ReactMarkdown from "react-markdown"; // Used for Node Usage Documentation import EditIcon from "@mui/icons-material/Edit"; export default function NodeConfigurationSidebar({ drawerOpen, setDrawerOpen, title, nodeData, setNodes, selectedNode }) { const [activeTab, setActiveTab] = useState(0); const contextSetNodes = useReactFlow().setNodes; // Use setNodes from props if provided, else fallback to context (for backward compatibility) const effectiveSetNodes = setNodes || contextSetNodes; const handleTabChange = (_, newValue) => setActiveTab(newValue); // Rename dialog state const [renameOpen, setRenameOpen] = useState(false); const [renameValue, setRenameValue] = useState(title || ""); const renderConfigFields = () => { const config = nodeData?.config || []; const nodeId = nodeData?.nodeId; return config.map((field, index) => { const value = nodeData?.[field.key] || ""; return ( {field.label || field.key} {field.type === "select" ? ( { const newValue = e.target.value; if (!nodeId) return; effectiveSetNodes((nds) => nds.map((n) => n.id === nodeId ? { ...n, data: { ...n.data, [field.key]: newValue } } : n ) ); window.BorealisValueBus[nodeId] = newValue; }} SelectProps={{ MenuProps: { PaperProps: { sx: { bgcolor: "#1e1e1e", color: "#ccc", border: "1px solid #58a6ff", "& .MuiMenuItem-root": { color: "#ccc", fontSize: "0.85rem", "&:hover": { backgroundColor: "#2a2a2a" }, "&.Mui-selected": { backgroundColor: "#2c2c2c !important", color: "#58a6ff" }, "&.Mui-selected:hover": { backgroundColor: "#2a2a2a !important" } } } } } }} sx={{ "& .MuiOutlinedInput-root": { backgroundColor: "#1e1e1e", color: "#ccc", fontSize: "0.85rem", "& fieldset": { borderColor: "#444" }, "&:hover fieldset": { borderColor: "#58a6ff" }, "&.Mui-focused fieldset": { borderColor: "#58a6ff" } }, "& .MuiSelect-select": { backgroundColor: "#1e1e1e" } }} > {(field.options || []).map((opt, idx) => ( {opt} ))} ) : ( { const newValue = e.target.value; if (!nodeId) return; effectiveSetNodes((nds) => nds.map((n) => n.id === nodeId ? { ...n, data: { ...n.data, [field.key]: newValue } } : n ) ); window.BorealisValueBus[nodeId] = newValue; }} InputProps={{ sx: { backgroundColor: "#1e1e1e", color: "#ccc", "& fieldset": { borderColor: "#444" }, "&:hover fieldset": { borderColor: "#666" }, "&.Mui-focused fieldset": { borderColor: "#58a6ff" } } }} /> )} ); }); }; return ( <> setDrawerOpen(false)} sx={{ position: "absolute", top: 0, left: 0, right: 0, bottom: 0, backgroundColor: "rgba(0, 0, 0, 0.3)", opacity: drawerOpen ? 1 : 0, pointerEvents: drawerOpen ? "auto" : "none", transition: "opacity 0.6s ease", zIndex: 10 }} /> e.stopPropagation()} > {"Edit " + (title || "Node")} { setRenameValue(title || ""); setRenameOpen(true); }} sx={{ ml: 1, color: "#58a6ff" }} > {activeTab === 0 && renderConfigFields()} {activeTab === 1 && ( ( ), p: ({ node, ...props }) => ( ), ul: ({ node, ...props }) => (
    ), li: ({ node, ...props }) => (
  • ) }} /> )} {/* Rename Node Dialog */} setRenameOpen(false)} PaperProps={{ sx: { bgcolor: "#232323" } }} > Rename Node setRenameValue(e.target.value)} sx={{ mt: 1, bgcolor: "#1e1e1e", "& .MuiOutlinedInput-root": { color: "#ccc", backgroundColor: "#1e1e1e", "& fieldset": { borderColor: "#444" } }, label: { color: "#aaa" } }} /> ); }