Skip to content

Commit 76e6de7

Browse files
authored
ui: fix form data double fetch/reset form data by ownership selection (#11705)
* ui: fix form data double fetch/reset form data by ownership selection Fixes #10832
1 parent f1f779a commit 76e6de7

File tree

6 files changed

+36
-14
lines changed

6 files changed

+36
-14
lines changed

ui/src/views/compute/DeployVM.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2339,7 +2339,9 @@ export default {
23392339
this.owner.domainid = null
23402340
this.owner.projectid = OwnerOptions.selectedProject
23412341
}
2342-
this.resetData()
2342+
if (OwnerOptions.initialized) {
2343+
this.resetData()
2344+
}
23432345
},
23442346
fetchZones (zoneId, listZoneAllow) {
23452347
this.zones = []

ui/src/views/compute/wizard/OwnershipSelection.vue

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<a-form layout="vertical" >
2020
<a-form-item :label="$t('label.owner.type')">
2121
<a-select
22-
@change="changeDomain"
22+
@change="changeAccountTypeOrDomain"
2323
v-model:value="selectedAccountType"
2424
defaultValue="account"
2525
autoFocus
@@ -37,7 +37,7 @@
3737
</a-form-item>
3838
<a-form-item :label="$t('label.domain')" required>
3939
<a-select
40-
@change="changeDomain"
40+
@change="changeAccountTypeOrDomain"
4141
v-model:value="selectedDomain"
4242
showSearch
4343
optionFilterProp="label"
@@ -136,14 +136,16 @@ export default {
136136
components: { ResourceIcon },
137137
data () {
138138
return {
139+
initialized: false,
139140
domains: [],
140141
accounts: [],
141142
projects: [],
142143
selectedAccountType: this.$store.getters.project?.id ? 'Project' : 'Account',
143144
selectedDomain: null,
144145
selectedAccount: null,
145146
selectedProject: null,
146-
loading: false
147+
loading: false,
148+
requestToken: 0
147149
}
148150
},
149151
props: {
@@ -177,7 +179,7 @@ export default {
177179
const domainIds = this.domains?.map(domain => domain.id)
178180
const ownerDomainId = this.$store.getters.project?.domainid || this.$store.getters.userInfo.domainid
179181
this.selectedDomain = domainIds?.includes(ownerDomainId) ? ownerDomainId : this.domains?.[0]?.id
180-
this.changeDomain()
182+
this.fetchOwnerData()
181183
})
182184
.catch((error) => {
183185
this.$notifyError(error)
@@ -186,8 +188,13 @@ export default {
186188
this.loading = false
187189
})
188190
},
191+
incrementAndGetRequestToken () {
192+
this.requestToken += 1
193+
return this.requestToken
194+
},
189195
fetchAccounts () {
190196
this.loading = true
197+
const currentToken = this.incrementAndGetRequestToken()
191198
api('listAccounts', {
192199
response: 'json',
193200
domainId: this.selectedDomain,
@@ -196,6 +203,9 @@ export default {
196203
isrecursive: false
197204
})
198205
.then((response) => {
206+
if (currentToken !== this.requestToken) {
207+
return
208+
}
199209
this.accounts = response.listaccountsresponse.account || []
200210
if (this.override?.accounts && this.accounts) {
201211
this.accounts = this.accounts.filter(item => this.override.accounts.has(item.name))
@@ -214,10 +224,12 @@ export default {
214224
})
215225
.finally(() => {
216226
this.loading = false
227+
this.initialized = true
217228
})
218229
},
219230
fetchProjects () {
220231
this.loading = true
232+
const currentToken = this.incrementAndGetRequestToken()
221233
api('listProjects', {
222234
response: 'json',
223235
domainId: this.selectedDomain,
@@ -227,6 +239,9 @@ export default {
227239
isrecursive: false
228240
})
229241
.then((response) => {
242+
if (currentToken !== this.requestToken) {
243+
return
244+
}
230245
this.projects = response.listprojectsresponse.project
231246
if (this.override?.projects && this.projects) {
232247
this.projects = this.projects.filter(item => this.override.projects.has(item.id))
@@ -240,9 +255,14 @@ export default {
240255
})
241256
.finally(() => {
242257
this.loading = false
258+
this.initialized = true
243259
})
244260
},
245-
changeDomain () {
261+
changeAccountTypeOrDomain () {
262+
this.initialized = true
263+
this.fetchOwnerData()
264+
},
265+
fetchOwnerData () {
246266
if (this.selectedAccountType === 'Account') {
247267
this.fetchAccounts()
248268
} else {

ui/src/views/network/CreateIsolatedNetworkForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ export default {
507507
this.owner.domainid = null
508508
this.owner.projectid = OwnerOptions.selectedProject
509509
}
510-
if (isAdminOrDomainAdmin()) {
510+
if (OwnerOptions.initialized && isAdminOrDomainAdmin()) {
511511
this.updateVPCCheckAndFetchNetworkOfferingData()
512512
}
513513
},

ui/src/views/network/CreateL2NetworkForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ export default {
309309
this.owner.domainid = null
310310
this.owner.projectid = OwnerOptions.selectedProject
311311
}
312-
if (isAdminOrDomainAdmin()) {
312+
if (OwnerOptions.initialized && this.isAdminOrDomainAdmin()) {
313313
this.updateVPCCheckAndFetchNetworkOfferingData()
314314
}
315315
},

ui/src/views/storage/CreateSharedFS.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,23 +272,21 @@ export default {
272272
},
273273
fetchOwnerOptions (OwnerOptions) {
274274
this.owner = {}
275-
console.log('fetching owner')
276275
if (OwnerOptions.selectedAccountType === 'Account') {
277276
if (!OwnerOptions.selectedAccount) {
278277
return
279278
}
280-
console.log('fetched account')
281279
this.owner.account = OwnerOptions.selectedAccount
282280
this.owner.domainid = OwnerOptions.selectedDomain
283281
} else if (OwnerOptions.selectedAccountType === 'Project') {
284282
if (!OwnerOptions.selectedProject) {
285283
return
286284
}
287-
console.log('fetched project')
288285
this.owner.projectid = OwnerOptions.selectedProject
289286
}
290-
console.log('fetched owner')
291-
this.fetchData()
287+
if (OwnerOptions.initialized) {
288+
this.fetchData()
289+
}
292290
},
293291
fetchData () {
294292
this.minCpu = store.getters.features.sharedfsvmmincpucount

ui/src/views/storage/CreateVolume.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ export default {
272272
}
273273
this.owner.projectid = OwnerOptions.selectedProject
274274
}
275-
this.fetchData()
275+
if (OwnerOptions.initialized) {
276+
this.fetchData()
277+
}
276278
},
277279
fetchData () {
278280
if (this.createVolumeFromSnapshot) {

0 commit comments

Comments
 (0)