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

andrijapanic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack-primate.git


The following commit(s) were added to refs/heads/master by this push:
     new aa81baa  Fixing currentAction null while processing the response
     new 2add8d8  Merge pull request #707 from shapeblue/fix-groupaction
aa81baa is described below

commit aa81baa509289f03605275d3871650e25dd46725
Author: davidjumani <[email protected]>
AuthorDate: Mon Sep 14 11:41:44 2020 +0530

    Fixing currentAction null while processing the response
---
 src/config/section/event.js       |   2 +
 src/config/section/infra/zones.js |   2 +-
 src/locales/en.json               |   4 +-
 src/views/AutogenView.vue         | 136 ++++++++++++++++++++------------------
 4 files changed, 75 insertions(+), 69 deletions(-)

diff --git a/src/config/section/event.js b/src/config/section/event.js
index 1411fb0..9dab696 100644
--- a/src/config/section/event.js
+++ b/src/config/section/event.js
@@ -37,6 +37,7 @@ export default {
       message: 'message.confirm.archive.selected.events',
       docHelp: 
'adminguide/events.html#deleting-and-archiving-events-and-alerts',
       dataView: true,
+      successMessage: 'label.event.archived',
       groupAction: true,
       groupMap: (selection) => { return [{ ids: selection.join(',') }] },
       args: ['ids'],
@@ -55,6 +56,7 @@ export default {
       message: 'message.confirm.remove.selected.events',
       docHelp: 
'adminguide/events.html#deleting-and-archiving-events-and-alerts',
       dataView: true,
+      successMessage: 'label.event.deleted',
       groupAction: true,
       groupMap: (selection) => { return [{ ids: selection.join(',') }] },
       args: ['ids'],
diff --git a/src/config/section/infra/zones.js 
b/src/config/section/infra/zones.js
index 44e24e7..7254155 100644
--- a/src/config/section/infra/zones.js
+++ b/src/config/section/infra/zones.js
@@ -201,7 +201,7 @@ export default {
       icon: 'block',
       label: 'label.update.vmware.datacenter',
       message: 'message.restart.mgmt.server',
-      successMessage: 'message.restart.mgmt.server',
+      additionalMessage: 'message.restart.mgmt.server',
       dataView: true,
       show: record => record.vmwaredc,
       args: ['zoneid', 'name', 'vcenter', 'username', 'password'],
diff --git a/src/locales/en.json b/src/locales/en.json
index b926f20..b7af2d0 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -863,8 +863,8 @@
 "label.esplifetime": "ESP Lifetime (second)",
 "label.esppolicy": "ESP policy",
 "label.event": "Event",
-"label.event.archived": "Event Archived",
-"label.event.deleted": "Event Deleted",
+"label.event.archived": "Event(s) Archived",
+"label.event.deleted": "Event(s) Deleted",
 "label.event.timeline": "Event Timeline",
 "label.events": "Events",
 "label.every": "Every",
diff --git a/src/views/AutogenView.vue b/src/views/AutogenView.vue
index 5e62759..75a23d2 100644
--- a/src/views/AutogenView.vue
+++ b/src/views/AutogenView.vue
@@ -876,30 +876,32 @@ export default {
       }
     },
     callGroupApi (params, resourceName) {
-      api(this.currentAction.api, params).then(json => {
-        this.handleResponse(json, resourceName, false)
+      const action = this.currentAction
+      api(action.api, params).then(json => {
+        this.handleResponse(json, resourceName, action, false)
       }).catch(error => {
         this.$notifyError(error)
       })
     },
-    handleResponse (response, resourceName, showLoading = true) {
+    handleResponse (response, resourceName, action, showLoading = true) {
       for (const obj in response) {
         if (obj.includes('response')) {
           if (response[obj].jobid) {
             const jobid = response[obj].jobid
-            this.$store.dispatch('AddAsyncJob', { title: 
this.$t(this.currentAction.label), jobid: jobid, description: resourceName, 
status: 'progress' })
-            this.pollActionCompletion(jobid, this.currentAction, resourceName, 
showLoading)
+            this.$store.dispatch('AddAsyncJob', { title: 
this.$t(action.label), jobid: jobid, description: resourceName, status: 
'progress' })
+            this.pollActionCompletion(jobid, action, resourceName, showLoading)
             return true
           } else {
-            var message = this.$t(this.currentAction.label) + (resourceName ? 
' - ' + resourceName : '')
+            var message = action.successMessage ? 
this.$t(action.successMessage) : this.$t(action.label) +
+              (resourceName ? ' - ' + resourceName : '')
             var duration = 2
-            if (this.currentAction.successMessage) {
-              message = message + ' - ' + 
this.$t(this.currentAction.successMessage)
+            if (action.additionalMessage) {
+              message = message + ' - ' + this.$t(action.successMessage)
               duration = 5
             }
             this.$message.success({
               content: message,
-              key: this.currentAction.label + resourceName,
+              key: action.label + resourceName,
               duration: duration
             })
           }
@@ -911,76 +913,78 @@ export default {
     execSubmit (e) {
       e.preventDefault()
       this.form.validateFields((err, values) => {
-        if (!err) {
-          const params = {}
-          if ('id' in this.resource && this.currentAction.params.map(i => { 
return i.name }).includes('id')) {
-            params.id = this.resource.id
-          }
-          for (const key in values) {
-            const input = values[key]
-            for (const param of this.currentAction.params) {
-              if (param.name !== key) {
-                continue
-              }
-              if (input === undefined || input === null || input === '') {
-                if (param.type === 'boolean') {
-                  params[key] = false
-                }
-                break
+        if (err) {
+          return
+        }
+        const params = {}
+        const action = this.currentAction
+        if ('id' in this.resource && action.params.map(i => { return i.name 
}).includes('id')) {
+          params.id = this.resource.id
+        }
+        for (const key in values) {
+          const input = values[key]
+          for (const param of action.params) {
+            if (param.name !== key) {
+              continue
+            }
+            if (input === undefined || input === null || input === '') {
+              if (param.type === 'boolean') {
+                params[key] = false
               }
-              if (this.currentAction.mapping && key in 
this.currentAction.mapping && this.currentAction.mapping[key].options) {
-                params[key] = this.currentAction.mapping[key].options[input]
-              } else if (param.type === 'list') {
-                params[key] = input.map(e => { return param.opts[e].id 
}).reduce((str, name) => { return str + ',' + name })
-              } else if (param.name === 'account' || param.name === 'keypair') 
{
-                if (['addAccountToProject', 
'createAccount'].includes(this.currentAction.api)) {
-                  params[key] = input
-                } else {
-                  params[key] = param.opts[input].name
-                }
-              } else {
+              break
+            }
+            if (action.mapping && key in action.mapping && 
action.mapping[key].options) {
+              params[key] = action.mapping[key].options[input]
+            } else if (param.type === 'list') {
+              params[key] = input.map(e => { return param.opts[e].id 
}).reduce((str, name) => { return str + ',' + name })
+            } else if (param.name === 'account' || param.name === 'keypair') {
+              if (['addAccountToProject', 
'createAccount'].includes(action.api)) {
                 params[key] = input
+              } else {
+                params[key] = param.opts[input].name
               }
-              break
+            } else {
+              params[key] = input
             }
+            break
           }
+        }
 
-          for (const key in this.currentAction.defaultArgs) {
-            if (!params[key]) {
-              params[key] = this.currentAction.defaultArgs[key]
-            }
+        for (const key in action.defaultArgs) {
+          if (!params[key]) {
+            params[key] = action.defaultArgs[key]
           }
+        }
 
-          if (this.currentAction.mapping) {
-            for (const key in this.currentAction.mapping) {
-              if (!this.currentAction.mapping[key].value) {
-                continue
-              }
-              params[key] = 
this.currentAction.mapping[key].value(this.resource, params)
+        if (action.mapping) {
+          for (const key in action.mapping) {
+            if (!action.mapping[key].value) {
+              continue
             }
+            params[key] = action.mapping[key].value(this.resource, params)
           }
+        }
 
-          const resourceName = params.displayname || params.displaytext || 
params.name || params.hostname || params.username || params.ipaddress || 
params.virtualmachinename || this.resource.name
+        const resourceName = params.displayname || params.displaytext || 
params.name || params.hostname || params.username || params.ipaddress || 
params.virtualmachinename || this.resource.name
 
-          var hasJobId = false
-          this.actionLoading = true
-          api(this.currentAction.api, params).then(json => {
-            hasJobId = this.handleResponse(json, resourceName)
-            if ((this.currentAction.icon === 'delete' || ['archiveEvents', 
'archiveAlerts'].includes(this.currentAction.api)) && this.dataView) {
-              this.$router.go(-1)
-            } else {
-              if (!hasJobId) {
-                this.fetchData()
-              }
+        var hasJobId = false
+        this.actionLoading = true
+        api(action.api, params).then(json => {
+          hasJobId = this.handleResponse(json, resourceName, action)
+          if ((action.icon === 'delete' || ['archiveEvents', 
'archiveAlerts'].includes(action.api)) && this.dataView) {
+            this.$router.go(-1)
+          } else {
+            if (!hasJobId) {
+              this.fetchData()
             }
-          }).catch(error => {
-            console.log(error)
-            this.$notifyError(error)
-          }).finally(f => {
-            this.actionLoading = false
-            this.closeAction()
-          })
-        }
+          }
+        }).catch(error => {
+          console.log(error)
+          this.$notifyError(error)
+        }).finally(f => {
+          this.actionLoading = false
+          this.closeAction()
+        })
       })
     },
     changeFilter (filter) {

Reply via email to