Skip to content

Commit 3367c74

Browse files
committed
fix
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 19e8477 commit 3367c74

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

ui/src/config/section/compute.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ export default {
107107
severity: 'warning',
108108
message: 'message.advisory.instance.image.missing',
109109
condition: async (store) => {
110-
return await hasNoItems(store,
111-
'listTemplates',
112-
{ isvnf: false, templatefilter: 'executable', isready: true }) &&
110+
return await hasNoItems(store, 'listTemplates', { isvnf: false, templatefilter: 'executable', isready: true }, null, 'listtemplatesresponse', 'template') &&
113111
await hasNoItems(store, 'listIsos', { isofilter: 'executable', bootable: true, isready: true }) &&
114112
await hasNoItems(store, 'listVolumes', { state: 'Ready' }) &&
115113
await hasNoItems(store, 'listSnapshots')

ui/src/config/section/network.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,14 @@ export default {
404404
severity: 'warning',
405405
message: 'message.advisory.vnf.appliance.template.missing',
406406
condition: async (store) => {
407-
return await hasNoItems(store,
408-
'listVnfTemplates',
409-
{ isvnf: true, templatefilter: 'executable', isready: true })
407+
return await hasNoItems(
408+
store,
409+
'listTemplates',
410+
{ isvnf: false, templatefilter: 'executable', isready: true },
411+
null,
412+
'listtemplatesresponse',
413+
'template'
414+
)
410415
},
411416
actions: [
412417
{

ui/src/utils/advisory/index.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { getAPI } from '@/api'
2525
* @param {string} itemsKey - Optional key for items array in response. If not provided, will be deduced from apiName
2626
* @returns {Promise<boolean>} - Returns true if no items exist (advisory should be shown), false otherwise
2727
*/
28-
export async function hasNoItems (store, apiName, params = {}, filterFunc = null, itemsKey = null) {
28+
export async function hasNoItems (store, apiName, params = {}, filterFunc = null, responseKey = null, itemsKey = null) {
2929
if (!(apiName in store.getters.apis)) {
3030
return false
3131
}
@@ -55,22 +55,17 @@ export async function hasNoItems (store, apiName, params = {}, filterFunc = null
5555
allParams.pageSize = 1
5656
}
5757

58-
console.debug(`Checking if API ${apiName} has no items with params`, allParams)
59-
6058
try {
6159
const json = await getAPI(apiName, allParams)
6260
// Auto-derive response key: listNetworks -> listnetworksresponse
63-
const responseKey = `${apiName.toLowerCase()}response`
64-
const items = json?.[responseKey]?.[itemsKey] || []
61+
const apiResponseKey = responseKey || `${apiName.toLowerCase()}response`
62+
const items = json?.[apiResponseKey]?.[itemsKey] || []
6563
if (filterFunc) {
66-
const a = !items.some(filterFunc)
67-
console.debug(`API ${apiName} has ${items.length} items, after filter has items: ${items.filter(filterFunc)[0]}, returning ${a}`)
68-
const it = items.filter(filterFunc)
69-
console.debug(`Filtered items:`, it)
70-
return a
64+
return !items.some(filterFunc)
7165
}
7266
return items.length === 0
7367
} catch (error) {
68+
console.error(`Failed to fetch items for advisory check via API ${apiName}`, error)
7469
return false
7570
}
7671
}

0 commit comments

Comments
 (0)