refactor of dagflow start
This commit is contained in:
1 parent
3cb6070aca
commit
d62c484f33
29 files changed
+1463
-16
No files matched your search
@@ -0,0 +1,66 @@
|
||||
import "./index.css";
|
||||
|
||||
import { FC } from "react";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import ReactFlow, { Controls } from "react-flow-renderer";
|
||||
|
||||
import { NodeEditor } from "components/NodeEditor";
|
||||
import { Modal } from "components/Modal";
|
||||
|
||||
import { nodeTypes } from "../nodes";
|
||||
import { DAGGraphBoardProps } from "./types";
|
||||
|
||||
export const DAGGraphBoard: FC<DAGGraphBoardProps> = ({
|
||||
modalState,
|
||||
state,
|
||||
closeModal,
|
||||
}) => {
|
||||
// render unready or errored states
|
||||
if (!state.ready) {
|
||||
return (
|
||||
<div className="dag-graphboard loading">
|
||||
<CircularProgress />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if ("error" in state.data) {
|
||||
return <div className="dag-graphboard errored">{state.data.error}</div>;
|
||||
}
|
||||
|
||||
// modal
|
||||
let modalBody = <></>;
|
||||
if (modalState) {
|
||||
modalBody = (
|
||||
<NodeEditor
|
||||
node={modalState.node}
|
||||
isErrored={modalState.isError}
|
||||
onClose={closeModal}
|
||||
onSave={(n) => {
|
||||
modalState.update(n as any);
|
||||
closeModal();
|
||||
}}
|
||||
allowedTypes={modalState.allowedTypes}
|
||||
saveBtnCreateText={modalState.saveBtnCreateText}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// main render
|
||||
return (
|
||||
<>
|
||||
<Modal open={!!modalState}>{modalBody}</Modal>
|
||||
<ReactFlow
|
||||
className="dag-graphboard"
|
||||
nodeTypes={nodeTypes}
|
||||
snapToGrid
|
||||
onlyRenderVisibleElements
|
||||
nodesConnectable={false}
|
||||
nodesDraggable={false}
|
||||
{...state.data.elements}
|
||||
>
|
||||
<Controls />
|
||||
</ReactFlow>
|
||||
</>
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user