Updated Design of Sidebar
This commit is contained in:
parent
3ff9e6a369
commit
e8f9894e05
@ -1,6 +1,6 @@
|
|||||||
////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: <ProjectRoot>/Data/WebUI/src/Node_Sidebar.jsx
|
////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: <ProjectRoot>/Data/WebUI/src/Node_Sidebar.jsx
|
||||||
|
|
||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import {
|
import {
|
||||||
Accordion,
|
Accordion,
|
||||||
AccordionSummary,
|
AccordionSummary,
|
||||||
@ -19,17 +19,6 @@ import {
|
|||||||
Polyline as PolylineIcon
|
Polyline as PolylineIcon
|
||||||
} from "@mui/icons-material";
|
} from "@mui/icons-material";
|
||||||
|
|
||||||
/**
|
|
||||||
* Left sidebar for managing workflows and node categories.
|
|
||||||
*
|
|
||||||
* Props:
|
|
||||||
* - categorizedNodes (object of arrays, e.g. { "Category": [{...}, ...], ... })
|
|
||||||
* - handleExportFlow() => void
|
|
||||||
* - handleImportFlow() => void
|
|
||||||
* - handleOpenCloseAllDialog() => void
|
|
||||||
* - fileInputRef (ref to hidden file input)
|
|
||||||
* - onFileInputChange(event) => void
|
|
||||||
*/
|
|
||||||
export default function NodeSidebar({
|
export default function NodeSidebar({
|
||||||
categorizedNodes,
|
categorizedNodes,
|
||||||
handleExportFlow,
|
handleExportFlow,
|
||||||
@ -38,6 +27,12 @@ export default function NodeSidebar({
|
|||||||
fileInputRef,
|
fileInputRef,
|
||||||
onFileInputChange
|
onFileInputChange
|
||||||
}) {
|
}) {
|
||||||
|
const [expandedCategory, setExpandedCategory] = useState(null);
|
||||||
|
|
||||||
|
const handleAccordionChange = (category) => (_, isExpanded) => {
|
||||||
|
setExpandedCategory(isExpanded ? category : null);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@ -47,207 +42,114 @@ export default function NodeSidebar({
|
|||||||
overflowY: "auto"
|
overflowY: "auto"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{/* Workflows Section */}
|
||||||
<Accordion
|
<Accordion
|
||||||
defaultExpanded
|
defaultExpanded
|
||||||
square
|
square
|
||||||
disableGutters
|
disableGutters
|
||||||
sx={{
|
sx={{ "&:before": { display: "none" }, margin: 0, border: 0 }}
|
||||||
"&:before": { display: "none" },
|
|
||||||
margin: 0,
|
|
||||||
border: 0
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<AccordionSummary
|
<AccordionSummary
|
||||||
expandIcon={<ExpandMoreIcon />}
|
expandIcon={<ExpandMoreIcon />}
|
||||||
sx={{
|
sx={{
|
||||||
backgroundColor: "#2c2c2c",
|
backgroundColor: "#2c2c2c",
|
||||||
minHeight: "36px",
|
minHeight: "36px",
|
||||||
"& .MuiAccordionSummary-content": {
|
"& .MuiAccordionSummary-content": { margin: 0 }
|
||||||
margin: 0
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography
|
<Typography sx={{ fontSize: "0.9rem", color: "#0475c2" }}>
|
||||||
align="left"
|
|
||||||
sx={{
|
|
||||||
fontSize: "0.9rem",
|
|
||||||
color: "#0475c2"
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<b>Workflows</b>
|
<b>Workflows</b>
|
||||||
</Typography>
|
</Typography>
|
||||||
</AccordionSummary>
|
</AccordionSummary>
|
||||||
<AccordionDetails sx={{ p: 0, bgcolor: "#232323" }}>
|
<AccordionDetails sx={{ p: 0, bgcolor: "#232323" }}>
|
||||||
<Button
|
<Button fullWidth startIcon={<SaveIcon />} onClick={handleExportFlow} sx={buttonStyle}>
|
||||||
fullWidth
|
|
||||||
startIcon={<SaveIcon />}
|
|
||||||
sx={{
|
|
||||||
color: "#ccc",
|
|
||||||
backgroundColor: "#232323",
|
|
||||||
justifyContent: "flex-start",
|
|
||||||
pl: 2,
|
|
||||||
fontSize: "0.9rem",
|
|
||||||
textTransform: "none",
|
|
||||||
"&:hover": {
|
|
||||||
backgroundColor: "#2a2a2a"
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
onClick={handleExportFlow}
|
|
||||||
>
|
|
||||||
Export Current Flow
|
Export Current Flow
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button fullWidth startIcon={<FileOpenIcon />} onClick={handleImportFlow} sx={buttonStyle}>
|
||||||
fullWidth
|
|
||||||
startIcon={<FileOpenIcon />}
|
|
||||||
sx={{
|
|
||||||
color: "#ccc",
|
|
||||||
backgroundColor: "#232323",
|
|
||||||
justifyContent: "flex-start",
|
|
||||||
pl: 2,
|
|
||||||
fontSize: "0.9rem",
|
|
||||||
textTransform: "none",
|
|
||||||
"&:hover": {
|
|
||||||
backgroundColor: "#2a2a2a"
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
onClick={handleImportFlow}
|
|
||||||
>
|
|
||||||
Import Flow
|
Import Flow
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button fullWidth startIcon={<DeleteForeverIcon />} onClick={handleOpenCloseAllDialog} sx={buttonStyle}>
|
||||||
fullWidth
|
|
||||||
startIcon={<DeleteForeverIcon />}
|
|
||||||
sx={{
|
|
||||||
color: "#ccc",
|
|
||||||
backgroundColor: "#232323",
|
|
||||||
justifyContent: "flex-start",
|
|
||||||
pl: 2,
|
|
||||||
fontSize: "0.9rem",
|
|
||||||
textTransform: "none",
|
|
||||||
"&:hover": {
|
|
||||||
backgroundColor: "#2a2a2a"
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
onClick={handleOpenCloseAllDialog}
|
|
||||||
>
|
|
||||||
Close All Flows
|
Close All Flows
|
||||||
</Button>
|
</Button>
|
||||||
</AccordionDetails>
|
</AccordionDetails>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
|
{/* Nodes Section */}
|
||||||
<Accordion
|
<Accordion
|
||||||
defaultExpanded
|
defaultExpanded
|
||||||
square
|
square
|
||||||
disableGutters
|
disableGutters
|
||||||
sx={{
|
sx={{ "&:before": { display: "none" }, margin: 0, border: 0 }}
|
||||||
"&:before": { display: "none" },
|
|
||||||
margin: 0,
|
|
||||||
border: 0
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<AccordionSummary
|
<AccordionSummary
|
||||||
expandIcon={<ExpandMoreIcon />}
|
expandIcon={<ExpandMoreIcon />}
|
||||||
sx={{
|
sx={{
|
||||||
backgroundColor: "#2c2c2c",
|
backgroundColor: "#2c2c2c",
|
||||||
minHeight: "36px",
|
minHeight: "36px",
|
||||||
"& .MuiAccordionSummary-content": {
|
"& .MuiAccordionSummary-content": { margin: 0 }
|
||||||
margin: 0
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography
|
<Typography sx={{ fontSize: "0.9rem", color: "#0475c2" }}>
|
||||||
align="left"
|
|
||||||
sx={{
|
|
||||||
fontSize: "0.9rem",
|
|
||||||
color: "#0475c2"
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<b>Nodes</b>
|
<b>Nodes</b>
|
||||||
</Typography>
|
</Typography>
|
||||||
</AccordionSummary>
|
</AccordionSummary>
|
||||||
<AccordionDetails sx={{ p: 0 }}>
|
<AccordionDetails sx={{ p: 0 }}>
|
||||||
{Object.entries(categorizedNodes).map(([category, items]) => (
|
{Object.entries(categorizedNodes).map(([category, items]) => (
|
||||||
<div key={category} style={{ marginBottom: 0, backgroundColor: "#232323" }}>
|
<Accordion
|
||||||
<Divider
|
key={category}
|
||||||
|
square
|
||||||
|
expanded={expandedCategory === category}
|
||||||
|
onChange={handleAccordionChange(category)}
|
||||||
|
disableGutters
|
||||||
|
sx={{
|
||||||
|
bgcolor: "#232323",
|
||||||
|
"&:before": { display: "none" },
|
||||||
|
margin: 0,
|
||||||
|
border: 0
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<AccordionSummary
|
||||||
|
expandIcon={<ExpandMoreIcon />}
|
||||||
sx={{
|
sx={{
|
||||||
bgcolor: "transparent",
|
bgcolor: "#1e1e1e",
|
||||||
px: 2,
|
px: 2,
|
||||||
py: 0.75,
|
minHeight: "32px",
|
||||||
display: "flex",
|
"& .MuiAccordionSummary-content": { margin: 0 }
|
||||||
justifyContent: "center",
|
|
||||||
borderColor: "#333"
|
|
||||||
}}
|
}}
|
||||||
variant="fullWidth"
|
|
||||||
>
|
>
|
||||||
<Typography
|
<Typography sx={{ color: "#888", fontSize: "0.75rem" }}>
|
||||||
variant="caption"
|
|
||||||
sx={{
|
|
||||||
color: "#888",
|
|
||||||
fontSize: "0.75rem"
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{category}
|
{category}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Divider>
|
</AccordionSummary>
|
||||||
{items.map((nodeDef) => (
|
<AccordionDetails sx={{ px: 1, py: 0 }}>
|
||||||
<Tooltip
|
{items.map((nodeDef) => (
|
||||||
key={`${category}-${nodeDef.type}`}
|
<Tooltip
|
||||||
title={
|
key={`${category}-${nodeDef.type}`}
|
||||||
<span
|
title={
|
||||||
style={{
|
<span style={{ whiteSpace: "pre-line", wordWrap: "break-word", maxWidth: 220 }}>
|
||||||
whiteSpace: "pre-line",
|
{nodeDef.description || "Drag & Drop into Editor"}
|
||||||
wordWrap: "break-word",
|
</span>
|
||||||
maxWidth: 220
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{nodeDef.description || "Drag & Drop into Editor"}
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
placement="right"
|
|
||||||
arrow
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
fullWidth
|
|
||||||
sx={{
|
|
||||||
color: "#ccc",
|
|
||||||
backgroundColor: "#232323",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
pl: 2,
|
|
||||||
pr: 1,
|
|
||||||
fontSize: "0.9rem",
|
|
||||||
textTransform: "none",
|
|
||||||
"&:hover": {
|
|
||||||
backgroundColor: "#2a2a2a"
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
draggable
|
|
||||||
onDragStart={(event) => {
|
|
||||||
event.dataTransfer.setData("application/reactflow", nodeDef.type);
|
|
||||||
event.dataTransfer.effectAllowed = "move";
|
|
||||||
}}
|
|
||||||
startIcon={
|
|
||||||
<DragIndicatorIcon
|
|
||||||
sx={{
|
|
||||||
color: "#666",
|
|
||||||
fontSize: 18
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
}
|
||||||
|
placement="right"
|
||||||
|
arrow
|
||||||
>
|
>
|
||||||
<span style={{ flexGrow: 1, textAlign: "left" }}>
|
<Button
|
||||||
{nodeDef.label}
|
fullWidth
|
||||||
</span>
|
sx={nodeButtonStyle}
|
||||||
<PolylineIcon
|
draggable
|
||||||
sx={{
|
onDragStart={(event) => {
|
||||||
color: "#58a6ff",
|
event.dataTransfer.setData("application/reactflow", nodeDef.type);
|
||||||
fontSize: 18,
|
event.dataTransfer.effectAllowed = "move";
|
||||||
ml: 1
|
|
||||||
}}
|
}}
|
||||||
/>
|
startIcon={<DragIndicatorIcon sx={{ color: "#666", fontSize: 18 }} />}
|
||||||
</Button>
|
>
|
||||||
</Tooltip>
|
<span style={{ flexGrow: 1, textAlign: "left" }}>{nodeDef.label}</span>
|
||||||
))}
|
<PolylineIcon sx={{ color: "#58a6ff", fontSize: 18, ml: 1 }} />
|
||||||
</div>
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
))}
|
||||||
|
</AccordionDetails>
|
||||||
|
</Accordion>
|
||||||
))}
|
))}
|
||||||
</AccordionDetails>
|
</AccordionDetails>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
@ -263,3 +165,28 @@ export default function NodeSidebar({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const buttonStyle = {
|
||||||
|
color: "#ccc",
|
||||||
|
backgroundColor: "#232323",
|
||||||
|
justifyContent: "flex-start",
|
||||||
|
pl: 2,
|
||||||
|
fontSize: "0.9rem",
|
||||||
|
textTransform: "none",
|
||||||
|
"&:hover": {
|
||||||
|
backgroundColor: "#2a2a2a"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const nodeButtonStyle = {
|
||||||
|
color: "#ccc",
|
||||||
|
backgroundColor: "#232323",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
pl: 2,
|
||||||
|
pr: 1,
|
||||||
|
fontSize: "0.9rem",
|
||||||
|
textTransform: "none",
|
||||||
|
"&:hover": {
|
||||||
|
backgroundColor: "#2a2a2a"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user