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

rohit 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 73f82ae  ui: Save the tab and re-activate it after submitting the 
form. (#4962)
73f82ae is described below

commit 73f82ae9dd1803df4500db78ccf5d658b53bfe62
Author: Hoang Nguyen <[email protected]>
AuthorDate: Wed Apr 28 13:45:42 2021 +0700

    ui: Save the tab and re-activate it after submitting the form. (#4962)
    
    * save the tab and reactivate it after submitting the form.
    
    * fix for quota resource
    
    Fixes #4961
---
 ui/src/components/view/ResourceView.vue             | 20 +++++++++++++++++++-
 ui/src/views/network/PublicIpResource.vue           |  7 +++++--
 ui/src/views/plugins/quota/QuotaSummaryResource.vue |  7 +++++--
 3 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/ui/src/components/view/ResourceView.vue 
b/ui/src/components/view/ResourceView.vue
index 333f582..013310f 100644
--- a/ui/src/components/view/ResourceView.vue
+++ b/ui/src/components/view/ResourceView.vue
@@ -83,6 +83,10 @@ export default {
           component: DetailsTab
         }]
       }
+    },
+    historyTab: {
+      type: String,
+      default: ''
     }
   },
   data () {
@@ -128,6 +132,7 @@ export default {
           )
         }).join('&')
       )
+      this.$emit('onTabChange', key)
     },
     showTab (tab) {
       if ('networkServiceFilter' in tab) {
@@ -158,7 +163,20 @@ export default {
       }
     },
     setActiveTab () {
-      this.activeTab = this.$route.query.tab ? this.$route.query.tab : 
this.tabs[0].name
+      if (this.$route.query.tab) {
+        this.activeTab = this.$route.query.tab
+        return
+      }
+      if (!this.historyTab || !this.$route.meta.tabs || 
this.$route.meta.tabs.length === 0) {
+        this.activeTab = this.tabs[0].name
+        return
+      }
+      const tabIdx = this.$route.meta.tabs.findIndex(tab => tab.name === 
this.historyTab)
+      if (tabIdx === -1) {
+        this.activeTab = this.tabs[0].name
+      } else {
+        this.activeTab = this.historyTab
+      }
     }
   }
 }
diff --git a/ui/src/views/network/PublicIpResource.vue 
b/ui/src/views/network/PublicIpResource.vue
index 2c97f93..e80ed17 100644
--- a/ui/src/views/network/PublicIpResource.vue
+++ b/ui/src/views/network/PublicIpResource.vue
@@ -33,7 +33,9 @@
           v-if="isPublicIpAddress && 'id' in resource"
           :loading="loading"
           :resource="resource"
-          :tabs="tabs" />
+          :historyTab="activeTab"
+          :tabs="tabs"
+          @onTabChange="(tab) => { this.activeTab = tab }" />
       </div>
     </autogen-view>
   </div>
@@ -63,7 +65,8 @@ export default {
       tabs: [{
         name: 'details',
         component: () => import('@/components/view/DetailsTab.vue')
-      }]
+      }],
+      activeTab: ''
     }
   },
   mixins: [mixinDevice],
diff --git a/ui/src/views/plugins/quota/QuotaSummaryResource.vue 
b/ui/src/views/plugins/quota/QuotaSummaryResource.vue
index 381f94e..abc6e2d 100644
--- a/ui/src/views/plugins/quota/QuotaSummaryResource.vue
+++ b/ui/src/views/plugins/quota/QuotaSummaryResource.vue
@@ -19,7 +19,9 @@
   <resource-view
     :loading="loading"
     :resource="quotaResource"
-    :tabs="tabs"/>
+    :tabs="tabs"
+    :historyTab="activeTab"
+    @onTabChange="(tab) => { this.activeTab = tab }"/>
 </template>
 
 <script>
@@ -48,7 +50,8 @@ export default {
       loading: false,
       quotaResource: {},
       networkService: null,
-      pattern: 'YYYY-MM-DD'
+      pattern: 'YYYY-MM-DD',
+      activeTab: ''
     }
   },
   created () {

Reply via email to