Skip to content

Add search functionality to filter Kafka clusters in UI#1894

Open
Akshaya-T wants to merge 1 commit into
kafbat:mainfrom
Akshaya-T:feature/search_clusters
Open

Add search functionality to filter Kafka clusters in UI#1894
Akshaya-T wants to merge 1 commit into
kafbat:mainfrom
Akshaya-T:feature/search_clusters

Conversation

@Akshaya-T

@Akshaya-T Akshaya-T commented Jun 24, 2026

Copy link
Copy Markdown

What changes did you make?

Added a search/filter function in the Kafka UI to let users quickly filter and find Kafka clusters. This change improves usability for users managing multiple clusters by providing real-time search directly in the navigation component.

Key Changes:

  • Backend: Updated api/src/main/java/io/kafbat/ui/service/acl/AclsService.java to support cluster filtering logic.
  • API: Extended api/src/main/resources/static/openapi/kafbat-ui-api.yaml with search/filter request parameters and response definitions.
  • Frontend: Implemented the search UI in frontend/src/components/Nav/Nav.tsx.
  • Styling: Added search input styling in frontend/src/components/Nav/Nav.styled.ts.

Is there anything you'd like reviewers to focus on?

  • Verify the search behavior for cluster names with special characters and unicode.
  • Confirm the API spec changes are backward compatible.
  • Check frontend performance for large cluster lists.
  • Validate ACL service filtering parameters and behavior.

How Has This Been Tested? (put an "x" (case-sensitive!) next to an item)

  • No need to
  • Manually (please, describe, if necessary)
  • Unit checks
  • Integration checks
  • Covered by existing automation

Tested manually by filtering multiple Kafka cluster entries through the navigation search UI and confirming results matched expected cluster names.

Checklist (put an "x" (case-sensitive!) next to all the items, otherwise the build will fail)

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (e.g. ENVIRONMENT VARIABLES)
  • My changes generate no new warnings (e.g. Sonar is happy)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

Summary by CodeRabbit

  • New Features

    • Added search in the sidebar to quickly filter clusters by name.
    • Expanded configuration options for OAuth-based authentication, including additional client and token settings.
  • Bug Fixes

    • ACLs are now listed only for clusters that support the required security feature, avoiding unsupported requests.
  • Documentation

    • Updated the API schema to reflect the new configuration fields.

@Akshaya-T Akshaya-T requested review from a team as code owners June 24, 2026 15:14
@kapybro kapybro Bot added status/triage/manual Manual triage in progress and removed status/triage/manual Manual triage in progress labels Jun 24, 2026
@kapybro

kapybro Bot commented Jun 24, 2026

Copy link
Copy Markdown

AI Summary

The issue describes adding a search function to the Kafka UI that allows users to filter and find Kafka clusters in real time from the navigation component. The implementation includes backend changes to support cluster filtering, API updates to define search parameters, and frontend additions for the UI and styling. Reviewers are asked to focus on search behavior with special characters, API backward compatibility, performance with large cluster lists, and correct ACL service filtering.

@kapybro kapybro Bot changed the title Add search function in the UI to filter kafka clusters Add search functionality to filter Kafka clusters in UI Jun 24, 2026
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Three independent changes: AclsService.listAcls now filters clusters by the AUTHORIZED_SECURITY_ENABLED feature flag before fetching ACLs; the OpenAPI schema gains clientAuthenticationMethod for OAuth2 clients and a schemaRegistryAuth.oauth config block; the Nav sidebar gains a live cluster name search input backed by a new SearchWrapper styled component.

Changes

ACL Listing Feature Gate

Layer / File(s) Summary
AclsService AUTHORIZED_SECURITY_ENABLED gate
api/src/main/java/io/kafbat/ui/service/acl/AclsService.java
Imports ReactiveAdminClient.SupportedFeature and adds a reactive .filter(...) step in listAcls that skips any cluster whose getClusterFeatures() does not contain AUTHORIZED_SECURITY_ENABLED.

OpenAPI OAuth Config Extensions

Layer / File(s) Summary
OAuth2 client and schema registry OAuth schema additions
api/src/main/resources/static/openapi/kafbat-ui-api.yaml
Adds a clientAuthenticationMethod string field to the OAuth2 client config and a new schemaRegistryAuth.oauth nested object with tokenUrl, clientId, clientSecret, scopes, tokenCacheEnabled (default true), tokenRefreshBuffer, and maxRetries (default 1).

Nav Sidebar Cluster Search

Layer / File(s) Summary
Nav cluster filter with SearchWrapper and Search input
frontend/src/components/Nav/Nav.styled.ts, frontend/src/components/Nav/Nav.tsx
Adds a SearchWrapper styled div with fixed padding, introduces search state and a filteredClusters derivation by case-insensitive name matching, renders a Search input conditionally when clusters are loaded, and maps the sidebar list over filteredClusters.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • kafbat/kafka-ui#1812: Adds backend support for clientAuthenticationMethod in OAuth2 client config, directly overlapping with the new clientAuthenticationMethod OpenAPI field in this PR.

Suggested labels

type/enhancement

Suggested reviewers

  • Haarolean

🐰 A rabbit hops through the cluster list,
Searching by name — no cluster missed!
ACLs guarded by feature's gate,
OAuth fields added — isn't that great?
Three small leaps, the code stands neat,
Another sprint done, another treat! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main user-facing change: adding cluster search and filtering in the UI.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@kapybro kapybro Bot added area/ux User experiense issues scope/backend Related to backend changes scope/frontend Related to frontend changes type/enhancement En enhancement/improvement to an already existing feature labels Jun 24, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi Akshaya-T! 👋

Welcome, and thank you for opening your first PR in the repo!

Please wait for triaging by our maintainers.

Please take a look at our contributing guide.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/src/components/Nav/Nav.tsx (1)

13-37: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add Nav search behavior tests (filter + no-results).

This PR adds new UI behavior, but current Nav tests shown in frontend/src/components/Nav/__tests__/Nav.spec.tsx:16-42 only cover base rendering. Add search filtering cases to lock behavior.

🧪 Suggested test additions
+it('filters clusters by search query', () => {
+  renderComponent([onlineClusterPayload, offlineClusterPayload]);
+  fireEvent.change(screen.getByPlaceholderText('Search clusters...'), {
+    target: { value: onlineClusterPayload.name },
+  });
+  expect(screen.getByText(onlineClusterPayload.name)).toBeInTheDocument();
+  expect(screen.queryByText(offlineClusterPayload.name)).not.toBeInTheDocument();
+});
+
+it('shows no cluster menus when search has no matches', () => {
+  renderComponent([onlineClusterPayload, offlineClusterPayload]);
+  fireEvent.change(screen.getByPlaceholderText('Search clusters...'), {
+    target: { value: '__no_match__' },
+  });
+  expect(screen.queryByText(onlineClusterPayload.name)).not.toBeInTheDocument();
+  expect(screen.queryByText(offlineClusterPayload.name)).not.toBeInTheDocument();
+});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/Nav/Nav.tsx` around lines 13 - 37, Add tests for the
new Nav search behavior in Nav.spec.tsx by covering both filtering and
empty-state cases. Use the Nav component’s search input to verify that typing a
cluster name updates the rendered list to only matching clusters via the
filteredClusters logic, and add a case where the search term matches nothing so
the list renders no cluster items. Keep the existing base rendering tests and
extend them around the Search input and cluster list assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/components/Nav/Nav.tsx`:
- Around line 15-20: The cluster filtering logic in Nav.tsx is checking
search.trim() but still matching names against the untrimmed search value, so
whitespace-padded queries can fail. Update the filteredClusters computation to
use a single trimmed search string for both the truthy check and the includes
comparison, keeping the logic in the Nav component and the search-based filter
consistent.

---

Nitpick comments:
In `@frontend/src/components/Nav/Nav.tsx`:
- Around line 13-37: Add tests for the new Nav search behavior in Nav.spec.tsx
by covering both filtering and empty-state cases. Use the Nav component’s search
input to verify that typing a cluster name updates the rendered list to only
matching clusters via the filteredClusters logic, and add a case where the
search term matches nothing so the list renders no cluster items. Keep the
existing base rendering tests and extend them around the Search input and
cluster list assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a62fd65e-758e-44b6-928a-1eb138578542

📥 Commits

Reviewing files that changed from the base of the PR and between e78f6a6 and 672e6e1.

📒 Files selected for processing (4)
  • api/src/main/java/io/kafbat/ui/service/acl/AclsService.java
  • api/src/main/resources/static/openapi/kafbat-ui-api.yaml
  • frontend/src/components/Nav/Nav.styled.ts
  • frontend/src/components/Nav/Nav.tsx

Comment on lines +15 to +20
const filteredClusters =
clusters.isSuccess && search.trim()
? clusters.data.filter((c) =>
c.name.toLowerCase().includes(search.toLowerCase())
)
: clusters.data;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Trim the search query before matching cluster names.

Line 16 checks search.trim(), but Line 18 matches with untrimmed search, so queries like " prod " can miss valid matches.

💡 Proposed fix
-  const filteredClusters =
-    clusters.isSuccess && search.trim()
+  const normalizedSearch = search.trim().toLowerCase();
+  const filteredClusters =
+    clusters.isSuccess && normalizedSearch
       ? clusters.data.filter((c) =>
-          c.name.toLowerCase().includes(search.toLowerCase())
+          c.name.toLowerCase().includes(normalizedSearch)
         )
       : clusters.data;
📝 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 filteredClusters =
clusters.isSuccess && search.trim()
? clusters.data.filter((c) =>
c.name.toLowerCase().includes(search.toLowerCase())
)
: clusters.data;
const normalizedSearch = search.trim().toLowerCase();
const filteredClusters =
clusters.isSuccess && normalizedSearch
? clusters.data.filter((c) =>
c.name.toLowerCase().includes(normalizedSearch)
)
: clusters.data;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/Nav/Nav.tsx` around lines 15 - 20, The cluster
filtering logic in Nav.tsx is checking search.trim() but still matching names
against the untrimmed search value, so whitespace-padded queries can fail.
Update the filteredClusters computation to use a single trimmed search string
for both the truthy check and the includes comparison, keeping the logic in the
Nav component and the search-based filter consistent.

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

Labels

area/ux User experiense issues scope/backend Related to backend changes scope/frontend Related to frontend changes type/enhancement En enhancement/improvement to an already existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant