mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-07-27 08:48:27 -06:00
Configuration Panel Milestone 5
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: <ProjectRoot>/Data/WebUI/src/Node_Configuration_Sidebar.jsx
|
||||
import { Box, Typography, Tabs, Tab, TextField } from "@mui/material";
|
||||
import { Box, Typography, Tabs, Tab, TextField, MenuItem } from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
import { useReactFlow } from "reactflow";
|
||||
import ReactMarkdown from "react-markdown"; // Used for Node Usage Documentation
|
||||
@ -13,39 +13,117 @@ export default function NodeConfigurationSidebar({ drawerOpen, setDrawerOpen, ti
|
||||
const config = nodeData?.config || [];
|
||||
const nodeId = nodeData?.nodeId;
|
||||
|
||||
return config.map((field, index) => (
|
||||
<Box key={index} sx={{ mb: 2 }}>
|
||||
<Typography variant="body2" sx={{ color: "#ccc", mb: 0.5 }}>
|
||||
{field.label || field.key}
|
||||
</Typography>
|
||||
<TextField
|
||||
variant="outlined"
|
||||
size="small"
|
||||
fullWidth
|
||||
value={nodeData?.[field.key] || ""}
|
||||
onChange={(e) => {
|
||||
const newValue = e.target.value;
|
||||
if (!nodeId) return;
|
||||
setNodes((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" }
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
));
|
||||
return config.map((field, index) => {
|
||||
const value = nodeData?.[field.key] || "";
|
||||
|
||||
return (
|
||||
<Box key={index} sx={{ mb: 2 }}>
|
||||
<Typography variant="body2" sx={{ color: "#ccc", mb: 0.5 }}>
|
||||
{field.label || field.key}
|
||||
</Typography>
|
||||
|
||||
{field.type === "select" ? (
|
||||
<TextField
|
||||
select
|
||||
fullWidth
|
||||
size="small"
|
||||
value={value}
|
||||
onChange={(e) => {
|
||||
const newValue = e.target.value;
|
||||
if (!nodeId) return;
|
||||
setNodes((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) => (
|
||||
<MenuItem key={idx} value={opt}>
|
||||
{opt}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
|
||||
) : (
|
||||
<TextField
|
||||
variant="outlined"
|
||||
size="small"
|
||||
fullWidth
|
||||
value={value}
|
||||
onChange={(e) => {
|
||||
const newValue = e.target.value;
|
||||
if (!nodeId) return;
|
||||
setNodes((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" }
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
@ -95,7 +173,7 @@ export default function NodeConfigurationSidebar({ drawerOpen, setDrawerOpen, ti
|
||||
onChange={handleTabChange}
|
||||
variant="fullWidth"
|
||||
textColor="inherit"
|
||||
TabIndicatorProps={{ style: { backgroundColor: "#58a6ff" } }}
|
||||
TabIndicatorProps={{ style: { backgroundColor: "#ccc" } }}
|
||||
sx={{
|
||||
borderTop: "1px solid #333",
|
||||
borderBottom: "1px solid #333",
|
||||
@ -103,8 +181,27 @@ export default function NodeConfigurationSidebar({ drawerOpen, setDrawerOpen, ti
|
||||
height: "36px"
|
||||
}}
|
||||
>
|
||||
<Tab label="Config" sx={{ color: "#ccc", minHeight: "36px", height: "36px", textTransform: "none" }} />
|
||||
<Tab label="Usage Docs" sx={{ color: "#ccc", minHeight: "36px", height: "36px", textTransform: "none" }} />
|
||||
<Tab
|
||||
label="Config"
|
||||
sx={{
|
||||
color: "#ccc",
|
||||
"&.Mui-selected": { color: "#ccc" },
|
||||
minHeight: "36px",
|
||||
height: "36px",
|
||||
textTransform: "none"
|
||||
}}
|
||||
/>
|
||||
<Tab
|
||||
label="Usage Docs"
|
||||
sx={{
|
||||
color: "#ccc",
|
||||
"&.Mui-selected": { color: "#ccc" },
|
||||
minHeight: "36px",
|
||||
height: "36px",
|
||||
textTransform: "none"
|
||||
}}
|
||||
/>
|
||||
|
||||
</Tabs>
|
||||
</Box>
|
||||
|
||||
|
Reference in New Issue
Block a user