Skip to content

Add pagination to admin source list pages#103

Merged
mbuckingham74 merged 5 commits intomainfrom
feature/admin-pagination
Dec 2, 2025
Merged

Add pagination to admin source list pages#103
mbuckingham74 merged 5 commits intomainfrom
feature/admin-pagination

Conversation

@mbuckingham74
Copy link
Owner

Summary

  • Add pagination controls (Prev/Next buttons) to all admin source list pages
  • Show 20 sources per page with "Showing X-Y of Z sources" info text
  • Pagination controls appear at both top and bottom of long lists
  • Controls only appear when there's more than one page (no UI clutter for small lists)
  • Works for all source list pages: Active, Disabled, Needs Configuration, and Robots Blocked
  • Uses HTMX for seamless page navigation without full page reload

Test plan

  • Navigate to admin dashboard - verify Active Sources page shows pagination when >20 sources
  • Navigate to Needs Configuration page - verify pagination works
  • Click Next/Prev buttons and verify page changes without full refresh
  • Verify pagination controls disappear when <=20 sources on a page
  • Test on Disabled and Robots Blocked pages if sources exist

🤖 Generated with Claude Code

mbuckingham74 and others added 5 commits December 1, 2025 22:56
- Add pagination controls (Prev/Next) to all admin source list pages
- Show 20 sources per page with "Showing X-Y of Z sources" info
- Pagination appears at both top and bottom of long lists
- Controls only appear when there's more than one page
- Works for Active, Disabled, Needs Configuration, and Robots Blocked pages
- Uses HTMX for seamless page navigation without full page reload

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Code review fixes:
- Create _get_paginated_sources() helper to share pagination logic
- Update mutation endpoints (delete, toggle, mark-disabled, recheck-robots,
  create) to return paginated results instead of unpaginated lists
- Replace hard-coded page size (20) in template with page_size variable
- Add page_size to all GET list endpoint responses

This ensures pagination controls persist after actions like delete/toggle,
and the template will automatically reflect any changes to SOURCES_PER_PAGE.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Address code review feedback on PR #103:
- Thread current page from HX-Current-URL header through mutation
  endpoints (delete, toggle, mark-disabled, recheck-robots) so users
  don't lose their place after actions
- Refactor all four GET list endpoints to use _get_paginated_sources
  helper, ensuring consistent page clamping to prevent invalid ranges
  like "Showing 21-10 of 10"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The HX-Current-URL header contains the browser URL (e.g., /admin) which
never has a page param since pagination doesn't push to browser URL.

Fix by:
- Adding hx-vals='{"page": "{{ page }}"}' to all mutation buttons
  (recheck-robots, delete, mark-disabled, toggle)
- Update _get_current_page_from_request to read from query params
  (DELETE) or form data (POST) where htmx sends hx-vals
- Make mutation endpoints async to await form parsing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@mbuckingham74 mbuckingham74 merged commit d01afe8 into main Dec 2, 2025
@mbuckingham74 mbuckingham74 deleted the feature/admin-pagination branch December 2, 2025 04:45
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.

1 participant