ui: donot filter edge zones while registering directdownload iso (#10865)

Fixes #10766

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
Abhishek Kumar 2025-09-03 15:16:10 +05:30 committed by GitHub
parent 973b333e40
commit f24b1757a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -85,7 +85,7 @@
<template #label> <template #label>
<tooltip-label :title="$t('label.directdownload')" :tooltip="apiParams.directdownload.description"/> <tooltip-label :title="$t('label.directdownload')" :tooltip="apiParams.directdownload.description"/>
</template> </template>
<a-switch v-model:checked="form.directdownload"/> <a-switch v-model:checked="form.directdownload" @change="handleDirectDownloadChange"/>
</a-form-item> </a-form-item>
<a-form-item ref="checksum" name="checksum"> <a-form-item ref="checksum" name="checksum">
@ -110,7 +110,7 @@
}" }"
:loading="zoneLoading" :loading="zoneLoading"
:placeholder="apiParams.zoneid.description"> :placeholder="apiParams.zoneid.description">
<a-select-option :value="opt.id" v-for="opt in zones" :key="opt.id" :label="opt.name || opt.description"> <a-select-option :value="opt.id" v-for="opt in zoneList" :key="opt.id" :label="opt.name || opt.description">
<span> <span>
<resource-icon v-if="opt.icon" :image="opt.icon.base64image" size="1x" style="margin-right: 5px"/> <resource-icon v-if="opt.icon" :image="opt.icon.base64image" size="1x" style="margin-right: 5px"/>
<global-outlined v-else style="margin-right: 5px" /> <global-outlined v-else style="margin-right: 5px" />
@ -361,17 +361,18 @@ export default {
}, },
created () { created () {
this.initForm() this.initForm()
this.zones = [] this.initZones()
if (this.$store.getters.userInfo.roletype === 'Admin' && this.currentForm === 'Create') {
this.zones = [
{
id: '-1',
name: this.$t('label.all.zone')
}
]
}
this.fetchData() this.fetchData()
}, },
computed: {
zoneList () {
let filteredZones = this.zones
if (!this.form.directdownload) {
filteredZones = this.zones.filter(zone => zone.type !== 'Edge')
}
return filteredZones
}
},
methods: { methods: {
initForm () { initForm () {
this.formRef = ref() this.formRef = ref()
@ -390,6 +391,17 @@ export default {
ostypeid: [{ required: true, message: this.$t('message.error.select') }] ostypeid: [{ required: true, message: this.$t('message.error.select') }]
}) })
}, },
initZones () {
this.zones = []
if (this.$store.getters.userInfo.roletype === 'Admin' && this.currentForm === 'Create') {
this.zones = [
{
id: '-1',
name: this.$t('label.all.zone')
}
]
}
},
fetchData () { fetchData () {
this.fetchZoneData() this.fetchZoneData()
this.fetchOsType() this.fetchOsType()
@ -412,11 +424,10 @@ export default {
const listZones = json.listzonesresponse.zone const listZones = json.listzonesresponse.zone
if (listZones) { if (listZones) {
this.zones = this.zones.concat(listZones) this.zones = this.zones.concat(listZones)
this.zones = this.zones.filter(zone => zone.type !== 'Edge')
} }
}).finally(() => { }).finally(() => {
this.zoneLoading = false this.zoneLoading = false
this.form.zoneid = (this.zones[0].id ? this.zones[0].id : '') this.form.zoneid = this.zoneList?.[0]?.id || ''
}) })
}, },
fetchOsType () { fetchOsType () {
@ -467,6 +478,12 @@ export default {
this.fileList = newFileList this.fileList = newFileList
this.form.file = undefined this.form.file = undefined
}, },
handleDirectDownloadChange () {
if (this.form.zoneid && this.zoneList.find(entry => entry.id === this.form.zoneid)) {
return
}
this.form.zoneid = this.zoneList?.[0]?.id || ''
},
beforeUpload (file) { beforeUpload (file) {
this.fileList = [file] this.fileList = [file]
this.form.file = file this.form.file = file
@ -531,7 +548,7 @@ export default {
} }
switch (key) { switch (key) {
case 'zoneid': case 'zoneid':
var zone = this.zones.filter(zone => zone.id === input) var zone = this.zoneList.filter(zone => zone.id === input)
params[key] = zone[0].id params[key] = zone[0].id
break break
case 'ostypeid': case 'ostypeid':