Skip to content

Commit 0e2c09b

Browse files
author
Hoang Nguyen
authored
UI - Fixes Pod, Cluster selected is incorrect on addHost dialog (apache#5869)
* fix pod selected is incorrect * fixes fetch cluster with podid empty * clear clusterid field
1 parent e18ff60 commit 0e2c09b

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

ui/src/views/infra/HostAdd.vue

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@
123123
initialValue: authMethod
124124
}]"
125125
buttonStyle="solid"
126-
:defaultValue="authMethod"
127126
@change="selected => { handleAuthMethodChange(selected.target.value) }">
128127
<a-radio-button value="password">
129128
{{ $t('label.password') }}
@@ -321,22 +320,24 @@ export default {
321320
this.loading = true
322321
api('listZones', { showicon: true }).then(response => {
323322
this.zonesList = response.listzonesresponse.zone || []
324-
this.zoneId = this.zonesList[0].id || null
325-
this.fetchPods()
323+
this.zoneId = this.zonesList[0]?.id || null
324+
this.fetchPods(this.zoneId)
326325
}).catch(error => {
327326
this.$notifyError(error)
328327
}).finally(() => {
329328
this.loading = false
330329
})
331330
},
332-
fetchPods () {
331+
fetchPods (zoneId) {
332+
this.zoneId = zoneId
333333
this.loading = true
334334
api('listPods', {
335335
zoneid: this.zoneId
336336
}).then(response => {
337337
this.podsList = response.listpodsresponse.pod || []
338-
this.podId = this.podsList[0].id || null
339-
this.fetchClusters()
338+
this.podId = this.podsList[0]?.id || null
339+
this.form.setFieldsValue({ podid: this.podId })
340+
this.fetchClusters(this.podId)
340341
}).catch(error => {
341342
this.$notifyError(error)
342343
this.podsList = []
@@ -345,13 +346,19 @@ export default {
345346
this.loading = false
346347
})
347348
},
348-
fetchClusters () {
349+
fetchClusters (podId) {
350+
this.form.clearField('clusterid')
351+
this.clusterId = null
352+
this.clustersList = []
353+
if (!podId) return
354+
this.podId = podId
349355
this.loading = true
350356
api('listClusters', {
351357
podid: this.podId
352358
}).then(response => {
353359
this.clustersList = response.listclustersresponse.cluster || []
354-
this.clusterId = this.clustersList[0].id || null
360+
this.clusterId = this.clustersList[0]?.id || null
361+
this.form.setFieldsValue({ clusterid: this.clusterId })
355362
if (this.clusterId) {
356363
this.handleChangeCluster(this.clusterId)
357364
}

0 commit comments

Comments
 (0)