Implemented "Close Workflow" functionality with confirmation dialog box.
This commit is contained in:
parent
a97c1434aa
commit
467225d89e
@ -12,7 +12,12 @@ import {
|
|||||||
createTheme,
|
createTheme,
|
||||||
Accordion,
|
Accordion,
|
||||||
AccordionSummary,
|
AccordionSummary,
|
||||||
AccordionDetails
|
AccordionDetails,
|
||||||
|
Dialog,
|
||||||
|
DialogTitle,
|
||||||
|
DialogContent,
|
||||||
|
DialogContentText,
|
||||||
|
DialogActions
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
|
||||||
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
||||||
@ -45,20 +50,16 @@ const CustomNode = ({ data }) => {
|
|||||||
boxShadow: "0 0 10px rgba(0,0,0,0.2)",
|
boxShadow: "0 0 10px rgba(0,0,0,0.2)",
|
||||||
position: "relative"
|
position: "relative"
|
||||||
}}>
|
}}>
|
||||||
{/* Input handle on the left */}
|
|
||||||
<Handle
|
<Handle
|
||||||
type="target"
|
type="target"
|
||||||
position={Position.Left}
|
position={Position.Left}
|
||||||
style={{ background: "#58a6ff", width: 10, height: 10 }}
|
style={{ background: "#58a6ff", width: 10, height: 10 }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Output handle on the right */}
|
|
||||||
<Handle
|
<Handle
|
||||||
type="source"
|
type="source"
|
||||||
position={Position.Right}
|
position={Position.Right}
|
||||||
style={{ background: "#58a6ff", width: 10, height: 10 }}
|
style={{ background: "#58a6ff", width: 10, height: 10 }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div style={{
|
<div style={{
|
||||||
background: "#232323",
|
background: "#232323",
|
||||||
padding: "6px 10px",
|
padding: "6px 10px",
|
||||||
@ -200,10 +201,19 @@ export default function App() {
|
|||||||
const [aboutAnchorEl, setAboutAnchorEl] = useState(null);
|
const [aboutAnchorEl, setAboutAnchorEl] = useState(null);
|
||||||
const [nodes, setNodes] = useState([]);
|
const [nodes, setNodes] = useState([]);
|
||||||
const [edges, setEdges] = useState([]);
|
const [edges, setEdges] = useState([]);
|
||||||
|
const [confirmCloseOpen, setConfirmCloseOpen] = useState(false);
|
||||||
|
|
||||||
const handleAboutMenuOpen = (event) => setAboutAnchorEl(event.currentTarget);
|
const handleAboutMenuOpen = (event) => setAboutAnchorEl(event.currentTarget);
|
||||||
const handleAboutMenuClose = () => setAboutAnchorEl(null);
|
const handleAboutMenuClose = () => setAboutAnchorEl(null);
|
||||||
|
|
||||||
|
const handleOpenCloseDialog = () => setConfirmCloseOpen(true);
|
||||||
|
const handleCloseDialog = () => setConfirmCloseOpen(false);
|
||||||
|
const handleConfirmCloseWorkflow = () => {
|
||||||
|
setNodes([]);
|
||||||
|
setEdges([]);
|
||||||
|
setConfirmCloseOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
const handleAddTestNode = () => {
|
const handleAddTestNode = () => {
|
||||||
const id = `test-node-${Date.now()}`;
|
const id = `test-node-${Date.now()}`;
|
||||||
const newNode = {
|
const newNode = {
|
||||||
@ -264,7 +274,13 @@ export default function App() {
|
|||||||
<AccordionDetails sx={{ p: 0 }}>
|
<AccordionDetails sx={{ p: 0 }}>
|
||||||
<Button fullWidth sx={sidebarBtnStyle}>SAVE WORKFLOW</Button>
|
<Button fullWidth sx={sidebarBtnStyle}>SAVE WORKFLOW</Button>
|
||||||
<Button fullWidth sx={sidebarBtnStyle}>OPEN WORKFLOW</Button>
|
<Button fullWidth sx={sidebarBtnStyle}>OPEN WORKFLOW</Button>
|
||||||
<Button fullWidth sx={sidebarBtnStyle}>CLOSE WORKFLOW</Button>
|
<Button
|
||||||
|
fullWidth
|
||||||
|
sx={sidebarBtnStyle}
|
||||||
|
onClick={handleOpenCloseDialog}
|
||||||
|
>
|
||||||
|
CLOSE WORKFLOW
|
||||||
|
</Button>
|
||||||
</AccordionDetails>
|
</AccordionDetails>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
@ -310,6 +326,28 @@ export default function App() {
|
|||||||
<b>Nodes</b>: <span id="nodeCount">0</span> | <b>Update Rate</b>: 500ms
|
<b>Nodes</b>: <span id="nodeCount">0</span> | <b>Update Rate</b>: 500ms
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
{/* Confirmation Dialog */}
|
||||||
|
<Dialog
|
||||||
|
open={confirmCloseOpen}
|
||||||
|
onClose={handleCloseDialog}
|
||||||
|
PaperProps={{ sx: { bgcolor: "#1e1e1e", color: "#fff" } }}
|
||||||
|
>
|
||||||
|
<DialogTitle>Close Workflow?</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogContentText sx={{ color: "#ccc" }}>
|
||||||
|
Are you sure you want to reset the workflow? All nodes will be removed.
|
||||||
|
</DialogContentText>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button onClick={handleCloseDialog} sx={{ color: "#58a6ff" }}>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button onClick={handleConfirmCloseWorkflow} sx={{ color: "#ff4f4f" }}>
|
||||||
|
Close Workflow
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user