mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
prevent duplicate connections
This commit is contained in:
parent
3eb38c8178
commit
f6ad3c4c08
|
@ -1451,12 +1451,37 @@ export default mixins(
|
||||||
this.openNodeCreator(info.eventSource);
|
this.openNodeCreator(info.eventSource);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let dropPrevented = false;
|
||||||
|
|
||||||
this.instance.bind('connectionAborted', (info) => insertNodeAfterSelected({
|
this.instance.bind('connectionAborted', (info) => {
|
||||||
|
if (dropPrevented) {
|
||||||
|
dropPrevented = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
insertNodeAfterSelected({
|
||||||
sourceId: info.sourceId,
|
sourceId: info.sourceId,
|
||||||
index: info.getParameters().index,
|
index: info.getParameters().index,
|
||||||
eventSource: 'node_connection_drop',
|
eventSource: 'node_connection_drop',
|
||||||
}));
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
this.instance.bind('beforeDrop', (info) => {
|
||||||
|
const sourceInfo = info.connection.endpoints[0].getParameters();
|
||||||
|
// @ts-ignore
|
||||||
|
const targetInfo = info.dropEndpoint.getParameters();
|
||||||
|
|
||||||
|
const sourceNodeName = this.$store.getters.getNodeNameByIndex(sourceInfo.nodeIndex);
|
||||||
|
const targetNodeName = this.$store.getters.getNodeNameByIndex(targetInfo.nodeIndex);
|
||||||
|
|
||||||
|
// check for duplicates
|
||||||
|
if (this.getJSPlumbConnection(sourceNodeName, sourceInfo.index, targetNodeName, targetInfo.index)) {
|
||||||
|
dropPrevented = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
// only one set of visible actions should be visible at the same time
|
// only one set of visible actions should be visible at the same time
|
||||||
let activeConnection: null | Connection = null;
|
let activeConnection: null | Connection = null;
|
||||||
|
@ -1480,9 +1505,7 @@ export default mixins(
|
||||||
};
|
};
|
||||||
|
|
||||||
this.instance.bind('connection', (info: OnConnectionBindInfo) => {
|
this.instance.bind('connection', (info: OnConnectionBindInfo) => {
|
||||||
// @ts-ignore
|
|
||||||
const sourceInfo = info.sourceEndpoint.getParameters();
|
const sourceInfo = info.sourceEndpoint.getParameters();
|
||||||
// @ts-ignore
|
|
||||||
const targetInfo = info.targetEndpoint.getParameters();
|
const targetInfo = info.targetEndpoint.getParameters();
|
||||||
|
|
||||||
const sourceNodeName = this.$store.getters.getNodeNameByIndex(sourceInfo.nodeIndex);
|
const sourceNodeName = this.$store.getters.getNodeNameByIndex(sourceInfo.nodeIndex);
|
||||||
|
|
Loading…
Reference in a new issue