refactor: fix spelling and wording errors
This commit is contained in:
@@ -12,7 +12,7 @@ export default function Edge({
|
|||||||
targetX,
|
targetX,
|
||||||
targetY,
|
targetY,
|
||||||
source,
|
source,
|
||||||
data: { layouted },
|
data: { laidOut },
|
||||||
}) {
|
}) {
|
||||||
const { stepCreationInProgress, flowActive, onAddStep } =
|
const { stepCreationInProgress, flowActive, onAddStep } =
|
||||||
useContext(EdgesContext);
|
useContext(EdgesContext);
|
||||||
@@ -34,7 +34,7 @@ export default function Edge({
|
|||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
transform: `translate(-50%, -50%) translate(${labelX}px,${labelY}px)`,
|
transform: `translate(-50%, -50%) translate(${labelX}px,${labelY}px)`,
|
||||||
pointerEvents: 'all',
|
pointerEvents: 'all',
|
||||||
visibility: layouted ? 'visible' : 'hidden',
|
visibility: laidOut ? 'visible' : 'hidden',
|
||||||
}}
|
}}
|
||||||
disabled={stepCreationInProgress || flowActive}
|
disabled={stepCreationInProgress || flowActive}
|
||||||
>
|
>
|
||||||
@@ -52,6 +52,6 @@ Edge.propTypes = {
|
|||||||
targetY: PropTypes.number.isRequired,
|
targetY: PropTypes.number.isRequired,
|
||||||
source: PropTypes.string.isRequired,
|
source: PropTypes.string.isRequired,
|
||||||
data: PropTypes.shape({
|
data: PropTypes.shape({
|
||||||
layouted: PropTypes.bool,
|
laidOut: PropTypes.bool,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
};
|
};
|
||||||
|
@@ -8,7 +8,7 @@ import { UPDATE_STEP } from 'graphql/mutations/update-step';
|
|||||||
import { CREATE_STEP } from 'graphql/mutations/create-step';
|
import { CREATE_STEP } from 'graphql/mutations/create-step';
|
||||||
|
|
||||||
import { useAutoLayout } from './useAutoLayout';
|
import { useAutoLayout } from './useAutoLayout';
|
||||||
import { useScrollBoundries } from './useScrollBoundries';
|
import { useScrollBoundaries } from './useScrollBoundaries';
|
||||||
import FlowStepNode from './FlowStepNode/FlowStepNode';
|
import FlowStepNode from './FlowStepNode/FlowStepNode';
|
||||||
import Edge from './Edge/Edge';
|
import Edge from './Edge/Edge';
|
||||||
import InvisibleNode from './InvisibleNode/InvisibleNode';
|
import InvisibleNode from './InvisibleNode/InvisibleNode';
|
||||||
@@ -47,7 +47,7 @@ const EditorNew = ({ flow }) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
useAutoLayout();
|
useAutoLayout();
|
||||||
useScrollBoundries();
|
useScrollBoundaries();
|
||||||
|
|
||||||
const createdStepIdRef = useRef(null);
|
const createdStepIdRef = useRef(null);
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ const EditorNew = ({ flow }) => {
|
|||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
data: {
|
data: {
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
layouted: false,
|
laidOut: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -192,7 +192,7 @@ const EditorNew = ({ flow }) => {
|
|||||||
target: targetId,
|
target: targetId,
|
||||||
type: 'addNodeEdge',
|
type: 'addNodeEdge',
|
||||||
data: {
|
data: {
|
||||||
layouted: edge ? edge?.data.layouted : false,
|
laidOut: edge ? edge?.data.laidOut : false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -212,10 +212,10 @@ const EditorNew = ({ flow }) => {
|
|||||||
target: INVISIBLE_NODE_ID,
|
target: INVISIBLE_NODE_ID,
|
||||||
type: 'addNodeEdge',
|
type: 'addNodeEdge',
|
||||||
data: {
|
data: {
|
||||||
layouted:
|
laidOut:
|
||||||
lastEdge?.id ===
|
lastEdge?.id ===
|
||||||
generateEdgeId(lastStep.id, INVISIBLE_NODE_ID)
|
generateEdgeId(lastStep.id, INVISIBLE_NODE_ID)
|
||||||
? lastEdge?.data.layouted
|
? lastEdge?.data.laidOut
|
||||||
: false,
|
: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@@ -7,15 +7,9 @@ import { NodeWrapper, NodeInnerWrapper } from './style.js';
|
|||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import { NodesContext } from '../EditorNew.jsx';
|
import { NodesContext } from '../EditorNew.jsx';
|
||||||
|
|
||||||
function FlowStepNode({ data: { collapsed, layouted }, id }) {
|
function FlowStepNode({ data: { collapsed, laidOut }, id }) {
|
||||||
const {
|
const { openNextStep, onStepOpen, onStepClose, onStepChange, flowId, steps } =
|
||||||
openNextStep,
|
useContext(NodesContext);
|
||||||
onStepOpen,
|
|
||||||
onStepClose,
|
|
||||||
onStepChange,
|
|
||||||
flowId,
|
|
||||||
steps,
|
|
||||||
} = useContext(NodesContext);
|
|
||||||
|
|
||||||
const step = steps.find(({ id: stepId }) => stepId === id);
|
const step = steps.find(({ id: stepId }) => stepId === id);
|
||||||
|
|
||||||
@@ -23,7 +17,7 @@ function FlowStepNode({ data: { collapsed, layouted }, id }) {
|
|||||||
<NodeWrapper
|
<NodeWrapper
|
||||||
className="nodrag"
|
className="nodrag"
|
||||||
sx={{
|
sx={{
|
||||||
visibility: layouted ? 'visible' : 'hidden',
|
visibility: laidOut ? 'visible' : 'hidden',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<NodeInnerWrapper>
|
<NodeInnerWrapper>
|
||||||
@@ -59,7 +53,7 @@ FlowStepNode.propTypes = {
|
|||||||
id: PropTypes.string,
|
id: PropTypes.string,
|
||||||
data: PropTypes.shape({
|
data: PropTypes.shape({
|
||||||
collapsed: PropTypes.bool.isRequired,
|
collapsed: PropTypes.bool.isRequired,
|
||||||
layouted: PropTypes.bool.isRequired,
|
laidOut: PropTypes.bool.isRequired,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@ import { usePrevious } from 'hooks/usePrevious';
|
|||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
import { useNodesInitialized, useNodes, useReactFlow } from 'reactflow';
|
import { useNodesInitialized, useNodes, useReactFlow } from 'reactflow';
|
||||||
|
|
||||||
const getLayoutedElements = (nodes, edges) => {
|
const getLaidOutElements = (nodes, edges) => {
|
||||||
const graph = new Dagre.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
|
const graph = new Dagre.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
|
||||||
graph.setGraph({
|
graph.setGraph({
|
||||||
rankdir: 'TB',
|
rankdir: 'TB',
|
||||||
@@ -36,18 +36,18 @@ export const useAutoLayout = () => {
|
|||||||
|
|
||||||
const onLayout = useCallback(
|
const onLayout = useCallback(
|
||||||
(nodes, edges) => {
|
(nodes, edges) => {
|
||||||
const layoutedElements = getLayoutedElements(nodes, edges);
|
const laidOutElements = getLaidOutElements(nodes, edges);
|
||||||
|
|
||||||
setNodes([
|
setNodes([
|
||||||
...layoutedElements.nodes.map((node) => ({
|
...laidOutElements.nodes.map((node) => ({
|
||||||
...node,
|
...node,
|
||||||
data: { ...node.data, layouted: true },
|
data: { ...node.data, laidOut: true },
|
||||||
})),
|
})),
|
||||||
]);
|
]);
|
||||||
setEdges([
|
setEdges([
|
||||||
...layoutedElements.edges.map((edge) => ({
|
...laidOutElements.edges.map((edge) => ({
|
||||||
...edge,
|
...edge,
|
||||||
data: { ...edge.data, layouted: true },
|
data: { ...edge.data, laidOut: true },
|
||||||
})),
|
})),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useViewport, useReactFlow } from 'reactflow';
|
import { useViewport, useReactFlow } from 'reactflow';
|
||||||
|
|
||||||
export const useScrollBoundries = () => {
|
export const useScrollBoundaries = () => {
|
||||||
const { setViewport } = useReactFlow();
|
const { setViewport } = useReactFlow();
|
||||||
const { x, y, zoom } = useViewport();
|
const { x, y, zoom } = useViewport();
|
||||||
|
|
@@ -31,7 +31,7 @@ export const generateInitialNodes = (flow) => {
|
|||||||
zIndex: collapsed ? 0 : 1,
|
zIndex: collapsed ? 0 : 1,
|
||||||
data: {
|
data: {
|
||||||
collapsed,
|
collapsed,
|
||||||
layouted: false,
|
laidOut: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -61,7 +61,7 @@ export const generateInitialEdges = (flow) => {
|
|||||||
target: targetId,
|
target: targetId,
|
||||||
type: 'addNodeEdge',
|
type: 'addNodeEdge',
|
||||||
data: {
|
data: {
|
||||||
layouted: false,
|
laidOut: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ export const generateInitialEdges = (flow) => {
|
|||||||
target: INVISIBLE_NODE_ID,
|
target: INVISIBLE_NODE_ID,
|
||||||
type: 'addNodeEdge',
|
type: 'addNodeEdge',
|
||||||
data: {
|
data: {
|
||||||
layouted: false,
|
laidOut: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user