From 1341958aae0e3f2e9e5cc6e8aee2126c39a27a73 Mon Sep 17 00:00:00 2001 From: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> Date: Thu, 7 Oct 2021 21:59:00 +0200 Subject: [PATCH] :zap: Open new window when duplicating (#2237) * update duplicate to open in new window * remove active action --- .../editor-ui/src/components/DuplicateWorkflowDialog.vue | 2 +- .../editor-ui/src/components/mixins/workflowHelpers.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/editor-ui/src/components/DuplicateWorkflowDialog.vue b/packages/editor-ui/src/components/DuplicateWorkflowDialog.vue index 30f718d25f..07d8e7ba22 100644 --- a/packages/editor-ui/src/components/DuplicateWorkflowDialog.vue +++ b/packages/editor-ui/src/components/DuplicateWorkflowDialog.vue @@ -115,7 +115,7 @@ export default mixins(showMessage, workflowHelpers).extend({ this.$data.isSaving = true; - const saved = await this.saveAsNewWorkflow({name, tags: this.currentTagIds, resetWebhookUrls: true}); + const saved = await this.saveAsNewWorkflow({name, tags: this.currentTagIds, resetWebhookUrls: true, openInNewWindow: true}); if (saved) { this.closeDialog(); diff --git a/packages/editor-ui/src/components/mixins/workflowHelpers.ts b/packages/editor-ui/src/components/mixins/workflowHelpers.ts index 907f5bac02..e670e0e330 100644 --- a/packages/editor-ui/src/components/mixins/workflowHelpers.ts +++ b/packages/editor-ui/src/components/mixins/workflowHelpers.ts @@ -491,7 +491,7 @@ export const workflowHelpers = mixins( } }, - async saveAsNewWorkflow ({name, tags, resetWebhookUrls}: {name?: string, tags?: string[], resetWebhookUrls?: boolean} = {}): Promise { + async saveAsNewWorkflow ({name, tags, resetWebhookUrls, openInNewWindow}: {name?: string, tags?: string[], resetWebhookUrls?: boolean, openInNewWindow?: boolean} = {}): Promise { try { this.$store.commit('addActiveAction', 'workflowSaving'); @@ -517,6 +517,12 @@ export const workflowHelpers = mixins( workflowDataRequest.tags = tags; } const workflowData = await this.restApi().createNewWorkflow(workflowDataRequest); + if (openInNewWindow) { + const routeData = this.$router.resolve({name: 'NodeViewExisting', params: {name: workflowData.id}}); + window.open(routeData.href, '_blank'); + this.$store.commit('removeActiveAction', 'workflowSaving'); + return true; + } this.$store.commit('setActive', workflowData.active || false); this.$store.commit('setWorkflowId', workflowData.id);