Skip to content

Commit f24b175

Browse files
authored
ui: donot filter edge zones while registering directdownload iso (#10865)
Fixes #10766 Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 973b333 commit f24b175

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

ui/src/views/image/RegisterOrUploadIso.vue

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
<template #label>
8686
<tooltip-label :title="$t('label.directdownload')" :tooltip="apiParams.directdownload.description"/>
8787
</template>
88-
<a-switch v-model:checked="form.directdownload"/>
88+
<a-switch v-model:checked="form.directdownload" @change="handleDirectDownloadChange"/>
8989
</a-form-item>
9090

9191
<a-form-item ref="checksum" name="checksum">
@@ -110,7 +110,7 @@
110110
}"
111111
:loading="zoneLoading"
112112
:placeholder="apiParams.zoneid.description">
113-
<a-select-option :value="opt.id" v-for="opt in zones" :key="opt.id" :label="opt.name || opt.description">
113+
<a-select-option :value="opt.id" v-for="opt in zoneList" :key="opt.id" :label="opt.name || opt.description">
114114
<span>
115115
<resource-icon v-if="opt.icon" :image="opt.icon.base64image" size="1x" style="margin-right: 5px"/>
116116
<global-outlined v-else style="margin-right: 5px" />
@@ -361,17 +361,18 @@ export default {
361361
},
362362
created () {
363363
this.initForm()
364-
this.zones = []
365-
if (this.$store.getters.userInfo.roletype === 'Admin' && this.currentForm === 'Create') {
366-
this.zones = [
367-
{
368-
id: '-1',
369-
name: this.$t('label.all.zone')
370-
}
371-
]
372-
}
364+
this.initZones()
373365
this.fetchData()
374366
},
367+
computed: {
368+
zoneList () {
369+
let filteredZones = this.zones
370+
if (!this.form.directdownload) {
371+
filteredZones = this.zones.filter(zone => zone.type !== 'Edge')
372+
}
373+
return filteredZones
374+
}
375+
},
375376
methods: {
376377
initForm () {
377378
this.formRef = ref()
@@ -390,6 +391,17 @@ export default {
390391
ostypeid: [{ required: true, message: this.$t('message.error.select') }]
391392
})
392393
},
394+
initZones () {
395+
this.zones = []
396+
if (this.$store.getters.userInfo.roletype === 'Admin' && this.currentForm === 'Create') {
397+
this.zones = [
398+
{
399+
id: '-1',
400+
name: this.$t('label.all.zone')
401+
}
402+
]
403+
}
404+
},
393405
fetchData () {
394406
this.fetchZoneData()
395407
this.fetchOsType()
@@ -412,11 +424,10 @@ export default {
412424
const listZones = json.listzonesresponse.zone
413425
if (listZones) {
414426
this.zones = this.zones.concat(listZones)
415-
this.zones = this.zones.filter(zone => zone.type !== 'Edge')
416427
}
417428
}).finally(() => {
418429
this.zoneLoading = false
419-
this.form.zoneid = (this.zones[0].id ? this.zones[0].id : '')
430+
this.form.zoneid = this.zoneList?.[0]?.id || ''
420431
})
421432
},
422433
fetchOsType () {
@@ -467,6 +478,12 @@ export default {
467478
this.fileList = newFileList
468479
this.form.file = undefined
469480
},
481+
handleDirectDownloadChange () {
482+
if (this.form.zoneid && this.zoneList.find(entry => entry.id === this.form.zoneid)) {
483+
return
484+
}
485+
this.form.zoneid = this.zoneList?.[0]?.id || ''
486+
},
470487
beforeUpload (file) {
471488
this.fileList = [file]
472489
this.form.file = file
@@ -531,7 +548,7 @@ export default {
531548
}
532549
switch (key) {
533550
case 'zoneid':
534-
var zone = this.zones.filter(zone => zone.id === input)
551+
var zone = this.zoneList.filter(zone => zone.id === input)
535552
params[key] = zone[0].id
536553
break
537554
case 'ostypeid':

0 commit comments

Comments
 (0)