Skip to content

NO-JIRA: refactor: Separate custom hooks for re-use#191

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
alanconway:hook-refactor
Feb 13, 2026
Merged

NO-JIRA: refactor: Separate custom hooks for re-use#191
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
alanconway:hook-refactor

Conversation

@alanconway
Copy link
Contributor

  • useNavigateToQuery
  • useDomain

/cc @PeterYurkovich

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Feb 5, 2026
@openshift-ci openshift-ci bot requested a review from PeterYurkovich February 5, 2026 14:41
@openshift-ci-robot
Copy link

@alanconway: This pull request explicitly references no jira issue.

Details

In response to this:

  • useNavigateToQuery
  • useDomain

/cc @PeterYurkovich

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 5, 2026
netobserveAvailable: boolean;
constraint: korrel8r.Constraint;
}> = ({ domains, graph, loggingAvailable, netobserveAvailable, constraint }) => {
}> = ({ graph, loggingAvailable, netobserveAvailable, constraint }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we aren't going to use the domains prop anymore lets remove it from the prop type and not pass it in where the component is used

@alanconway alanconway force-pushed the hook-refactor branch 2 times, most recently from 83d8813 to 91aa6e8 Compare February 7, 2026 01:17
@alanconway
Copy link
Contributor Author

/retest
OOM kill, looks like CI problem

@alanconway alanconway force-pushed the hook-refactor branch 3 times, most recently from cfc6f3b to a092cd4 Compare February 9, 2026 14:32
@alanconway
Copy link
Contributor Author

/retest

Another OOMKill. Added --runInBand to the unit test runner - runs about 3x faster with 10x less memory so hopefully this will fix the proble.

@PeterYurkovich
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 9, 2026
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 13, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

Walkthrough

Refactors domain handling and navigation by introducing hooks (useDomains, useNavigateToQuery), removes domain props from topology and panel components, updates useLocationQuery to derive domains internally, and adds a Makefile all target plus a Jest --logHeapUsage flag.

Changes

Cohort / File(s) Summary
Build config
Makefile, web/package.json
Added phony all target (build-frontend build-backend test-frontend) and .PHONY: all; added --logHeapUsage to Jest test:unit script.
New hooks
web/src/hooks/useDomains.tsx, web/src/hooks/useNavigateToQuery.ts
Added useDomains (builds Domains from Redux alert rules) and useNavigateToQuery (navigates by converting query+constraint to link via domains).
Hook update
web/src/hooks/useLocationQuery.ts
Removed domains parameter; useLocationQuery now calls useDomains() internally and returns the derived query.
Panel component
web/src/components/Korrel8rPanel.tsx
Removed dependency on AlertDomain/allDomains and stopped passing domains to location query and Topology; now uses useLocationQuery/useDomains flow and passes fewer props to Topology.
Topology component
web/src/components/topology/Korrel8rTopology.tsx
Removed domains from public props; replaced local navigation logic with useNavigateToQuery hook; updated imports and component signature accordingly.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
web/src/components/Korrel8rPanel.tsx (1)

245-252: setSearch prop is declared and passed but never consumed.

TopologyProps declares setSearch (Line 249) and it's passed at Line 224, but the Topology component destructures only { result, t, constraint } at Line 252. The prop is silently ignored. Either remove it from the interface and call site, or wire it through if it's still needed downstream.

If it's no longer needed, clean it up:
 interface TopologyProps {
   result?: Result;
   constraint: korrel8r.Constraint;
   t: TFunction;
-  setSearch: (search: Search) => void;
 }

-const Topology: React.FC<TopologyProps> = ({ result, t, constraint }) => {
+const Topology: React.FC<TopologyProps> = ({ result, t, constraint }) => {

And at the call site:

-    <Topology result={result} constraint={search.constraint} t={t} setSearch={setSearch} />
+    <Topology result={result} constraint={search.constraint} t={t} />

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@alanconway
Copy link
Contributor Author

/label qe-approved
Refactor, no change in behavior

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label Feb 13, 2026
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/src/components/Korrel8rPanel.tsx (1)

225-233: ⚠️ Potential issue | 🟡 Minor

domains prop is passed to Topology but never used — dead code from incomplete refactor.

TopologyProps still declares domains (line 254) and Korrel8rPanel still passes it (line 227), but the Topology component destructures only { result, t, constraint } (line 261) — domains is silently ignored. Since Korrel8rTopology now sources domains internally via hooks, this prop should be removed entirely.

Suggested fix
 interface TopologyProps {
-  domains: korrel8r.Domains;
   result?: Result;
   constraint: korrel8r.Constraint;
   t: TFunction;
   setSearch: (search: Search) => void;
 }
   const topologySection = (
     <Topology
-      domains={domains}
       result={result}
       constraint={search.constraint}
       t={t}
       setSearch={setSearch}
     />
   );

And in Korrel8rPanel, the useDomains() call on line 53 is now unused and can also be removed:

-  const domains = useDomains();
   const locationQuery = useLocationQuery();

Note: useLocationQuery already calls useDomains() internally, so there's no need to call it separately in Korrel8rPanel.

Also applies to: 253-261

🧹 Nitpick comments (1)
web/src/hooks/useDomains.tsx (1)

15-18: Duplicate AlertDomain in the domains list.

allDomains (from web/src/korrel8r/all-domains.ts) already contains new AlertDomain(). Spreading it here and then appending another new AlertDomain(alertIDs) creates a duplicate that silently overwrites the first via the Map-based Domains.set. It works, but is misleading and fragile — a future reader (or a change to Domains) might not expect the overwrite.

Consider filtering out the existing AlertDomain to make the intent explicit:

Suggested fix
- () => new Domains(...allDomains, new AlertDomain(alertIDs)),
+ () => new Domains(...allDomains.filter(d => d.name !== 'alert'), new AlertDomain(alertIDs)),

@alanconway
Copy link
Contributor Author

My first coderabbit spanking! Fixed 2 minor issues.
@PeterYurkovich can I get an LGTM?

@openshift-ci
Copy link

openshift-ci bot commented Feb 13, 2026

@alanconway: all tests passed!

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.

@PeterYurkovich
Copy link
Contributor

/lgtm

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

openshift-ci bot commented Feb 13, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alanconway, PeterYurkovich

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:
  • OWNERS [PeterYurkovich,alanconway]

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

@openshift-merge-bot openshift-merge-bot bot merged commit 0577883 into openshift:main Feb 13, 2026
6 checks passed
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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. qe-approved Signifies that QE has signed off on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments