Skip to content

Commit e8f8378

Browse files
committed
refactor
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent bbfc4f0 commit e8f8378

File tree

1 file changed

+23
-31
lines changed

1 file changed

+23
-31
lines changed

ui/src/views/compute/DeployVM.vue

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,15 @@
279279
<a-card
280280
v-else
281281
:tabList="tabList"
282-
:activeTabKey="tabKey"
283-
@tabChange="key => onTabChange(key, 'tabKey')">
284-
<div v-if="tabKey === 'templateid'">
282+
:activeTabKey="form.imagetype"
283+
@tabChange="key => changeImageType(key)">
284+
<div v-if="form.imagetype === 'templateid'">
285285
{{ $t('message.template.desc') }}
286286
<new-template-iso-selection
287287
v-if="templateview === 'new'"
288288
input-decorator="templateid"
289289
:items="options.templates"
290-
:selected="tabKey"
290+
:selected="form.imagetype"
291291
:loading="loading.templates"
292292
:preFillContent="dataPreFill"
293293
@handle-search-filter="($event) => fetchAllTemplates($event)"
@@ -296,7 +296,7 @@
296296
v-else
297297
input-decorator="templateid"
298298
:items="options.templates"
299-
:selected="tabKey"
299+
:selected="form.imagetype"
300300
:loading="loading.templates"
301301
:preFillContent="dataPreFill"
302302
:key="templateKey"
@@ -338,7 +338,7 @@
338338
v-if="templateview === 'new'"
339339
input-decorator="isoid"
340340
:items="options.isos"
341-
:selected="tabKey"
341+
:selected="form.imagetype"
342342
:loading="loading.isos"
343343
:preFillContent="dataPreFill"
344344
@handle-search-filter="($event) => fetchAllIsos($event)"
@@ -347,7 +347,7 @@
347347
v-else
348348
input-decorator="isoid"
349349
:items="options.isos"
350-
:selected="tabKey"
350+
:selected="form.imagetype"
351351
:loading="loading.isos"
352352
:preFillContent="dataPreFill"
353353
@handle-search-filter="($event) => fetchAllIsos($event)"
@@ -450,7 +450,7 @@
450450
<a-input v-model:value="form.memory"/>
451451
</a-form-item>
452452
</span>
453-
<span v-if="tabKey!=='isoid'">
453+
<span v-if="form.imagetype!=='isoid'">
454454
{{ $t('label.override.root.diskoffering') }}
455455
<a-switch
456456
v-model:checked="showOverrideDiskOfferingOption"
@@ -459,7 +459,7 @@
459459
@change="val => { updateOverrideRootDiskShowParam(val) }"
460460
style="margin-left: 10px;"/>
461461
</span>
462-
<span v-if="tabKey!=='isoid' && serviceOffering && !serviceOffering.diskofferingstrictness">
462+
<span v-if="form.imagetype!=='isoid' && serviceOffering && !serviceOffering.diskofferingstrictness">
463463
<a-step
464464
:status="zoneSelected ? 'process' : 'wait'"
465465
v-if="!template.deployasis && template.childtemplates && template.childtemplates.length > 0" >
@@ -486,7 +486,7 @@
486486
:value="overrideDiskOffering ? overrideDiskOffering.id : ''"
487487
:loading="loading.diskOfferings"
488488
:preFillContent="dataPreFill"
489-
:isIsoSelected="tabKey==='isoid'"
489+
:isIsoSelected="form.imagetype==='isoid'"
490490
:isRootDiskOffering="true"
491491
@on-selected-root-disk-size="onSelectRootDiskSize"
492492
@select-disk-offering-item="($event) => updateOverrideDiskOffering($event)"
@@ -528,7 +528,7 @@
528528
</a-step>
529529
<a-step
530530
v-else
531-
:title="tabKey === 'templateid' ? $t('label.data.disk') : $t('label.disk.size')"
531+
:title="form.imagetype === 'templateid' ? $t('label.data.disk') : $t('label.disk.size')"
532532
:status="zoneSelected ? 'process' : 'wait'">
533533
<template #description>
534534
<div v-if="zoneSelected">
@@ -539,7 +539,7 @@
539539
:value="diskOffering ? diskOffering.id : ''"
540540
:loading="loading.diskOfferings"
541541
:preFillContent="dataPreFill"
542-
:isIsoSelected="tabKey==='isoid'"
542+
:isIsoSelected="form.imagetype==='isoid'"
543543
@on-selected-disk-size="onSelectDiskSize"
544544
@select-disk-offering-item="($event) => updateDiskOffering($event)"
545545
@handle-search-filter="($event) => handleSearchFilter('diskOfferings', $event)"
@@ -725,7 +725,7 @@
725725
</div>
726726
<a-form-item
727727
:label="$t('label.bootintosetup')"
728-
v-if="zoneSelected && ((tabKey === 'isoid' && hypervisor === 'VMware') || (tabKey === 'templateid' && template && template.hypervisor === 'VMware'))"
728+
v-if="zoneSelected && ((form.imagetype === 'isoid' && hypervisor === 'VMware') || (form.imagetype === 'templateid' && template && template.hypervisor === 'VMware'))"
729729
name="bootintosetup"
730730
ref="bootintosetup">
731731
<a-switch v-model:checked="form.bootintosetup" />
@@ -1224,7 +1224,6 @@ export default {
12241224
defaultnetworkid: '',
12251225
networkConfig: [],
12261226
dataNetworkCreated: [],
1227-
tabKey: 'templateid',
12281227
userdataTabKey: 'userdataregistered',
12291228
dataPreFill: {},
12301229
showDetails: false,
@@ -2004,7 +2003,7 @@ export default {
20042003
},
20052004
updateFieldValue (name, value) {
20062005
if (name === 'templateid') {
2007-
this.tabKey = 'templateid'
2006+
this.form.imagetype = 'templateid'
20082007
this.form.templateid = value
20092008
this.form.isoid = null
20102009
this.resetFromTemplateConfiguration()
@@ -2047,7 +2046,7 @@ export default {
20472046
this.templateNics = []
20482047
this.templateLicenses = []
20492048
this.templateProperties = {}
2050-
this.tabKey = 'isoid'
2049+
this.form.imagetype = 'isoid'
20512050
this.resetFromTemplateConfiguration()
20522051
this.form.isoid = value
20532052
this.form.templateid = null
@@ -2185,15 +2184,18 @@ export default {
21852184
this.fetchGuestOsCategories()
21862185
return
21872186
}
2188-
if (this.tabKey === 'templateid') {
2187+
if (this.form.imagetype === 'templateid') {
21892188
this.fetchAllTemplates()
21902189
} else {
21912190
this.fetchAllIsos()
21922191
}
21932192
},
2194-
changeImageType () {
2193+
changeImageType (imageType) {
21952194
if (this.templateview === 'new') {
21962195
this.fetchGuestOsCategories()
2196+
} else {
2197+
this.form.imagetype = imageType
2198+
this.fetchImages()
21972199
}
21982200
},
21992201
handleSubmitAndStay (e) {
@@ -2259,7 +2261,7 @@ export default {
22592261
deployVmData.userdata = this.$toBase64AndURIEncoded(values.userdata)
22602262
}
22612263
// step 2: select template/iso
2262-
if (this.tabKey === 'templateid') {
2264+
if (this.form.imagetype === 'templateid') {
22632265
deployVmData.templateid = values.templateid
22642266
values.hypervisor = null
22652267
} else {
@@ -2673,8 +2675,7 @@ export default {
26732675
})
26742676
},
26752677
fetchImages (params) {
2676-
const key = this.templateview === 'new' ? this.form.imagetype : this.tabKey
2677-
if (key === 'isoid') {
2678+
if (this.form.imagetype === 'isoid') {
26782679
this.fetchAllIsos(params)
26792680
return
26802681
}
@@ -2785,10 +2786,7 @@ export default {
27852786
this.form.isoid = undefined
27862787
this.resetTemplatesList()
27872788
this.resetIsosList()
2788-
this.tabKey = 'templateid'
2789-
if (this.isoId) {
2790-
this.tabKey = 'isoid'
2791-
}
2789+
this.form.imagetype = this.isoId ? 'isoid' : 'templateid'
27922790
this.fetchZoneOptions()
27932791
},
27942792
onSelectPodId (value) {
@@ -2822,12 +2820,6 @@ export default {
28222820
this.params[name].options = { ...this.params[name].options, ...options }
28232821
this.fetchOptions(this.params[name], name)
28242822
},
2825-
onTabChange (key, type) {
2826-
this[type] = key
2827-
if (key === 'isoid') {
2828-
this.fetchAllIsos()
2829-
}
2830-
},
28312823
onUserdataTabChange (key, type) {
28322824
this[type] = key
28332825
this.userDataParams = []

0 commit comments

Comments
 (0)