Skip to content

Commit ca09591

Browse files
committed
Addressed reviews
Removed OS/User options when using volume/snapshot refactoring
1 parent 13b1796 commit ca09591

File tree

1 file changed

+47
-38
lines changed

1 file changed

+47
-38
lines changed

ui/src/views/compute/DeployVM.vue

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,9 @@ export default {
15081508
return this.$config.showAllCategoryForModernImageSelection
15091509
},
15101510
guestOsCategoriesSelectionDisallowed () {
1511+
if (this.imageType === 'volumeid' || this.imageType === 'snapshotid') {
1512+
return true
1513+
}
15111514
return (!this.queryGuestOsCategoryId || this.options.guestOsCategories.length === 0) && (!!this.queryTemplateId || !!this.queryIsoId)
15121515
},
15131516
isTemplateHypervisorExternal () {
@@ -2022,52 +2025,58 @@ export default {
20222025
this.userdataDefaultOverridePolicy = this.iso.userdatapolicy
20232026
}
20242027
} else if (name === 'volumeid') {
2025-
this.imageType = 'volumeid'
2026-
this.resetTemplateAssociatedResources()
2027-
this.resetFromTemplateConfiguration()
2028-
this.form.templateid = null
2029-
this.form.isoid = null
2030-
this.form.volumeid = value
2031-
this.form.snapshotid = null
2032-
let volume = null
2033-
for (const entry of Object.values(this.options.volumes)) {
2034-
volume = entry?.volume.find(option => option.id === value)
2035-
if (volume) {
2036-
this.volume = volume
2037-
break
2038-
}
2039-
}
2040-
if (volume) {
2041-
this.updateTemplateLinkedUserData(this.volume.userdataid)
2042-
this.userdataDefaultOverridePolicy = this.volume.userdatapolicy
2043-
}
2028+
this.updateFieldValueForVolume(value)
20442029
} else if (name === 'snapshotid') {
2045-
this.imageType = 'snapshotid'
2046-
this.resetTemplateAssociatedResources()
2047-
this.resetFromTemplateConfiguration()
2048-
this.form.templateid = null
2049-
this.form.isoid = null
2050-
this.form.volumeid = null
2051-
this.form.snapshotid = value
2052-
let snapshot = null
2053-
for (const entry of Object.values(this.options.snapshots)) {
2054-
snapshot = entry?.snapshot.find(option => option.id === value)
2055-
if (snapshot) {
2056-
this.snapshot = snapshot
2057-
break
2058-
}
2059-
}
2060-
if (snapshot) {
2061-
this.updateTemplateLinkedUserData(this.snapshot.userdataid)
2062-
this.userdataDefaultOverridePolicy = this.snapshot.userdatapolicy
2063-
}
2030+
this.updateFieldValueForSnapshot(value)
20642031
} else if (['cpuspeed', 'cpunumber', 'memory'].includes(name)) {
20652032
this.vm[name] = value
20662033
this.form[name] = value
20672034
} else {
20682035
this.form[name] = value
20692036
}
20702037
},
2038+
updateFieldValueForVolume (value) {
2039+
this.imageType = 'volumeid'
2040+
this.resetTemplateAssociatedResources()
2041+
this.resetFromTemplateConfiguration()
2042+
this.form.templateid = null
2043+
this.form.isoid = null
2044+
this.form.volumeid = value
2045+
this.form.snapshotid = null
2046+
let volume = null
2047+
for (const entry of Object.values(this.options.volumes)) {
2048+
volume = entry?.volume.find(option => option.id === value)
2049+
if (volume) {
2050+
this.volume = volume
2051+
break
2052+
}
2053+
}
2054+
if (volume) {
2055+
this.updateTemplateLinkedUserData(this.volume.userdataid)
2056+
this.userdataDefaultOverridePolicy = this.volume.userdatapolicy
2057+
}
2058+
},
2059+
updateFieldValueForSnapshot (value) {
2060+
this.imageType = 'snapshotid'
2061+
this.resetTemplateAssociatedResources()
2062+
this.resetFromTemplateConfiguration()
2063+
this.form.templateid = null
2064+
this.form.isoid = null
2065+
this.form.volumeid = null
2066+
this.form.snapshotid = value
2067+
let snapshot = null
2068+
for (const entry of Object.values(this.options.snapshots)) {
2069+
snapshot = entry?.snapshot.find(option => option.id === value)
2070+
if (snapshot) {
2071+
this.snapshot = snapshot
2072+
break
2073+
}
2074+
}
2075+
if (snapshot) {
2076+
this.updateTemplateLinkedUserData(this.snapshot.userdataid)
2077+
this.userdataDefaultOverridePolicy = this.snapshot.userdatapolicy
2078+
}
2079+
},
20712080
updateComputeOffering (id) {
20722081
this.form.computeofferingid = id
20732082
setTimeout(() => {

0 commit comments

Comments
 (0)