harikrishna-patnala commented on code in PR #12296:
URL: https://github.com/apache/cloudstack/pull/12296#discussion_r2650284374


##########
ui/src/views/infra/AddSecondaryStorage.vue:
##########
@@ -229,16 +247,57 @@ export default {
     closeModal () {
       this.$emit('close-action')
     },
+    fetchCopyTemplatesConfig () {
+      if (!this.form.zone) {
+        return
+      }
+
+      api('listConfigurations', {
+        name: 'copy.templates.from.other.secondary.storages',
+        zoneid: this.form.zone
+      }).then(json => {
+        const items =
+          json?.listconfigurationsresponse?.configuration || []
+
+        items.forEach(item => {
+          if (item.name === 'copy.templates.from.other.secondary.storages') {
+            this.form.copyTemplatesFromOtherSecondaryStorages =
+              item.value === 'true'
+          }
+        })
+      })
+    },
     listZones () {
       api('listZones', { showicon: true }).then(json => {
-        if (json && json.listzonesresponse && json.listzonesresponse.zone) {
+        if (json?.listzonesresponse?.zone) {
           this.zones = json.listzonesresponse.zone
+
           if (this.zones.length > 0) {
             this.form.zone = this.zones[0].id || ''
+            this.fetchCopyTemplatesConfig()
+            this.checkOtherSecondaryStorages()
           }
         }
       })
     },
+    checkOtherSecondaryStorages () {
+      api('listImageStores', {
+        listall: true
+      }).then(json => {
+        const stores = json?.listimagestoresresponse?.imagestore || []
+
+        this.showCopyTemplatesToggle = stores.some(store => {
+          if (store.providername !== 'NFS') {
+            return false
+          }
+
+          return store.zoneid !== this.form.zone || store.zoneid === 
this.form.zone

Review Comment:
   Checking if there are any secondary storage in same or other zones. but If 
we rethink its not required, I will simplify this by replacing with
   
   ```
   checkOtherSecondaryStorages () {
     api('listImageStores', { listall: true }).then(json => {
       const stores = json?.listimagestoresresponse?.imagestore || []
   
       this.showCopyTemplatesToggle = stores.some(store =>
         store.providername === 'NFS'
       )
     })
   }
   
   ```



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