fix(editor): Prevent creation of input connections for nodes without input slot (#5425)

* fix(editor): Prevent creation of input connections for nodes without input

* WIP: Workflow checks service and controller

* fix: Created SQLite migration to remove broken connections

* Cleanup & add mysql/posgres migrations

* Linter fixes

* Unify the migration scripts

* Escape migration workflow_entity

* Wrap the migration in try/catch and do not parse nodes and connection if mysql/postgres

* Do migration changes also fro mysql

* refactor: Wrap only the necessary call in try catch block

---------

Co-authored-by: Omar Ajoue <krynble@gmail.com>
This commit is contained in:
OlegIvaniv
2023-02-09 16:04:26 +01:00
committed by GitHub
parent d9a4c2c66d
commit 018f8a3510
8 changed files with 301 additions and 26 deletions

View File

@@ -1995,7 +1995,7 @@ export default mixins(
},
] as [IConnection, IConnection];
this.__addConnection(connectionData, true);
this.__addConnection(connectionData);
},
async addNode(
nodeTypeName: string,
@@ -2571,22 +2571,19 @@ export default mixins(
return NodeViewUtils.getInputEndpointUUID(node.id, index);
},
__addConnection(connection: [IConnection, IConnection], addVisualConnection = false) {
if (addVisualConnection) {
const outputUuid = this.getOutputEndpointUUID(connection[0].node, connection[0].index);
const inputUuid = this.getInputEndpointUUID(connection[1].node, connection[1].index);
if (!outputUuid || !inputUuid) {
return;
}
const uuid: [string, string] = [outputUuid, inputUuid];
// Create connections in DOM
this.instance?.connect({
uuids: uuid,
detachable: !this.isReadOnly,
});
__addConnection(connection: [IConnection, IConnection]) {
const outputUuid = this.getOutputEndpointUUID(connection[0].node, connection[0].index);
const inputUuid = this.getInputEndpointUUID(connection[1].node, connection[1].index);
if (!outputUuid || !inputUuid) {
return;
}
this.workflowsStore.addConnection({ connection });
const uuid: [string, string] = [outputUuid, inputUuid];
// Create connections in DOM
this.instance?.connect({
uuids: uuid,
detachable: !this.isReadOnly,
});
setTimeout(() => {
this.addPinDataConnections(this.workflowsStore.pinData);
@@ -3277,7 +3274,7 @@ export default mixins(
},
] as [IConnection, IConnection];
this.__addConnection(connectionData, true);
this.__addConnection(connectionData);
});
}
}
@@ -3763,7 +3760,7 @@ export default mixins(
},
async onRevertRemoveConnection({ connection }: { connection: [IConnection, IConnection] }) {
this.suspendRecordingDetachedConnections = true;
this.__addConnection(connection, true);
this.__addConnection(connection);
this.suspendRecordingDetachedConnections = false;
},
async onRevertNameChange({ currentName, newName }: { currentName: string; newName: string }) {