You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2021/08/27 08:18:45 UTC

[cloudstack] branch 4.15 updated: ui: Go back for delete actions before querying async job (#5360)

This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch 4.15
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.15 by this push:
     new b3dca8c  ui: Go back for delete actions before querying async job (#5360)
b3dca8c is described below

commit b3dca8ca27ea1ad6f1e15b70c4bd4143eddd709c
Author: davidjumani <dj...@gmail.com>
AuthorDate: Fri Aug 27 13:48:17 2021 +0530

    ui: Go back for delete actions before querying async job (#5360)
    
    * ui: Go back for delete actions before querying async job
    
    * Prevent redirecting if failed
---
 ui/src/utils/plugins.js      | 10 +++++++---
 ui/src/views/AutogenView.vue |  8 +++++++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/ui/src/utils/plugins.js b/ui/src/utils/plugins.js
index 3c512d2..1f621be 100644
--- a/ui/src/utils/plugins.js
+++ b/ui/src/utils/plugins.js
@@ -91,7 +91,7 @@ export const pollJobPlugin = {
           const currentPage = this.$router.currentRoute.path
           const samePage = options.originalPage === currentPage || options.originalPage.startsWith(currentPage + '/')
           if (samePage && (!action || !('isFetchData' in action) || (action.isFetchData))) {
-            eventBus.$emit('async-job-complete')
+            eventBus.$emit('async-job-complete', action)
           }
           successMethod(result)
         } else if (result.jobstatus === 2) {
@@ -121,8 +121,12 @@ export const pollJobPlugin = {
             status: 'failed',
             duration: 0
           })
-          if (!action || !('isFetchData' in action) || (action.isFetchData)) {
-            eventBus.$emit('async-job-complete')
+
+          // Ensure we refresh on the same / parent page
+          const currentPage = this.$router.currentRoute.path
+          const samePage = options.originalPage === currentPage || options.originalPage.startsWith(currentPage + '/')
+          if (samePage && (!action || !('isFetchData' in action) || (action.isFetchData))) {
+            eventBus.$emit('async-job-complete', action)
           }
           errorMethod(result)
         } else if (result.jobstatus === 0) {
diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue
index f691cf9..0ad9568 100644
--- a/ui/src/views/AutogenView.vue
+++ b/ui/src/views/AutogenView.vue
@@ -862,6 +862,9 @@ export default {
       })
     },
     pollActionCompletion (jobId, action, resourceName, showLoading = true) {
+      if (this.shouldNavigateBack(action)) {
+        action.isFetchData = false
+      }
       return new Promise((resolve) => {
         this.$pollJob({
           jobId,
@@ -1062,7 +1065,7 @@ export default {
         api(...args).then(json => {
           this.handleResponse(json, resourceName, action).then(jobId => {
             hasJobId = jobId
-            if ((action.icon === 'delete' || ['archiveEvents', 'archiveAlerts', 'unmanageVirtualMachine'].includes(action.api)) && this.dataView) {
+            if (this.shouldNavigateBack(action)) {
               this.$router.go(-1)
             } else {
               if (!hasJobId) {
@@ -1083,6 +1086,9 @@ export default {
         })
       })
     },
+    shouldNavigateBack (action) {
+      return ((action.icon === 'delete' || ['archiveEvents', 'archiveAlerts', 'unmanageVirtualMachine'].includes(action.api)) && this.dataView)
+    },
     changeFilter (filter) {
       const query = Object.assign({}, this.$route.query)
       delete query.templatefilter