Skip to content
Snippets Groups Projects
Commit 9be140e0 authored by ali asaria's avatar ali asaria
Browse files

move add node to inside the workflow canvas

parent 198d3e41
No related branches found
No related tags found
No related merge requests found
import { Button } from '@mui/joy';
import { import {
Background, Background,
ControlButton, ControlButton,
...@@ -54,7 +55,7 @@ function generateEdges(workflow: any) { ...@@ -54,7 +55,7 @@ function generateEdges(workflow: any) {
return out; return out;
} }
const Flow = ({ selectedWorkflow }) => { const Flow = ({ selectedWorkflow, setNewNodeModalOpen = (x) => {} }) => {
const reactFlowInstance = useReactFlow(); const reactFlowInstance = useReactFlow();
// Use fitView after the component mounts // Use fitView after the component mounts
useEffect(() => { useEffect(() => {
...@@ -81,6 +82,26 @@ const Flow = ({ selectedWorkflow }) => { ...@@ -81,6 +82,26 @@ const Flow = ({ selectedWorkflow }) => {
panOnScroll={false} panOnScroll={false}
style={{ backgroundColor: '#F7F9FB' }} style={{ backgroundColor: '#F7F9FB' }}
> >
<Button
variant="plain"
sx={{
zIndex: '1000',
position: 'absolute',
bottom: '20px',
right: '20px',
}}
startDecorator={
<PlusCircleIcon
strokeWidth={2}
size={32}
onClick={() => {
setNewNodeModalOpen(true);
}}
/>
}
>
Add Node
</Button>
<Background color="#96ADE9" /> <Background color="#96ADE9" />
<Controls> <Controls>
<ControlButton <ControlButton
...@@ -91,19 +112,23 @@ const Flow = ({ selectedWorkflow }) => { ...@@ -91,19 +112,23 @@ const Flow = ({ selectedWorkflow }) => {
* *
</ControlButton> </ControlButton>
</Controls> </Controls>
<PlusCircleIcon
style={{ position: 'absolute', bottom: '20px', right: '20px' }}
strokeWidth={2}
size={32}
/>
</ReactFlow> </ReactFlow>
); );
}; };
export default function WorkflowCanvas({ selectedWorkflow }) { export default function WorkflowCanvas({
selectedWorkflow,
setNewNodeModalOpen = () => {},
}) {
if (!selectedWorkflow) {
return null;
}
return ( return (
<ReactFlowProvider> <ReactFlowProvider>
<Flow selectedWorkflow={selectedWorkflow} /> <Flow
selectedWorkflow={selectedWorkflow}
setNewNodeModalOpen={setNewNodeModalOpen}
/>
</ReactFlowProvider> </ReactFlowProvider>
); );
} }
...@@ -142,7 +142,10 @@ export default function Workflows({ experimentInfo }) { ...@@ -142,7 +142,10 @@ export default function Workflows({ experimentInfo }) {
}} }}
> >
{selectedWorkflow ? ( {selectedWorkflow ? (
<WorkflowCanvas selectedWorkflow={selectedWorkflow} /> <WorkflowCanvas
selectedWorkflow={selectedWorkflow}
setNewNodeModalOpen={setNewNodeflowModalOpen}
/>
) : ( ) : (
<Box sx={{ width: '100%', backgroundColor: '#F7F9FB' }} p={4}> <Box sx={{ width: '100%', backgroundColor: '#F7F9FB' }} p={4}>
Select Workflow Select Workflow
...@@ -162,15 +165,15 @@ export default function Workflows({ experimentInfo }) { ...@@ -162,15 +165,15 @@ export default function Workflows({ experimentInfo }) {
Running Running
</Button> </Button>
)} )}
<Button {/* <Button
startDecorator={<PlusIcon />} startDecorator={<PlusIcon />}
onClick={() => setNewNodeflowModalOpen(true)} onClick={() => setNewNodeflowModalOpen(true)}
> >
Add Node Add Node
</Button> </Button> */}
<Button startDecorator={<PenIcon />} variant="outlined"> {/* <Button startDecorator={<PenIcon />} variant="outlined">
Edit Edit
</Button> </Button> */}
<Button startDecorator={<AxeIcon />} variant="outlined"> <Button startDecorator={<AxeIcon />} variant="outlined">
Fight Fight
</Button> </Button>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment