Skip to content

Commit 21d844b

Browse files
authored
ui: fix zone options for image instance deploy button (#12060)
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent e90e31d commit 21d844b

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

ui/src/components/view/ImageDeployInstanceButton.vue

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,14 @@ export default {
7171
if (this.$route.meta.name === 'iso') {
7272
this.imageApi = 'listIsos'
7373
}
74-
setTimeout(() => {
75-
this.fetchData()
76-
}, 100)
74+
this.fetchData()
75+
},
76+
watch: {
77+
resource (newValue) {
78+
if (newValue?.id) {
79+
this.fetchData()
80+
}
81+
}
7782
},
7883
computed: {
7984
allowed () {
@@ -82,23 +87,22 @@ export default {
8287
}
8388
},
8489
methods: {
85-
arrayHasItems (array) {
86-
return array !== null && array !== undefined && Array.isArray(array) && array.length > 0
87-
},
8890
fetchData () {
8991
this.fetchResourceData()
9092
},
9193
fetchResourceData () {
92-
const params = {}
93-
params.id = this.resource.id
94-
params.templatefilter = 'executable'
95-
params.listall = true
96-
params.page = this.page
97-
params.pagesize = this.pageSize
94+
if (!this.resource || !this.resource.id) {
95+
return
96+
}
97+
const params = {
98+
id: this.resource.id,
99+
templatefilter: 'executable',
100+
listall: true
101+
}
98102
99103
this.dataSource = []
100104
this.itemCount = 0
101-
this.fetchLoading = true
105+
this.loading = true
102106
this.zones = []
103107
getAPI(this.imageApi, params).then(json => {
104108
const imageResponse = json?.[this.imageApi.toLowerCase() + 'response']?.[this.$route.meta.name] || []
@@ -108,8 +112,8 @@ export default {
108112
}))
109113
}).catch(error => {
110114
this.$notifyError(error)
111-
this.loading = false
112115
}).finally(() => {
116+
this.loading = false
113117
if (this.zones.length !== 0) {
114118
this.$emit('update-zones', this.zones)
115119
}
@@ -122,7 +126,8 @@ export default {
122126
}
123127
const zoneids = this.zones.map(z => z.id)
124128
this.loading = true
125-
getAPI('listZones', { showicon: true, ids: zoneids.join(',') }).then(json => {
129+
const params = { showicon: true, ids: zoneids.join(',') }
130+
getAPI('listZones', params).then(json => {
126131
this.zones = json.listzonesresponse.zone || []
127132
}).finally(() => {
128133
this.loading = false

0 commit comments

Comments
 (0)