From 1e15f73b0df161f648da64fb1b9cf0229f901ae3 Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> Date: Mon, 10 Jun 2024 13:36:42 +0300 Subject: [PATCH] fix(editor): Remove template creds setup from workflow when copied (no-changelog) (#9673) --- cypress/e2e/34-template-credentials-setup.cy.ts | 3 ++- packages/editor-ui/src/Interface.ts | 2 +- .../editor-ui/src/components/MainHeader/WorkflowDetails.vue | 2 +- packages/editor-ui/src/views/NodeView.vue | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/34-template-credentials-setup.cy.ts b/cypress/e2e/34-template-credentials-setup.cy.ts index 7de435c4fafaa..e112cd926b875 100644 --- a/cypress/e2e/34-template-credentials-setup.cy.ts +++ b/cypress/e2e/34-template-credentials-setup.cy.ts @@ -34,7 +34,7 @@ describe('Template credentials setup', () => { }); cy.intercept('GET', '**/rest/settings', (req) => { // Disable cache - delete req.headers['if-none-match'] + delete req.headers['if-none-match']; req.reply((res) => { if (res.body.data) { // Disable custom templates host if it has been overridden by another intercept @@ -117,6 +117,7 @@ describe('Template credentials setup', () => { const workflow = JSON.parse(workflowJSON); expect(workflow.meta).to.haveOwnProperty('templateId', testTemplate.id.toString()); + expect(workflow.meta).not.to.haveOwnProperty('templateCredsSetupCompleted'); workflow.nodes.forEach((node: any) => { expect(Object.keys(node.credentials ?? {})).to.have.lengthOf(1); }); diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index 6687919ea25d4..a8dc46c158991 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -260,7 +260,7 @@ export interface IWorkflowDataUpdate { } export interface IWorkflowToShare extends IWorkflowDataUpdate { - meta?: WorkflowMetadata; + meta: WorkflowMetadata; } export interface NewWorkflowResponse { diff --git a/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue b/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue index ff9570de18f1a..5abb8b73db205 100644 --- a/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue +++ b/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue @@ -403,7 +403,7 @@ async function onWorkflowMenuSelect(action: WORKFLOW_MENU_ACTIONS): Promise { diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index 63fcd797c15a3..57b10a1156600 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -1997,12 +1997,14 @@ export default defineComponent({ void this.getNodesToSave(nodes).then((data) => { const workflowToCopy: IWorkflowToShare = { meta: { - ...(this.workflowsStore.workflow.meta ?? {}), + ...this.workflowsStore.workflow.meta, instanceId: this.rootStore.instanceId, }, ...data, }; + delete workflowToCopy.meta.templateCredsSetupCompleted; + this.workflowHelpers.removeForeignCredentialsFromWorkflow( workflowToCopy, this.credentialsStore.allCredentials,