Open new window when duplicating (#2237)

* update duplicate to open in new window

* remove active action
This commit is contained in:
Mutasem Aldmour 2021-10-07 21:59:00 +02:00 committed by GitHub
parent 857426a918
commit 1341958aae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -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();

View file

@ -491,7 +491,7 @@ export const workflowHelpers = mixins(
}
},
async saveAsNewWorkflow ({name, tags, resetWebhookUrls}: {name?: string, tags?: string[], resetWebhookUrls?: boolean} = {}): Promise<boolean> {
async saveAsNewWorkflow ({name, tags, resetWebhookUrls, openInNewWindow}: {name?: string, tags?: string[], resetWebhookUrls?: boolean, openInNewWindow?: boolean} = {}): Promise<boolean> {
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);