From 34c2975a9fc0c906b59cd2c1998fa544b17f2bd5 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Wed, 17 Jul 2019 12:20:26 +0200 Subject: [PATCH] :zap: Deactivate workflow when saved under a new name --- .../src/components/mixins/workflowHelpers.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/editor-ui/src/components/mixins/workflowHelpers.ts b/packages/editor-ui/src/components/mixins/workflowHelpers.ts index ab563e5a6d..e6454f73f8 100644 --- a/packages/editor-ui/src/components/mixins/workflowHelpers.ts +++ b/packages/editor-ui/src/components/mixins/workflowHelpers.ts @@ -396,12 +396,21 @@ export const workflowHelpers = mixins( if (currentWorkflow === undefined || withNewName === true) { // Workflow is new or is supposed to get saved under a new name - // so create a new etnry in database + // so create a new entry in database workflowData.name = workflowName as string; + + if (withNewName === true) { + // If an existing workflow gets resaved with a new name + // make sure that the new ones is not active + workflowData.active = false; + } + workflowData = await this.restApi().createNewWorkflow(workflowData); - this.$store.commit('setWorkflowName', workflowData.name); + this.$store.commit('setActive', workflowData.active || false); this.$store.commit('setWorkflowId', workflowData.id); + this.$store.commit('setWorkflowName', workflowData.name); + this.$store.commit('setWorkflowSettings', workflowData.settings || {}); } else { // Workflow exists already so update it await this.restApi().updateWorkflow(currentWorkflow, workflowData);