Skip to content

EDM-3777: Filter repositories via the API#630

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

EDM-3777: Filter repositories via the API#630
celdrake wants to merge 1 commit into
flightctl: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"

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: aaa2aafa-9e16-4052-82e1-c762a1b23693

📥 Commits

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

⛔ 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/src/utils/search.ts
  • libs/ui-components/src/hooks/useTableTextSearch.ts
  • libs/ui-components/package.json
  • apps/standalone/package.json
  • apps/ocp-plugin/package.json
🚧 Files skipped from review as they are similar to previous changes (6)
  • libs/ui-components/src/components/Repository/RepositoryDetails/DeleteRepositoryModal.tsx
  • libs/ui-components/src/components/Repository/CreateRepository/CreateRepository.tsx
  • libs/ui-components/src/utils/query.ts
  • libs/ui-components/src/components/Repository/useRepositories.ts
  • libs/ui-components/src/components/Repository/RepositoryList.tsx
  • libs/ui-components/src/components/ResourceSync/RepositoryResourceSyncList.tsx

Summary by CodeRabbit

Release Notes

  • Chores

    • Removed fuzzysearch dependency from project packages
  • Bug Fixes

    • Repository list and resource sync filtering now use server-side search for improved performance and accuracy

Walkthrough

This pull request removes the fuzzysearch dependency and client-side fuzzy search hook, refactors getResourceSyncsByRepo to accept an object with optional rsName, and updates repository and resource-sync components to use server-side name filtering.

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 these packages.
Search Infrastructure Removal
libs/ui-components/src/utils/search.ts, libs/ui-components/src/components/*, libs/ui-components/src/hooks/useTableTextSearch.ts
Deletes exported fuzzySeach and removes usages/imports of the useTableTextSearch client-side fuzzy filtering hook across components.
Query API Refactor
libs/ui-components/src/utils/query.ts
Updates commonQueries.getResourceSyncsByRepo signature to ({ repositoryId, rsName, options }) and builds a comma-joined fieldSelector including optional metadata.name contains <rsName>.
Repository List Server-Side Filtering
libs/ui-components/src/components/Repository/useRepositories.ts, libs/ui-components/src/components/Repository/RepositoryList.tsx
useRepositories gains an optional name parameter, resets pagination when name changes, and RepositoryList replaces client-side search with nameSearch bound to the hook.
ResourceSync Server-Side Filtering
libs/ui-components/src/components/ResourceSync/RepositoryResourceSyncList.tsx, libs/ui-components/src/components/modals/*
Introduce nameSearch state, pass rsName into resource-sync fetch endpoint, use server-filtered resourceSyncs for rendering and mass-delete; update modal call sites to the new query shape.
CreateRepository reload refactor & Delete flows
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
Refactor fetchResources/reload to accept explicit id and update calls to getResourceSyncsByRepo to use the object-parameter form ({ repositoryId }).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: migrating repository filtering from client-side fuzzy search to API-based filtering.
Description check ✅ Passed The description explains the context and the change: repository filtering is moved from client-side fuzzy search to API-based filtering with 'contains' matching.
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.


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.

@celdrake celdrake force-pushed the EDM-3777-filter-repos-via-api branch from f70f339 to f550b18 Compare May 19, 2026 08:06
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