Skip to content

Comments

ui: refactor advisories enabled usage and more#12676

Open
shwstppr wants to merge 3 commits intoapache:mainfrom
shwstppr:ui-adv-improv
Open

ui: refactor advisories enabled usage and more#12676
shwstppr wants to merge 3 commits intoapache:mainfrom
shwstppr:ui-adv-improv

Conversation

@shwstppr
Copy link
Contributor

@shwstppr shwstppr commented Feb 21, 2026

Description

Considers advisoriesDisabled as false if no value is found in the config or if set to false.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

Considers advisoriesDisabled as false if no value is found in the config
or if set to false.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@codecov
Copy link

codecov bot commented Feb 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 17.92%. Comparing base (30e6c22) to head (19e8477).

Additional details and impacted files
@@            Coverage Diff            @@
##               main   #12676   +/-   ##
=========================================
  Coverage     17.92%   17.92%           
- Complexity    16154    16158    +4     
=========================================
  Files          5939     5940    +1     
  Lines        533181   533240   +59     
  Branches      65237    65237           
=========================================
+ Hits          95585    95597   +12     
- Misses       426856   426904   +48     
+ Partials      10740    10739    -1     
Flag Coverage Δ
uitests 3.66% <ø> (-0.01%) ⬇️
unittests 19.04% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@sudo87 sudo87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr shwstppr changed the title ui: refactor advisories enabled usage ui: refactor advisories enabled usage and more Feb 21, 2026
@shwstppr
Copy link
Contributor Author

@blueorangutan ui

@blueorangutan
Copy link

@shwstppr a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors advisory system usage in the UI by introducing a centralized hasNoItems utility function and adding new advisories for VNF appliances and instances. The PR aims to improve code maintainability by reducing duplication and providing a consistent approach to checking resource availability for advisory conditions.

Changes:

  • Added hasNoItems utility function to centralize API-based advisory condition checking
  • Refactored existing Kubernetes cluster advisories to use the new utility function
  • Added new advisories for instance and VNF appliance deployment prerequisites (templates, ISOs, compute offerings, networks)
  • Updated router configuration to handle advisoriesDisabled config with proper null/undefined handling
  • Added new localization messages for the new advisories
  • Added advisoriesDisabled config option to config.json

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
ui/src/utils/advisory/index.js New utility file with hasNoItems helper function for checking API resource availability
ui/src/config/section/network.js Added advisories for VNF appliance deployment (template and compute offering checks)
ui/src/config/section/compute.js Added advisories for instance deployment (image, compute offering, network checks) and refactored CKS advisories
ui/src/config/router.js Improved handling of advisoriesDisabled config with nullish coalescing operator
ui/public/locales/en.json Added localization messages for new advisory warnings
ui/public/config.json Added advisoriesDisabled: false configuration option

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +66 to +70
const a = !items.some(filterFunc)
console.debug(`API ${apiName} has ${items.length} items, after filter has items: ${items.filter(filterFunc)[0]}, returning ${a}`)
const it = items.filter(filterFunc)
console.debug(`Filtered items:`, it)
return a
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The debug logging code contains redundant logic. Lines 66-67 compute the result and log filtered items, then lines 68-69 recompute the same filtered items for logging. The variable a is computed but could be simplified, and items.filter(filterFunc)[0] is used in logging which may be undefined if no items match. Consider simplifying this to compute the filtered items once and improve the debug output clarity.

Suggested change
const a = !items.some(filterFunc)
console.debug(`API ${apiName} has ${items.length} items, after filter has items: ${items.filter(filterFunc)[0]}, returning ${a}`)
const it = items.filter(filterFunc)
console.debug(`Filtered items:`, it)
return a
const filteredItems = items.filter(filterFunc)
const hasNoMatchingItems = filteredItems.length === 0
console.debug(`API ${apiName} has ${items.length} items, filtered items count: ${filteredItems.length}, returning ${hasNoMatchingItems}`)
console.debug('Filtered items:', filteredItems)
return hasNoMatchingItems

Copilot uses AI. Check for mistakes.
@@ -647,19 +750,8 @@ export default {
id: 'cks-version-check',
severity: 'warning',
message: 'message.advisory.cks.version.check',
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of docsHelp property from these advisories may be intentional refactoring, but it removes potentially useful documentation links for users. The original advisories had docsHelp: 'plugins/cloudstack-kubernetes-service.html' which helped users understand Kubernetes service setup. If this is intentional, ensure that documentation is accessible through other means.

Suggested change
message: 'message.advisory.cks.version.check',
message: 'message.advisory.cks.version.check',
docsHelp: 'plugins/cloudstack-kubernetes-service.html',

Copilot uses AI. Check for mistakes.
condition: async (store) => {
return await hasNoItems(store,
'listVnfTemplates',
{ isvnf: true, templatefilter: 'executable', isready: true })
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The listVnfTemplates API returns a response with the key listtemplatesresponse.template, not listvnftemplatesresponse.vnftemplate. The current itemsKey deduction logic will incorrectly derive vnftemplate and responseKey as listvnftemplatesresponse, which will not match the actual API response structure. This will cause the advisory condition to fail silently and return false. Consider either passing an explicit itemsKey parameter for this API or handling special API name mappings where the response key doesn't match the API name pattern.

Suggested change
{ isvnf: true, templatefilter: 'executable', isready: true })
{ isvnf: true, templatefilter: 'executable', isready: true },
'listtemplatesresponse.template')

Copilot uses AI. Check for mistakes.
return a
}
return items.length === 0
} catch (error) {
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling silently returns false when an API call fails, which could hide legitimate errors and cause advisories not to appear when they should. Consider logging the error or providing more specific error handling, especially since API failures could indicate permission issues or connectivity problems that users should be aware of.

Suggested change
} catch (error) {
} catch (error) {
console.error(`Failed to fetch items for advisory check via API ${apiName}`, error)

Copilot uses AI. Check for mistakes.
@blueorangutan
Copy link

UI build: ✔️
Live QA URL: https://qa.cloudstack.cloud/simulator/pr/12676 (QA-JID-879)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants