EDM-3868: Reset page to 1 when filters change#664
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (3)
Summary by CodeRabbit
WalkthroughRefactors device pagination/filtering: adds a hook to reset pagination on backend filter changes, exposes a stable filterKey, and simplifies useDevicesPaginated to accept an optional deviceNameFilter; updates DevicesPage and Install Wizard call sites. ChangesDevice Pagination and Filter Management
sequenceDiagram
participant SelectTargetStep
participant SpecificationsStep
participant DevicesPage
participant useDevicesPaginated
participant useResetPaginationOnFilterChange
participant useDevicesEndpoint
SelectTargetStep->>useDevicesPaginated: pass deviceNameFilter
SpecificationsStep->>useDevicesPaginated: call without fleet filter
DevicesPage->>useDevicesPaginated: observe filterKey/onlyDecommissioned
useDevicesPaginated->>useResetPaginationOnFilterChange: notify filter key
useResetPaginationOnFilterChange->>useDevicesPaginated: setCurrentPage(1)
useDevicesPaginated->>useDevicesEndpoint: call with derived textFilters & pagination
useDevicesEndpoint-->>useDevicesPaginated: return devices
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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
`@libs/ui-components/src/components/Device/DevicesPage/useDeviceBackendFilters.ts`:
- Around line 19-26: getSearchParamsQueryKey currently builds a joined string
from searchParams.entries() that can collide when keys/values contain '&' or
'='; update getSearchParamsQueryKey to percent-encode each entry before joining
(e.g., encodeURIComponent on both key and value) or use URLSearchParams
serialization that performs encoding, keep the .map/.sort/.join logic intact but
replace `${key}=${value}` with an encoded pair so filterKey is unambiguous
(refer to function name getSearchParamsQueryKey).
In `@libs/ui-components/src/components/Device/DevicesPage/useDevices.ts`:
- Around line 174-188: useDevicesPaginated now fetches all enrolled devices and
drops the fleetless filter used by the install wizard; restore a fleetless-only
filter by passing a filter flag into useDevicesEndpoint (or include it in the
textFilters) when called from useDevicesPaginated so the API request limits to
fleetless devices. Locate useDevicesPaginated and the useDevicesEndpoint call
and add the fleetless filter (e.g., include a property like fleetless: true or
FilterSearchParams.Fleetless) to the options passed to useDevicesEndpoint (while
preserving existing textFilters and nextContinue) so downstream components (like
SpecificationsStep) can still get only fleetless devices. Ensure you reference
FilterSearchParams.NameOrAlias and keep pagination.nextContinue unchanged.
🪄 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: Enterprise
Run ID: 969d5b83-8095-414f-bcde-68c3194b6c26
📒 Files selected for processing (6)
libs/ui-components/src/components/Catalog/InstallWizard/steps/SelectTargetStep.tsxlibs/ui-components/src/components/Catalog/InstallWizard/steps/SpecificationsStep.tsxlibs/ui-components/src/components/Device/DevicesPage/DevicesPage.tsxlibs/ui-components/src/components/Device/DevicesPage/useDeviceBackendFilters.tslibs/ui-components/src/components/Device/DevicesPage/useDevices.tslibs/ui-components/src/hooks/useTablePagination.ts
Made-with: Cursor
Made-with: Cursor
5238d87 to
4d82bf9
Compare
Fixes filters not returning the expected results when the user was on a page other than page 1.
Fixed for:
useDevicesPaginatedto make the code simpler while keeping all existing functionality)