Skip to content

Commit 8c634cd

Browse files
committed
Address comments
1 parent 07bd2de commit 8c634cd

File tree

1 file changed

+47
-43
lines changed

1 file changed

+47
-43
lines changed

ui/src/components/view/SearchFilter.vue

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
:wrap="false"
2222
>
2323
<template
24-
v-for="(filter) in this.searchFilters"
25-
:key="filter"
24+
v-for="filter in this.searchFilters"
25+
:key="filter.key + filter.value"
2626
>
2727
<a-col v-if="!['page', 'pagesize', 'q', 'keyword', 'tags'].includes(filter.key)">
2828
<a-tag
@@ -32,7 +32,7 @@
3232
>
3333
<a-tooltip
3434
:title="retrieveFieldLabel(filter.key) + ': ' + filter.value"
35-
:placement="tooltipPlacement"
35+
placement="bottom"
3636
>
3737
{{ retrieveFieldLabel(filter.key) }} : {{ getTrimmedText(filter.value, 20) }}
3838
</a-tooltip>
@@ -44,7 +44,7 @@
4444
>
4545
<a-tooltip
4646
:title="$t('label.tag') + ': ' + filter.key + '=' + filter.value"
47-
:placement="tooltipPlacement"
47+
placement="bottom"
4848
>
4949
{{ $t('label.tag') }}: {{ filter.key }}={{ getTrimmedText(filter.value, 20) }}
5050
</a-tooltip>
@@ -87,8 +87,8 @@ export default {
8787
return {
8888
searchFilters: [],
8989
apiMap: {
90-
type: this.getType,
91-
hypervisor: this.getHypervisor,
90+
type: (value) => this.getType(value),
91+
hypervisor: (value) => this.getHypervisor(value),
9292
zoneid: {
9393
apiName: 'listZones',
9494
responseKey1: 'listzonesresponse',
@@ -170,37 +170,39 @@ export default {
170170
}
171171
}
172172
},
173-
updated () {
174-
this.searchFilters = this.filters
175-
const promises = []
176-
for (const idx in this.filters) {
177-
const filter = this.filters[idx]
178-
if (this.searchFilters[idx] && this.searchFilters[idx].value !== filter.value) {
179-
continue
180-
}
181-
promises.push(new Promise((resolve) => {
182-
if (this.searchFilters[idx] && this.searchFilters[idx].value !== filter.value) {
183-
resolve()
184-
}
185-
if (filter.key === 'tags') {
186-
this.searchFilters[idx] = {
187-
key: filter.key,
188-
value: filter.value,
189-
isTag: true
190-
}
191-
} else {
192-
this.getSearchFilters(filter.key, filter.value).then((value) => {
193-
this.searchFilters[idx] = {
194-
key: filter.key,
195-
value: value,
196-
isTag: filter.isTag
173+
watch: {
174+
filters: {
175+
immediate: true,
176+
handler (newFilters) {
177+
const clonedFilters = newFilters.map(filter => ({ ...filter }))
178+
const promises = []
179+
for (let idx = 0; idx < clonedFilters.length; idx++) {
180+
const filter = clonedFilters[idx]
181+
promises.push(new Promise((resolve) => {
182+
if (filter.key === 'tags') {
183+
clonedFilters[idx] = {
184+
key: filter.key,
185+
value: filter.value,
186+
isTag: true
187+
}
188+
resolve()
189+
} else {
190+
this.getSearchFilters(filter.key, filter.value).then((value) => {
191+
clonedFilters[idx] = {
192+
key: filter.key,
193+
value: value,
194+
isTag: filter.isTag
195+
}
196+
resolve()
197+
})
197198
}
198-
})
199+
}))
199200
}
200-
resolve()
201-
}))
201+
Promise.all(promises).then(() => {
202+
this.searchFilters = clonedFilters
203+
})
204+
}
202205
}
203-
Promise.all(promises)
204206
},
205207
methods: {
206208
getTrimmedText (text, length) {
@@ -241,7 +243,9 @@ export default {
241243
}
242244
243245
if (key.includes('scope')) {
244-
formattedValue = this.getScope(value)
246+
// Check storage pool scope first (more specific), then fall back to general scope
247+
const storagePoolScope = this.getStoragePoolScope(value)
248+
formattedValue = storagePoolScope && storagePoolScope.length > 0 ? storagePoolScope : this.getScope(value)
245249
}
246250
247251
if (key.includes('state')) {
@@ -264,10 +268,6 @@ export default {
264268
formattedValue = this.getSystemVmType(value)
265269
}
266270
267-
if (key.includes('scope')) {
268-
formattedValue = this.getStoragePoolScope(value)
269-
}
270-
271271
if (key.includes('provider')) {
272272
formattedValue = this.getImageStoreProvider(value)
273273
}
@@ -301,10 +301,11 @@ export default {
301301
for (const key in json.listhypervisorsresponse.hypervisor) {
302302
const hypervisor = json.listhypervisorsresponse.hypervisor[key]
303303
if (hypervisor.name === value) {
304-
resolve(hypervisor.name)
304+
return resolve(hypervisor.name)
305305
}
306306
}
307307
}
308+
resolve(null)
308309
}).catch(() => {
309310
resolve(null)
310311
})
@@ -316,8 +317,11 @@ export default {
316317
return resolve('')
317318
}
318319
api(apiName, { listAll: true, id: id }).then(json => {
319-
if (json[responseKey1] && json[responseKey1][responseKey2]) {
320-
resolve(json[responseKey1][responseKey2][0][field])
320+
const items = json && json[responseKey1] && json[responseKey1][responseKey2]
321+
if (Array.isArray(items) && items.length > 0 && items[0] && items[0][field] !== undefined) {
322+
resolve(items[0][field])
323+
} else {
324+
resolve('')
321325
}
322326
}).catch(() => {
323327
resolve('')
@@ -522,7 +526,7 @@ export default {
522526
ISO: 'ISO',
523527
SSH_KEYPAIR: 'SSH Key Pair',
524528
DOMAIN: 'Domain',
525-
SERVICE_OFFERING: 'Service Offfering',
529+
SERVICE_OFFERING: 'Service Offering',
526530
DISK_OFFERING: 'Disk Offering',
527531
NETWORK_OFFERING: 'Network Offering',
528532
POD: 'Pod',

0 commit comments

Comments
 (0)