Skip to content

Commit c35ba60

Browse files
authored
ui: fix account list on domain change in filterview (#9345)
* ui: fix account list on domain change in filterview Fixes #9274 * fix * filter accounts for selected domain Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent f35f3f6 commit c35ba60

1 file changed

Lines changed: 28 additions & 7 deletions

File tree

ui/src/components/view/SearchView.vue

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@
6666
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
6767
}"
6868
:loading="field.loading"
69-
@input="onchange($event, field.name)">
69+
@input="onchange($event, field.name)"
70+
@change="onSelectFieldChange(field.name)">
7071
<a-select-option
7172
v-for="(opt, idx) in field.opts"
7273
:key="idx"
73-
:value="opt.id"
74-
:label="$t(opt.path || opt.name)">
74+
:value="['account'].includes(field.name) ? opt.name : opt.id"
75+
:label="$t((['storageid'].includes(field.name) || !opt.path) ? opt.name : opt.path)">
7576
<div>
7677
<span v-if="(field.name.startsWith('zone'))">
7778
<span v-if="opt.icon">
@@ -85,7 +86,7 @@
8586
</span>
8687
<block-outlined v-else style="margin-right: 5px" />
8788
</span>
88-
{{ $t(opt.path || opt.name) }}
89+
{{ $t((['storageid'].includes(field.name) || !opt.path) ? opt.name : opt.path) }}
8990
</div>
9091
</a-select-option>
9192
</a-select>
@@ -241,6 +242,11 @@ export default {
241242
onchange: async function (event, fieldname) {
242243
this.fetchDynamicFieldData(fieldname, event.target.value)
243244
},
245+
onSelectFieldChange (fieldname) {
246+
if (fieldname === 'domainid') {
247+
this.fetchDynamicFieldData('account')
248+
}
249+
},
244250
onVisibleForm () {
245251
this.visibleFilter = !this.visibleFilter
246252
if (!this.visibleFilter) return
@@ -563,6 +569,9 @@ export default {
563569
if (domainIndex > -1) {
564570
this.fields[domainIndex].loading = false
565571
}
572+
if (accountIndex > -1) {
573+
this.fields[accountIndex].loading = false
574+
}
566575
if (imageStoreIndex > -1) {
567576
this.fields[imageStoreIndex].loading = false
568577
}
@@ -584,7 +593,9 @@ export default {
584593
if (diskOfferingIndex > -1) {
585594
this.fields[diskOfferingIndex].loading = false
586595
}
587-
this.fillFormFieldValues()
596+
if (Array.isArray(arrayField)) {
597+
this.fillFormFieldValues()
598+
}
588599
})
589600
},
590601
initFormFieldData () {
@@ -595,6 +606,9 @@ export default {
595606
this.fetchDynamicFieldData(arrayField)
596607
},
597608
sortArray (data, key = 'name') {
609+
if (!data) {
610+
return []
611+
}
598612
return data.sort(function (a, b) {
599613
if (a[key] < b[key]) { return -1 }
600614
if (a[key] > b[key]) { return 1 }
@@ -644,8 +658,15 @@ export default {
644658
},
645659
fetchAccounts (searchKeyword) {
646660
return new Promise((resolve, reject) => {
647-
api('listAccounts', { listAll: true, showicon: true, keyword: searchKeyword }).then(json => {
648-
const account = json.listaccountsresponse.account
661+
const params = { listAll: true, isrecursive: false, showicon: true, keyword: searchKeyword }
662+
if (this.form.domainid) {
663+
params.domainid = this.form.domainid
664+
}
665+
api('listAccounts', params).then(json => {
666+
var account = json.listaccountsresponse.account
667+
if (this.form.domainid) {
668+
account = account.filter(a => a.domainid === this.form.domainid)
669+
}
649670
resolve({
650671
type: 'account',
651672
data: account

0 commit comments

Comments
 (0)