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


##########
ui/src/views/setting/ConfigurationValue.vue:
##########
@@ -190,10 +190,41 @@
           :disabled="(!('resetConfiguration' in $store.getters.apis) || 
configDisabled || valueLoading || configrecord.value === 
configrecord.defaultvalue)" />
       </span>
     </a-list-item>
+    <a-modal
+      v-if="!suppressRelatedPrompt"
+      v-model:visible="relatedModalVisible"
+      :title="$t('label.related.settings')"
+      :footer="null"
+      :maskClosable="false"
+      :width="'60vw'"
+      @cancel="closeRelatedModal">

Review Comment:
   The related-settings modal is rendered for every ConfigurationValue instance 
whenever `suppressRelatedPrompt` is false, even when it is not visible. In the 
global settings list this can create many hidden modal/table instances 
(including nested ConfigurationValue components), which is unnecessary work and 
can hurt UI performance. Render the modal only when it is actually visible and 
destroy its contents on close.



##########
ui/src/views/setting/ConfigurationValue.vue:
##########
@@ -319,6 +375,66 @@ export default {
         this.$emit('refresh', configrecord.name, configRecordEntry)
       })
     },
+    isConfigNowActive (configrecord) {
+      const name = configrecord.name || ''
+      if (name.endsWith('.disabled')) {
+        return configrecord.value === 'false'
+      }
+      return configrecord.value === 'true'
+    },
+    getRelatedConfigPrefix (configrecord) {
+      const name = configrecord.name || ''
+      const segments = name.split('.')
+      if (segments.length < 2) {
+        return null
+      }
+      let prefixSegments = segments.slice(0, -1)
+      if ((name.endsWith('.service.enabled') || 
name.endsWith('.service.disabled')) && prefixSegments.length > 1) {
+        prefixSegments = prefixSegments.slice(0, -1)
+      }
+      return prefixSegments.join('.')
+    },
+    fetchRelatedConfigurations (configrecord) {
+      const prefix = this.getRelatedConfigPrefix(configrecord)
+      if (!prefix) {
+        return
+      }
+      this.relatedLoading = true
+      const params = {
+        [this.scopeKey]: this.$route.params?.id,
+        keyword: prefix,
+        pagesize: -1,
+        listAll: true
+      }
+      if (this.scopeKey === 'domainid' && !params[this.scopeKey]) {
+        params[this.scopeKey] = this.resource?.id
+      }
+      getAPI('listConfigurations', params).then(json => {
+        const list = json?.listconfigurationsresponse?.configuration || []
+        this.relatedConfigs = list.filter(c => c.name !== configrecord.name && 
c.name.startsWith(prefix + '.'))
+        if (this.relatedConfigs.length > 0) {
+          this.relatedSourceConfigName = configrecord.name
+          this.relatedModalVisible = true
+        }
+      }).catch(error => {
+        console.error(error)
+      }).finally(() => {

Review Comment:
   When fetching related configurations fails, the error is only logged to the 
console. This leaves users with no feedback and can make the modal appear 
empty/non-responsive. Surface an error message to the UI so the user knows the 
related settings could not be loaded.



##########
ui/src/views/setting/ConfigurationValue.vue:
##########
@@ -319,6 +375,66 @@ export default {
         this.$emit('refresh', configrecord.name, configRecordEntry)
       })
     },
+    isConfigNowActive (configrecord) {
+      const name = configrecord.name || ''
+      if (name.endsWith('.disabled')) {
+        return configrecord.value === 'false'
+      }
+      return configrecord.value === 'true'
+    },
+    getRelatedConfigPrefix (configrecord) {
+      const name = configrecord.name || ''
+      const segments = name.split('.')
+      if (segments.length < 2) {
+        return null
+      }
+      let prefixSegments = segments.slice(0, -1)
+      if ((name.endsWith('.service.enabled') || 
name.endsWith('.service.disabled')) && prefixSegments.length > 1) {
+        prefixSegments = prefixSegments.slice(0, -1)
+      }
+      return prefixSegments.join('.')
+    },
+    fetchRelatedConfigurations (configrecord) {
+      const prefix = this.getRelatedConfigPrefix(configrecord)
+      if (!prefix) {
+        return
+      }
+      this.relatedLoading = true
+      const params = {
+        [this.scopeKey]: this.$route.params?.id,
+        keyword: prefix,
+        pagesize: -1,
+        listAll: true
+      }

Review Comment:
   `fetchRelatedConfigurations` always adds `[this.scopeKey]: 
this.$route.params?.id` to the GET params. On the `globalsetting` route, 
`scopeKey` is an empty string (see `created()`), and `getAPI()` does not filter 
out empty/undefined keys. This can produce a request with an empty query 
parameter name, which may break `listConfigurations`. Only include the scope 
parameter when `scopeKey` is set.



-- 
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