fix(editor): Prevent adding of the start node when importing workflow in the demo mode (#4564)

This commit is contained in:
OlegIvaniv 2022-11-09 18:36:06 +01:00 committed by GitHub
parent 736777385c
commit 49748f27a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -42,17 +42,6 @@ export const INPUT_UUID_KEY = '-input';
export const OUTPUT_UUID_KEY = '-output';
export const PLACEHOLDER_BUTTON = 'PlaceholderTriggerButton';
export const DEFAULT_START_NODE = {
name: 'Start',
type: START_NODE_TYPE,
typeVersion: 1,
position: [
DEFAULT_START_POSITION_X,
DEFAULT_START_POSITION_Y,
] as XYPosition,
parameters: {},
};
export const DEFAULT_PLACEHOLDER_TRIGGER_BUTTON = {
name: 'Choose a Trigger...',
type: PLACEHOLDER_BUTTON,
@ -777,7 +766,6 @@ export const getInputEndpointUUID = (nodeId: string, inputIndex: number) => {
export const getFixedNodesList = (workflowNodes: INode[]) => {
const nodes = [...workflowNodes];
const hasStartNode = !!nodes.find(node => node.type === START_NODE_TYPE);
const leftmostTop = getLeftmostTopNode(nodes);
@ -785,12 +773,9 @@ export const getFixedNodesList = (workflowNodes: INode[]) => {
const diffY = DEFAULT_START_POSITION_Y - leftmostTop.position[1];
nodes.map((node) => {
node.position[0] += diffX + (hasStartNode? 0 : NODE_SIZE * 2);
node.position[0] += diffX + (NODE_SIZE * 2);
node.position[1] += diffY;
});
if (!hasStartNode) {
nodes.push({...DEFAULT_START_NODE, id: uuid() });
}
return nodes;
};