fix(editor): Remove unknown credentials on pasting workflow (#7582)

https://linear.app/n8n/issue/PAY-881
This commit is contained in:
Iván Ovejero
2023-11-02 17:26:39 +01:00
committed by GitHub
parent 81f43805aa
commit d633753687
3 changed files with 90 additions and 5 deletions

View File

@@ -1677,6 +1677,8 @@ export default defineComponent({
});
}
this.removeUnknownCredentials(workflowData);
const currInstanceId = this.rootStore.instanceId;
const nodeGraph = JSON.stringify(
@@ -1756,6 +1758,23 @@ export default defineComponent({
this.showError(error, this.$locale.baseText('nodeView.showError.importWorkflowData.title'));
}
},
removeUnknownCredentials(workflow: IWorkflowToShare) {
if (!workflow?.nodes) return;
for (const node of workflow.nodes) {
if (!node.credentials) continue;
for (const [name, credential] of Object.entries(node.credentials)) {
if (credential.id === null) continue;
if (!this.credentialsStore.getCredentialById(credential.id)) {
delete node.credentials[name];
}
}
}
},
onDragOver(event: DragEvent) {
event.preventDefault();
},