Copilot commented on code in PR #12865:
URL: https://github.com/apache/cloudstack/pull/12865#discussion_r2964649322


##########
ui/src/config/section/offering.js:
##########
@@ -32,14 +32,18 @@ export default {
       permission: ['listServiceOfferings'],
       searchFilters: ['name', 'gpuenabled', 'zoneid', 'domainid', 'cpunumber', 
'cpuspeed', 'memory'],
       params: () => {
-        var params = {}
         if (['Admin', 
'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
-          params = { isrecursive: 'true' }
+          return { isrecursive: 'true' }
         }
-        return params
+        return { state: 'Active' }
       },
-      filters: ['active', 'inactive'],
-      columns: ['name', 'displaytext', 'state', 'cpunumber', 'cpuspeed', 
'memory', 'gpu', 'domain', 'zone', 'order'],
+      filters: () => {
+        if (['Admin', 
'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
+          return ['active', 'inactive']
+        }
+        return []
+      },
+      columns: ['name', 'displaytext', 'state', 'cpunumber', 'cpuspeed', 
'memory', 'domain', 'zone', 'order'],

Review Comment:
   The `gpu` column was removed from the compute offering list columns. This 
looks unrelated to the PR goal (hiding inactive offerings) and will stop 
displaying GPU card/profile info even though `ListView` has a dedicated 
renderer for the `gpu` column and the section still supports GPU-related 
fields. If this wasn’t intentional, keep the `gpu` column (or make it 
conditional based on whether GPU fields are present).



##########
ui/src/config/section/offering.js:
##########
@@ -32,14 +32,18 @@ export default {
       permission: ['listServiceOfferings'],
       searchFilters: ['name', 'gpuenabled', 'zoneid', 'domainid', 'cpunumber', 
'cpuspeed', 'memory'],
       params: () => {
-        var params = {}
         if (['Admin', 
'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
-          params = { isrecursive: 'true' }
+          return { isrecursive: 'true' }
         }
-        return params
+        return { state: 'Active' }
       },
-      filters: ['active', 'inactive'],
-      columns: ['name', 'displaytext', 'state', 'cpunumber', 'cpuspeed', 
'memory', 'gpu', 'domain', 'zone', 'order'],
+      filters: () => {
+        if (['Admin', 
'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
+          return ['active', 'inactive']
+        }
+        return []
+      },

Review Comment:
   `params` sets `{ state: 'Active' }` for non-admin users, but in 
`AutogenView.fetchData` the route query is merged *after* meta params; a user 
can still append `?state=Inactive` in the URL and override this to list 
inactive offerings. To actually prevent listing inactive offerings for `User` 
role, enforce the state after query merge (e.g., add a `customParamHandler` for 
`computeoffering` that overwrites/removes `params.state` unless the role is 
Admin/DomainAdmin).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to