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 fc4fcff  Hiding self filter for project view
     new 4b03c53  Merge pull request #699 from 
shapeblue/hide-self-filter-project
fc4fcff is described below

commit fc4fcff077781da6a5fad5e9f558cd19abc8c079
Author: davidjumani <dj.davidjumani1...@gmail.com>
AuthorDate: Fri Sep 11 10:50:13 2020 +0530

    Hiding self filter for project view
---
 src/config/section/compute.js |  8 +++++++-
 src/views/AutogenView.vue     | 15 ++++++++++++---
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/config/section/compute.js b/src/config/section/compute.js
index 97b6ec0..a283fce 100644
--- a/src/config/section/compute.js
+++ b/src/config/section/compute.js
@@ -30,7 +30,13 @@ export default {
       docHelp: 'adminguide/virtual_machines.html',
       permission: ['listVirtualMachinesMetrics'],
       resourceType: 'UserVm',
-      filters: ['self', 'running', 'stopped'],
+      filters: () => {
+        const filters = ['running', 'stopped']
+        if (!(store.getters.project && store.getters.project.id)) {
+          filters.unshift('self')
+        }
+        return filters
+      },
       columns: () => {
         const fields = ['name', 'state', 'ipaddress']
         const metricsFields = ['cpunumber', 'cpuused', 'cputotal',
diff --git a/src/views/AutogenView.vue b/src/views/AutogenView.vue
index a3e6dae..5e62759 100644
--- a/src/views/AutogenView.vue
+++ b/src/views/AutogenView.vue
@@ -43,16 +43,18 @@
                   {{ $t('label.filterby') }}
                 </template>
                 <a-select
-                  v-if="!dataView && $route.meta.filters && 
$route.meta.filters.length > 0"
+                  v-if="!dataView && filters && filters.length > 0"
                   :placeholder="$t('label.filterby')"
-                  :value="$route.query.filter || (['Admin', 
'DomainAdmin'].includes($store.getters.userInfo.roletype) && ['vm', 'iso', 
'template'].includes($route.name) ? 'all' : 'self')"
+                  :value="$route.query.filter || (projectView && $route.name 
=== 'vm' ||
+                    ['Admin', 
'DomainAdmin'].includes($store.getters.userInfo.roletype) && ['vm', 'iso', 
'template'].includes($route.name)
+                    ? 'all' : 'self')"
                   style="min-width: 100px; margin-left: 10px"
                   @change="changeFilter">
                   <a-icon slot="suffixIcon" type="filter" />
                   <a-select-option v-if="['Admin', 
'DomainAdmin'].includes($store.getters.userInfo.roletype) && ['vm', 'iso', 
'template'].includes($route.name)" key="all">
                     {{ $t('label.all') }}
                   </a-select-option>
-                  <a-select-option v-for="filter in $route.meta.filters" 
:key="filter">
+                  <a-select-option v-for="filter in filters" :key="filter">
                     {{ $t('label.' + filter) }}
                   </a-select-option>
                 </a-select>
@@ -379,6 +381,7 @@ export default {
       currentAction: {},
       showAction: false,
       dataView: false,
+      projectView: false,
       selectedFilter: '',
       filters: [],
       searchFilters: [],
@@ -495,6 +498,12 @@ export default {
       delete params.irefresh
 
       this.searchFilters = this.$route && this.$route.meta && 
this.$route.meta.searchFilters
+      this.filters = this.$route && this.$route.meta && 
this.$route.meta.filters
+      if (typeof this.filters === 'function') {
+        this.filters = this.filters()
+      }
+
+      this.projectView = Boolean(store.getters.project && 
store.getters.project.id)
 
       if (this.$route && this.$route.params && this.$route.params.id) {
         this.dataView = true

Reply via email to