Skip to content

Conversation

@Jakub007d
Copy link

@Jakub007d Jakub007d commented Jan 26, 2026

As described in RHINENG-19549 there is currently bug in the plugin where the severity numbers and links are not showing but the icons are.
As part of the investigation i have noticed that the main issue was with ExternalLink which did not render the text and the link correctly. Changin the ExternalLink to simple a link element seems to have fixed the problem.

Screenshot before fix:
Snímka obrazovky 2026-01-26 o 13 32 11

Screenshot after fix:
Snímka obrazovky 2026-01-26 o 13 37 59

Summary by CodeRabbit

  • Refactor
    • Enhanced link handling in the Insights plugin with improved security attributes for external navigation. Links opening in new tabs now include proper referrer policies. Updated styling to provide clearer visual indication of clickable elements.

✏️ Tip: You can customize this high-level summary in your review settings.

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. component/insights Related to insights plugin needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 26, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 26, 2026

Hi @Jakub007d. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@Jakub007d Jakub007d changed the title fix: fixing severity not showing number of issues [RHINENG-19549] fix: fixing severity not showing number of issues Jan 26, 2026
@Jakub007d Jakub007d marked this pull request as ready for review January 27, 2026 09:21
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 27, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

The changes refactor the LabelComponent in the InsightsPopup component by replacing the ExternalLink-wrapped ChartLabel with an inline HTML anchor element. The href attribute is computed dynamically using optional chaining (props.datum?.id) combined with clusterID. Security attributes target="_blank" and rel="noopener noreferrer" are added to the anchor element. The ChartLabel styling merges existing props.style and introduces cursor: pointer. This modification maintains functional equivalence while removing the dependency on the ExternalLink component. No changes are made to exported or public entity signatures.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately identifies the main fix: replacing ExternalLink with a simple anchor element to resolve the missing severity numbers and links issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@frontend/packages/insights-plugin/src/components/InsightsPopup/index.tsx`:
- Around line 33-49: LabelComponent builds an href using clusterID and
riskSorting[props.datum?.id] which can produce NaN/broken URLs when clusterID or
props.datum?.id is missing; update LabelComponent to validate inputs before
wrapping ChartLabel in an anchor: check that clusterID exists and that
riskSorting[props.datum?.id] yields a finite number (e.g., Number.isFinite) and
only then construct the href and return the <a> wrapper; otherwise return
ChartLabel directly (preserving props and style) so the legend renders without a
broken link. Reference: LabelComponent, clusterID, props.datum?.id, riskSorting,
ChartLabel.
- Around line 33-49: The anchor in LabelComponent wrapping ChartLabel is not
keyboard-focusable because SVG anchors need an explicit tabIndex; update the
returned <a> element used in LabelComponent to include tabIndex={0} alongside
the existing href, target and rel attributes so the legend link becomes
reachable by keyboard and screen readers (keep ChartLabel and its props
unchanged).

Comment on lines 33 to 49
const LabelComponent = ({ clusterID, ...props }) => {
const href = `https://console.redhat.com/openshift/insights/advisor/clusters/${clusterID}?total_risk=${
riskSorting[props.datum?.id] + 1
}`;

return (
<a href={href} target="_blank" rel="noopener noreferrer">
<ChartLabel
{...props}
style={{
...props.style,
fill: 'var(--pf-t--global--text--color--link--default)',
cursor: 'pointer',
}}
/>
</a>
);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Guard link generation when clusterID or datum.id is missing

If either value is absent, riskSorting[props.datum?.id] + 1 becomes NaN, producing a broken URL while the legend still renders. Consider falling back to a non-link label in those cases.

🔧 Suggested fix
 const LabelComponent = ({ clusterID, ...props }) => {
-  const href = `https://console.redhat.com/openshift/insights/advisor/clusters/${clusterID}?total_risk=${
-    riskSorting[props.datum?.id] + 1
-  }`;
+  const riskId = props.datum?.id;
+  const riskIndex = riskId != null ? riskSorting[riskId] : undefined;
+  const totalRisk = Number.isFinite(riskIndex) ? riskIndex + 1 : undefined;
+  const href =
+    clusterID && totalRisk != null
+      ? `https://console.redhat.com/openshift/insights/advisor/clusters/${clusterID}?total_risk=${totalRisk}`
+      : undefined;
 
-  return (
-    <a href={href} target="_blank" rel="noopener noreferrer">
-      <ChartLabel
-        {...props}
-        style={{
-          ...props.style,
-          fill: 'var(--pf-t--global--text--color--link--default)',
-          cursor: 'pointer',
-        }}
-      />
-    </a>
-  );
+  const label = (
+    <ChartLabel
+      {...props}
+      style={{
+        ...props.style,
+        fill: 'var(--pf-t--global--text--color--link--default)',
+        cursor: href ? 'pointer' : undefined,
+      }}
+    />
+  );
+
+  return href ? (
+    <a href={href} target="_blank" rel="noopener noreferrer">
+      {label}
+    </a>
+  ) : (
+    label
+  );
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const LabelComponent = ({ clusterID, ...props }) => {
const href = `https://console.redhat.com/openshift/insights/advisor/clusters/${clusterID}?total_risk=${
riskSorting[props.datum?.id] + 1
}`;
return (
<a href={href} target="_blank" rel="noopener noreferrer">
<ChartLabel
{...props}
style={{
...props.style,
fill: 'var(--pf-t--global--text--color--link--default)',
cursor: 'pointer',
}}
/>
</a>
);
const LabelComponent = ({ clusterID, ...props }) => {
const riskId = props.datum?.id;
const riskIndex = riskId != null ? riskSorting[riskId] : undefined;
const totalRisk = Number.isFinite(riskIndex) ? riskIndex + 1 : undefined;
const href =
clusterID && totalRisk != null
? `https://console.redhat.com/openshift/insights/advisor/clusters/${clusterID}?total_risk=${totalRisk}`
: undefined;
const label = (
<ChartLabel
{...props}
style={{
...props.style,
fill: 'var(--pf-t--global--text--color--link--default)',
cursor: href ? 'pointer' : undefined,
}}
/>
);
return href ? (
<a href={href} target="_blank" rel="noopener noreferrer">
{label}
</a>
) : (
label
);
};
🤖 Prompt for AI Agents
In `@frontend/packages/insights-plugin/src/components/InsightsPopup/index.tsx`
around lines 33 - 49, LabelComponent builds an href using clusterID and
riskSorting[props.datum?.id] which can produce NaN/broken URLs when clusterID or
props.datum?.id is missing; update LabelComponent to validate inputs before
wrapping ChartLabel in an anchor: check that clusterID exists and that
riskSorting[props.datum?.id] yields a finite number (e.g., Number.isFinite) and
only then construct the href and return the <a> wrapper; otherwise return
ChartLabel directly (preserving props and style) so the legend renders without a
broken link. Reference: LabelComponent, clusterID, props.datum?.id, riskSorting,
ChartLabel.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

PatternFly Victory ChartLegend labelComponent documentation

💡 Result:

In PatternFly React Charts, ChartLegend is a wrapper around Victory’s VictoryLegend, so labelComponent is the “pass-through” prop you use to customize how each legend label is rendered. (v4-archive.patternfly.org)

What labelComponent does (for ChartLegend):

  • Type: React.ReactElement<any>
  • Purpose: provide a custom component instance to render each legend label
  • PatternFly will clone your element and supply it props like x, y, style, and text (you can override any of these via props on your component). (v4-archive.patternfly.org)

Where it’s documented:

  • PatternFly charts docs (current site): see Charts → Patterns → ChartLegend (prop table includes labelComponent). (patternfly.org)
  • PatternFly v4 archive page for ChartLegend (includes the same labelComponent description and notes that Victory pass-through props apply). (v4-archive.patternfly.org)

Citations:


🌐 Web query:

Victory ChartLegend custom label component anchor link SVG

💡 Result:

To make legend labels clickable links in Victory / PatternFly ChartLegend, pass a custom labelComponent that renders an SVG <a> wrapping a VictoryLabel (the legend will inject x, y, text, style, events, etc. into your component). PatternFly explicitly documents this approach as “Legend links … using a custom label component.” [1]. Victory’s label-component contract (props like x, y, text, style, events) is documented in Victory’s type/docs. [2][3]

import * as React from "react";
import { VictoryLabel } from "victory";
// PatternFly: import { ChartLegend } from "@patternfly/react-charts/victory";

const LegendLinkLabel: React.FC<any> = (props) => {
  const { datum, text, ...labelProps } = props;

  // Put the URL on each legend datum (e.g. legendData: [{ name, href }])
  const href = datum?.href;
  if (!href) return <VictoryLabel {...labelProps} text={text} />;

  return (
    <a
      href={href}
      target="_blank"
      rel="noopener noreferrer"
      tabIndex={0}                 // keyboard focus
    >
      <VictoryLabel {...labelProps} text={text} />
    </a>
  );
};

// VictoryLegend
// <VictoryLegend data={[{ name: "Cats", href: "/cats" }]} labelComponent={<LegendLinkLabel />} />

// PatternFly ChartLegend
// <ChartLegend data={[{ name: "Cats", href: "/cats" }]} labelComponent={<LegendLinkLabel />} />

Notes:

  • In SVG, anchors can be rendered as <a href="…">…</a> (some environments/libraries historically used xlinkHref, but modern SVG2 uses href).
  • You can also wire onClick/onKeyDown via the events prop Victory passes into the label component (included in labelProps). [2][3]

Sources: PatternFly Legends (“Legend links” via custom label component) [1]; Victory label-component props contract [2][3].

[1] (patternfly.org)
[2] (unpkg.com)
[3] (unpkg.com)

Citations:


🌐 Web query:

SVG foreignObject anchor tag href browser support accessibility

💡 Result:

Browser support (rendering)

  • <foreignObject> is supported in modern Chrome/Edge, Firefox, and Safari, but not supported in Internet Explorer (incl. IE11). [1][2]
  • “Supported” doesn’t mean bug-free: WebKit/Safari has long-running rendering/positioning quirks with <foreignObject> in various scenarios. [4]

<a href> inside <foreignObject> (click/navigation)

  • Inside <foreignObject>, you’re effectively embedding HTML, so an HTML <a href> can work—but only when the SVG is in a “document/DOM” context (inline <svg> in HTML, or embedded via <object>/<iframe>/<embed>). [3]
  • If the SVG is used as an image (<img>, CSS background-image, SVG <image>), browsers often apply “image-context” restrictions (notably JS disabled and other limitations), and interactivity is unreliable/limited compared to document embedding—so don’t depend on <a> inside a <foreignObject> there. [3]

Accessibility (screen readers / keyboard)

  • SVG accessibility support has historically been inconsistent across browser + screen reader pairs; patterns that work in one combo may fail in another. [5][6]
  • For reliable accessible link text, the most robust pattern is usually: keep the SVG decorative (aria-hidden="true") and provide the link’s accessible name via visible text or a visually-hidden text node (rather than depending on SVG/foreignObject internals being announced consistently). [5][6]

Sources

[1] Can I use: SVG element foreignObjecthttps://caniuse.com/mdn-svg_elements_foreignobject
[2] MDN: <foreignObject>https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject
[3] MDN: SVG as an image (restrictions; document vs image context) — https://developer.mozilla.org/en-US/docs/Web/SVG/Guides/SVG_as_an_image
[4] Example of long-running WebKit/Safari <foreignObject> issues — https://stackoverflow.com/questions/61895287/wrong-position-of-video-element-inside-svg-foreignobject-on-safari
[5] TPGi: Using ARIA to enhance SVG accessibility (notes on limited support) — https://www.tpgi.com/using-aria-enhance-svg-accessibility/
[6] Orange accessibility guidelines: Accessible SVG (notes on testing + robust patterns) — https://a11y-guidelines.orange.com/en/articles/accessible-svg/


Add tabIndex={0} to the anchor for keyboard accessibility

The <a> pattern is officially supported by PatternFly/Victory for legend links. However, anchors nested in SVG require an explicit tabIndex to be keyboard-focusable and screen-reader navigable. Add tabIndex={0} alongside the existing href, target, and rel attributes:

Suggested fix:
return (
  <a 
    href={href} 
    target="_blank" 
    rel="noopener noreferrer"
    tabIndex={0}
  >
    <ChartLabel {...props} ... />
  </a>
);

Modern href (not xlinkHref) is correct; SVG link support is solid in evergreen browsers.

🤖 Prompt for AI Agents
In `@frontend/packages/insights-plugin/src/components/InsightsPopup/index.tsx`
around lines 33 - 49, The anchor in LabelComponent wrapping ChartLabel is not
keyboard-focusable because SVG anchors need an explicit tabIndex; update the
returned <a> element used in LabelComponent to include tabIndex={0} alongside
the existing href, target and rel attributes so the legend link becomes
reachable by keyboard and screen readers (keep ChartLabel and its props
unchanged).

@jhadvig
Copy link
Member

jhadvig commented Jan 28, 2026

/ok-to-test

@openshift-ci openshift-ci bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 28, 2026
@Jakub007d
Copy link
Author

/retest

@jhadvig
Copy link
Member

jhadvig commented Jan 28, 2026

Looks like a platform issue
/retest
/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 28, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 28, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Jakub007d, jhadvig

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 28, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 28, 2026

@Jakub007d: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-gcp-console 5700e97 link true /test e2e-gcp-console

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/insights Related to insights plugin lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants