Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions packages/editor-ui/src/views/canvasHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -777,20 +766,16 @@ 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);

const diffX = DEFAULT_START_POSITION_X - leftmostTop.position[0];
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;
};