Skip to content

ui: do not filter edge zones while registering directdownload iso #10865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 31 additions & 14 deletions ui/src/views/image/RegisterOrUploadIso.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<template #label>
<tooltip-label :title="$t('label.directdownload')" :tooltip="apiParams.directdownload.description"/>
</template>
<a-switch v-model:checked="form.directdownload"/>
<a-switch v-model:checked="form.directdownload" @change="handleDirectDownloadChange"/>
</a-form-item>

<a-form-item ref="checksum" name="checksum">
Expand All @@ -110,7 +110,7 @@
}"
:loading="zoneLoading"
: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>
<resource-icon v-if="opt.icon" :image="opt.icon.base64image" size="1x" style="margin-right: 5px"/>
<global-outlined v-else style="margin-right: 5px" />
Expand Down Expand Up @@ -361,17 +361,18 @@ export default {
},
created () {
this.initForm()
this.zones = []
if (this.$store.getters.userInfo.roletype === 'Admin' && this.currentForm === 'Create') {
this.zones = [
{
id: '-1',
name: this.$t('label.all.zone')
}
]
}
this.initZones()
this.fetchData()
},
computed: {
zoneList () {
let filteredZones = this.zones
if (!this.form.directdownload) {
filteredZones = this.zones.filter(zone => zone.type !== 'Edge')
}
return filteredZones
}
},
methods: {
initForm () {
this.formRef = ref()
Expand All @@ -390,6 +391,17 @@ export default {
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 () {
this.fetchZoneData()
this.fetchOsType()
Expand All @@ -412,11 +424,10 @@ export default {
const listZones = json.listzonesresponse.zone
if (listZones) {
this.zones = this.zones.concat(listZones)
this.zones = this.zones.filter(zone => zone.type !== 'Edge')
}
}).finally(() => {
this.zoneLoading = false
this.form.zoneid = (this.zones[0].id ? this.zones[0].id : '')
this.form.zoneid = this.zoneList?.[0]?.id || ''
})
},
fetchOsType () {
Expand Down Expand Up @@ -467,6 +478,12 @@ export default {
this.fileList = newFileList
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 || ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shwstppr
line 485 set the this.form.zoneid to the id of first zone , is it needed ?

Copy link
Contributor Author

@shwstppr shwstppr May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weizhouapache yes. This is for the case when the user selects direct-download, then selects an edge zone but then changes direct-download to false. Earlier selected zone will not be available now so the code selects the first zone from the list

},
beforeUpload (file) {
this.fileList = [file]
this.form.file = file
Expand Down Expand Up @@ -531,7 +548,7 @@ export default {
}
switch (key) {
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
break
case 'ostypeid':
Expand Down
Loading