From a61650ada27b52e5941de3949f588258d45a526d Mon Sep 17 00:00:00 2001
From: Laila Los <44241786+ElectronicBlueberry@users.noreply.github.com>
Date: Tue, 7 Nov 2023 13:46:43 +0100
Subject: [PATCH] use replace to avoid redundant history entry show save
 progress dialog on first save remove modal which is immediately hidden after
 creation

---
 .../src/components/Workflow/Editor/Index.vue  | 34 +++++++++----------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/client/src/components/Workflow/Editor/Index.vue b/client/src/components/Workflow/Editor/Index.vue
index 937686c544b0..e9fc2b29874b 100644
--- a/client/src/components/Workflow/Editor/Index.vue
+++ b/client/src/components/Workflow/Editor/Index.vue
@@ -519,7 +519,7 @@ export default {
         onDownload() {
             window.location = `${getAppRoot()}api/workflows/${this.id}/download?format=json-download`;
         },
-        doSaveAs(create = false) {
+        async doSaveAs(create = false) {
             const rename_name = this.saveAsName ?? create ? this.name : `SavedAs_${this.name}`;
             const rename_annotation = this.saveAsAnnotation ?? create ? this.annotation : "";
 
@@ -530,23 +530,23 @@ export default {
             formData.append("from_tool_form", true);
             formData.append("workflow_data", JSON.stringify(toSimple(this.id, this)));
 
-            axios
-                .post(`${getAppRoot()}workflow/save_workflow_as`, formData)
-                .then((response) => {
-                    this.onWorkflowMessage("Workflow saved as", "success");
-                    this.hideModal();
-                    this.onNavigate(`${getAppRoot()}workflows/edit?id=${response.data}`);
+            try {
+                const response = await axios.post(`${getAppRoot()}workflow/save_workflow_as`, formData);
+                const newId = response.data;
 
-                    if (create) {
-                        const { addScopePointer } = useScopePointerStore();
-                        // map scoped stores to existing stores, before updating the id
-                        addScopePointer(response.data, this.id);
-                        this.id = response.data;
-                    }
-                })
-                .catch((response) => {
-                    this.onWorkflowError("Saving workflow failed, please contact an administrator.");
-                });
+                if (create) {
+                    const { addScopePointer } = useScopePointerStore();
+                    // map scoped stores to existing stores, before updating the id
+                    addScopePointer(newId, this.id);
+                    this.id = newId;
+                }
+
+                await this.onSave();
+                this.hasChanges = false;
+                this.$router.replace({ query: { id: newId } });
+            } catch (e) {
+                this.onWorkflowError("Saving workflow failed, please contact an administrator.");
+            }
         },
         onSaveAs() {
             this.showSaveAsModal = true;