Skip to content

IFC-2346 Display parent prefixes in search anywhere#8632

Draft
gmazoyer wants to merge 4 commits intodevelopfrom
gma-20260317-ifc2346
Draft

IFC-2346 Display parent prefixes in search anywhere#8632
gmazoyer wants to merge 4 commits intodevelopfrom
gma-20260317-ifc2346

Conversation

@gmazoyer
Copy link
Contributor

Why

This is the frontend companion to #8611, which added the parent_prefixes field to the InfrahubSearchAnywhere GraphQL query. That PR delivered the backend query and resolver changes; this PR consumes the new field in the frontend search dialog.

No backend changes in this PR. The backend work is fully contained in #8611.

image

What changed

  • New "Parent Prefixes" section in search anywhere, when the backend returns parent_prefixes (i.e., the search query is a valid IP address or CIDR prefix), a dedicated "Parent Prefixes" group appears above the "Objects" group in the search dialog. When the query is not an IP/CIDR, no section appears. When it is but no containing prefixes exist, an empty state message is shown.
  • Reuses existing NodesOptions component, parent prefix results render with the exact same format as regular search results (same fields, layout, namespace badge, click-to-navigate behavior). NodesOptions was exported from search-nodes.tsx for reuse.
  • GraphQL query extended, parent_prefixes { node { id kind } } added to the SEARCH query in search.ts.
  • Domain type extended, parentPrefixes: Array<ObjectResult> | null added to SearchAnywhereResult in search-anywhere.ts. Maps from parent_prefixes in the API response.
  • E2E tests, Playwright tests covering: IP address search shows parent prefixes, non-IP search does not show the section, clicking a parent prefix navigates to the IPAM detail page.

What stayed the same: all existing search behavior is unchanged. The query hook, debounce, case-sensitivity toggle, "Go to" actions, "Objects" results, and "Documentation" results are untouched.

How to review

Key file: search-parent-prefixes.tsx, follows the same pattern as SearchNodes. The main decision is rendering null when parentPrefixes is null (non-IP query) vs. showing an empty state when it's an empty array (valid IP, no containing prefixes).

NodesOptions export in search-nodes.tsx, changed from const to export const. No logic change.

How to test

# E2E tests (requires running Infrahub instance with seeded test data)
cd frontend/app && npx playwright test tests/e2e/search-parent-prefixes.spec.ts --headed

Manual: open the search dialog (Cmd+K or click the search trigger), type 10.0.0.2, and verify the "Parent Prefixes" section appears above "Objects" with 10.0.0.0/16 and 10.0.0.0/8. Then type atl1 and verify no "Parent Prefixes" section appears.

Impact & rollout

  • Backward compatibility: No breaking changes. If the backend doesn't return parent_prefixes (older backend version), the field is null and the component renders nothing.
  • Performance: No additional API calls. The parent_prefixes field is fetched in the same GraphQL query that already runs for search. SearchParentPrefixes shares the same React Query cache key as SearchNodes (deduplicated request).
  • Deployment notes: Should be deployed after or alongside IFC-2271 IPAM find closes matched prefix for IP/prefix #8611 (backend). Safe to deploy before — the component gracefully handles null.

Checklist

  • Tests added/updated
  • I have reviewed AI generated content

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 092daf4a-6d6d-4033-ab60-f56c51732a43

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@github-actions github-actions bot added group/frontend Issue related to the frontend (React) type/spec A specification for an upcoming change to the project labels Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

group/frontend Issue related to the frontend (React) type/spec A specification for an upcoming change to the project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant