Skip to content

EDM-3777: Filter repositories via the API#630

Open
celdrake wants to merge 1 commit intoflightctl:mainfrom
celdrake:EDM-3777-filter-repos-via-api
Open

EDM-3777: Filter repositories via the API#630
celdrake wants to merge 1 commit intoflightctl:mainfrom
celdrake:EDM-3777-filter-repos-via-api

Conversation

@celdrake
Copy link
Copy Markdown
Collaborator

@celdrake celdrake commented Apr 24, 2026

Filtering by name in Repositories page worked differently to the rest of the pages, since it was done client-side and used fuzzy search.

Now the filtering in Repositories / ResourceSyncs will be done via the API with "contains"

Summary by CodeRabbit

  • Improvements
    • Repository search functionality now processes name filters server-side for more consistent and reliable results
    • Resource sync list search enhanced with server-side name-based filtering capability
    • Search interface updated across repository list and resource sync views to support improved filtering behavior
    • Streamlined search experience with server-side validation and processing

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

Warning

Rate limit exceeded

@celdrake has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 28 minutes and 56 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 28 minutes and 56 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0e6c4dae-0f5c-4af8-935c-fbcac6c9cd26

📥 Commits

Reviewing files that changed from the base of the PR and between b651fb8 and f70f339.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (12)
  • apps/ocp-plugin/package.json
  • apps/standalone/package.json
  • libs/ui-components/package.json
  • libs/ui-components/src/components/Repository/CreateRepository/CreateRepository.tsx
  • libs/ui-components/src/components/Repository/RepositoryDetails/DeleteRepositoryModal.tsx
  • libs/ui-components/src/components/Repository/RepositoryList.tsx
  • libs/ui-components/src/components/Repository/useRepositories.ts
  • libs/ui-components/src/components/ResourceSync/RepositoryResourceSyncList.tsx
  • libs/ui-components/src/components/modals/massModals/MassDeleteRepositoryModal/MassDeleteRepositoryModal.tsx
  • libs/ui-components/src/hooks/useTableTextSearch.ts
  • libs/ui-components/src/utils/query.ts
  • libs/ui-components/src/utils/search.ts

Walkthrough

This pull request removes the fuzzysearch dependency from three packages and refactors search functionality from client-side to server-side filtering. The changes include removing the useTableTextSearch hook and fuzzySeach utility, updating repository and resource-sync queries to accept server-side name filters, and modifying multiple components to use the new filtering approach.

Changes

Cohort / File(s) Summary
Dependency Removals
apps/ocp-plugin/package.json, apps/standalone/package.json, libs/ui-components/package.json
Removes fuzzysearch from runtime dependencies across all three packages.
Search Infrastructure Removal
libs/ui-components/src/utils/search.ts, libs/ui-components/src/hooks/useTableTextSearch.ts
Deletes the fuzzySeach function and removes the entire useTableTextSearch hook that previously performed client-side fuzzy filtering.
Query API Refactor
libs/ui-components/src/utils/query.ts
Updates getResourceSyncsByRepo signature from positional arguments to an object parameter, adding support for optional rsName server-side filter via fieldSelector.
Repository List Server-Side Filtering
libs/ui-components/src/components/Repository/useRepositories.ts, libs/ui-components/src/components/Repository/RepositoryList.tsx
Modifies useRepositories hook to accept optional name parameter and apply server-side filtering; refactors RepositoryList to replace client-side text search with nameSearch state bound to the hook.
Resource Sync Server-Side Filtering
libs/ui-components/src/components/ResourceSync/RepositoryResourceSyncList.tsx, libs/ui-components/src/components/Repository/CreateRepository/CreateRepository.tsx, libs/ui-components/src/components/Repository/RepositoryDetails/DeleteRepositoryModal.tsx, libs/ui-components/src/components/modals/massModals/MassDeleteRepositoryModal/MassDeleteRepositoryModal.tsx
Updates components to pass rsName filter to resource-sync queries and call getResourceSyncsByRepo with the new object-parameter signature; refactors fetchResources and reload functions to accept explicit id parameter.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: migrating repository filtering from client-side fuzzy search to server-side API filtering.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 and usage tips.

Copy link
Copy Markdown

@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)
libs/ui-components/src/components/ResourceSync/RepositoryResourceSyncList.tsx (1)

276-286: ⚠️ Potential issue | 🟡 Minor

Guard ResourceSyncEmptyState when a search filter is active.

Now that nameSearch drives a server-side query, an active search with zero matches will render ResourceSyncEmptyState ("No resource syncs here!") even though the repository may actually contain resource syncs that just don't match the filter. This is also inconsistent with RepositoryList.tsx (line 231), which gates its empty state with !nameSearch. It may additionally collide with the Table's own "no results for the applied filters" state driven by hasFilters/emptyData/clearFilters.

🛠️ Proposed fix
-      {resourceSyncs.length === 0 && (
+      {resourceSyncs.length === 0 && !nameSearch && (
         <ResourceSyncEmptyState
           addResourceSync={
             canCreate
               ? () => {
                   setIsAddRsModalOpen(true);
                 }
               : undefined
           }
         />
       )}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@libs/ui-components/src/components/ResourceSync/RepositoryResourceSyncList.tsx`
around lines 276 - 286, The empty-state component ResourceSyncEmptyState is
rendered even when a nameSearch filter is active; change the render guard so the
empty state only appears when there are zero resourceSyncs AND no active
nameSearch (mirror RepositoryList behavior), i.e. update the condition around
ResourceSyncEmptyState to include !nameSearch while keeping the existing
canCreate -> setIsAddRsModalOpen logic intact so the addResourceSync prop
remains unchanged.
🧹 Nitpick comments (1)
libs/ui-components/src/utils/query.ts (1)

68-88: Object-parameter refactor looks good; minor note on rsName interpolation.

The new signature is clean and mirrors the repo + optional name contains pattern elsewhere. One small thing to keep in mind: rsName is spliced into a comma-joined fieldSelector without escaping, so a literal comma in rsName would be interpreted as a selector separator by the API. TableTextSearch only strips whitespace, not commas. Not blocking given resource-sync names shouldn't contain commas, but worth noting.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libs/ui-components/src/utils/query.ts` around lines 68 - 88,
getResourceSyncsByRepo currently injects rsName directly into the fieldSelector
which treats commas as selector separators; modify the function so you escape
commas in rsName before building the selector (e.g., compute const safeRsName =
rsName.replaceAll(',', '\\,') and use safeRsName in the selectors.push call),
keeping the rest of the URLSearchParams logic unchanged; this ensures commas in
the provided rsName are treated literally when constructing the fieldSelector.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@libs/ui-components/src/components/ResourceSync/RepositoryResourceSyncList.tsx`:
- Around line 276-286: The empty-state component ResourceSyncEmptyState is
rendered even when a nameSearch filter is active; change the render guard so the
empty state only appears when there are zero resourceSyncs AND no active
nameSearch (mirror RepositoryList behavior), i.e. update the condition around
ResourceSyncEmptyState to include !nameSearch while keeping the existing
canCreate -> setIsAddRsModalOpen logic intact so the addResourceSync prop
remains unchanged.

---

Nitpick comments:
In `@libs/ui-components/src/utils/query.ts`:
- Around line 68-88: getResourceSyncsByRepo currently injects rsName directly
into the fieldSelector which treats commas as selector separators; modify the
function so you escape commas in rsName before building the selector (e.g.,
compute const safeRsName = rsName.replaceAll(',', '\\,') and use safeRsName in
the selectors.push call), keeping the rest of the URLSearchParams logic
unchanged; this ensures commas in the provided rsName are treated literally when
constructing the fieldSelector.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bacd6e19-bcdc-4a1b-9cbf-d8ba19934f76

📥 Commits

Reviewing files that changed from the base of the PR and between fc240a7 and b651fb8.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (12)
  • apps/ocp-plugin/package.json
  • apps/standalone/package.json
  • libs/ui-components/package.json
  • libs/ui-components/src/components/Repository/CreateRepository/CreateRepository.tsx
  • libs/ui-components/src/components/Repository/RepositoryDetails/DeleteRepositoryModal.tsx
  • libs/ui-components/src/components/Repository/RepositoryList.tsx
  • libs/ui-components/src/components/Repository/useRepositories.ts
  • libs/ui-components/src/components/ResourceSync/RepositoryResourceSyncList.tsx
  • libs/ui-components/src/components/modals/massModals/MassDeleteRepositoryModal/MassDeleteRepositoryModal.tsx
  • libs/ui-components/src/hooks/useTableTextSearch.ts
  • libs/ui-components/src/utils/query.ts
  • libs/ui-components/src/utils/search.ts
💤 Files with no reviewable changes (5)
  • libs/ui-components/package.json
  • apps/standalone/package.json
  • apps/ocp-plugin/package.json
  • libs/ui-components/src/utils/search.ts
  • libs/ui-components/src/hooks/useTableTextSearch.ts

@celdrake celdrake force-pushed the EDM-3777-filter-repos-via-api branch from b651fb8 to f70f339 Compare April 24, 2026 10:21
Comment on lines +48 to +54
const prevNameRef = React.useRef(name);
React.useEffect(() => {
if (prevNameRef.current !== name) {
prevNameRef.current = name;
setCurrentPage(1);
}
}, [name, setCurrentPage]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why are you using name Ref ? Would this be sufficient ?

Suggested change
const prevNameRef = React.useRef(name);
React.useEffect(() => {
if (prevNameRef.current !== name) {
prevNameRef.current = name;
setCurrentPage(1);
}
}, [name, setCurrentPage]);
React.useEffect(() => {
setCurrentPage(1);
}, [name, setCurrentPage]);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The only difference is that with the ref we avoid a re-render in the first mount.
I can remove it, since it's not very clear in any case.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants