Skip to content

ROX-29492: Compute conditional colSpan according to Advisory column#15453

Merged
pedrottimark merged 1 commit intomasterfrom
ROX-29492-colSpan-Advisory
May 28, 2025
Merged

ROX-29492: Compute conditional colSpan according to Advisory column#15453
pedrottimark merged 1 commit intomasterfrom
ROX-29492-colSpan-Advisory

Conversation

@pedrottimark
Copy link
Contributor

@pedrottimark pedrottimark commented May 27, 2025

Description

Problems

  1. Thank you, David Vail for finding inconsistent colspan="5" attribute of td element when presence of Advisory column increases total to 6.
    Therefore layer has less than available width.
  2. When I expanded the wrong td element, I also found inconsistent colspan attribute for component table itself.
    • Images: colspan={7} attribute is out-of-date and too small.
    • Deployments: colspan={6} attribute is up-to-date, becamebut incorrect when I substituted inline value with computed value, because colspan={8} attribute of TbodyUnified for filtered empty state is incorrect. Maybe copy-paste from images?

Solution

Follow conditional colSpan pattern from elsewhere.

User-facing documentation

  • CHANGELOG.md update is not needed
  • documentation PR is not needed

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

  1. npm run tsc in ui/apps/platform folder.
  2. npm run lint in ui/apps/platform folder.

Manual testing with Advisory column

Temporarily edit code to simulate ROX_FLATTEN_CVE_DATA feature flag enabled, because it is not yet enabled for staging demo.

  1. Visit /main/vulnerabilities/user-workloads/cves/id with and expand vulnerability row to see ImageComponentVulnerabilitiesTable element.

    • Before changes, with constant colSpan={5} prop, see inconsistent colspan="5" attribute of td element, therefore layer has less than available width.
      ImageComponentVulnerabilitiesTable_inconsistent

    • After changes, with conditional colSpan={colSpanForDockerfileLayer} prop, consistent colspan="6" attribute of td element, therefore layer has available width.
      ImageComponentVulnerabilitiesTable_consistent

  2. Click Deployments and then expand vulnerability row to see DeploymentComponentVulnerabilitiesTable element.

    • Before changes, with constant colSpan={8} prop, see inconsistent colspan="8" attribute of td element, therefore layer has less than available width.
      DeploymentComponentVulnerabilitiesTable_inconsistent

    • After changes, with conditional colSpan={colSpanForDockerfileLayer} prop, consistent colspan="9" attribute of td element, therefore layer has available width.
      DeploymentComponentVulnerabilitiesTable_consistent

Manual testing without Advisory column

  1. Visit /main/vulnerabilities/user-workloads/cves/id with and expand vulnerability row to see ImageComponentVulnerabilitiesTable element.

    • Before and after changes, with conditional colSpan={colSpanForDockerfileLayer} prop, see consistent colspan="5" attribute of td element, therefore layer has available width.
  2. Click Deployments and then expand vulnerability row to see DeploymentComponentVulnerabilitiesTable element.

    • Before and after changes, with conditional colSpan={colSpanForDockerfileLayer} prop, see consistent colspan="8" attribute of td element, therefore layer has available width.

Bonus

  1. Visit /main/vulnerabilities/user-workloads/cves/id with and expand vulnerability row to see ImageComponentVulnerabilitiesTable element.

    • Before changes, with constant colSpan={7} prop, see inconsistent colspan="7" attribute of td element, therefore component table has less than available width.
      AffectedImagesTable_inconsistent

    • After changes, with conditional colSpan={colSpanForComponentVulnerabilitiesTable} prop, consistent colspan="8" attribute of td element, therefore component table has available width.
      AffectedImagesTable_consistent

  2. Click Deployments filter for no matches, and then expand vulnerability row to see DeploymentComponentVulnerabilitiesTable element.

    • Before changes, with incorrect 8 + -hiddenColumnCount prop, see inconsistent colspan="8" attribute of td element, although TbodyFilteredEmpty has available width.
      AffectedDeploymentsTable_inconsistent

    • After changes, with conditional 7 + -hiddenColumnCount prop, see consistent colspan="7" attribute of td element, therefore TbodyFilteredEmpty has available width.
      AffectedDeploymentsTable_consistent

@pedrottimark pedrottimark requested a review from a team as a code owner May 27, 2025 19:50
@pedrottimark pedrottimark requested a review from dvail May 27, 2025 19:50
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @pedrottimark - I've reviewed your changes - here's some feedback:

  • Consider extracting the repeated colSpan calculation logic (base count ± hidden columns ± advisory) into a shared util or hook to reduce duplication across tables.
  • The 8 + -hiddenColumnCount (and similar) expressions are a bit hard to parse—using 8 - hiddenColumnCount would be clearer.
  • Variable names like colSpanForComponentVulnerabilitiesTable vs colSpanForDockerfileLayer could be made more consistent or descriptive (e.g. componentTableColSpan, dockerfileLayerColSpan).
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@rhacs-bot
Copy link
Contributor

Images are ready for the commit at 3ffcd88.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.8.x-821-g3ffcd88b1f.

@codecov
Copy link

codecov bot commented May 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.23%. Comparing base (67d73ad) to head (3ffcd88).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #15453      +/-   ##
==========================================
- Coverage   49.23%   49.23%   -0.01%     
==========================================
  Files        2578     2578              
  Lines      189182   189182              
==========================================
- Hits        93153    93149       -4     
- Misses      88692    88694       +2     
- Partials     7337     7339       +2     
Flag Coverage Δ
go-unit-tests 49.23% <ø> (-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:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@dvail dvail left a comment

Choose a reason for hiding this comment

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

Great catches Mark! I'm contemplating a change to a more descriptor style pattern for table columns in VM, due to the upcoming needs of the dynamic plugin. If we go that route, we can likely determine colSpan in a better way without manual adjustments going forward.

@pedrottimark pedrottimark merged commit b291cbd into master May 28, 2025
86 checks passed
@pedrottimark pedrottimark deleted the ROX-29492-colSpan-Advisory branch May 28, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants