Skip to content

feat: make Repository Pull Requests table columns sortable#283

Merged
anderdc merged 2 commits intoentrius:testfrom
edwin-rivera-dev:feat/repo-prs-table-sortable-columns
Apr 15, 2026
Merged

feat: make Repository Pull Requests table columns sortable#283
anderdc merged 2 commits intoentrius:testfrom
edwin-rivera-dev:feat/repo-prs-table-sortable-columns

Conversation

@edwin-rivera-dev
Copy link
Copy Markdown
Contributor

@edwin-rivera-dev edwin-rivera-dev commented Apr 15, 2026

Summary

On the Repository page's Pull Requests tab, the table columns are now clickable and sortable (PR #, Title, Author, Commits, +/-, Score, Status, Merged). Default sort remains Score desc so the current UX is preserved. Matches the TableSortLabel-based sort pattern already used in RepositoryWeightsTable and LanguageWeightsTable.

What changed

  • Added sortField / sortOrder state with a handleSort toggle that flips asc ↔ desc on the active column and jumps to a sensible default when switching columns (strings default to asc, numbers/dates default to desc).
  • Replaced the hardcoded score-only sort in sortedPRs with a dynamic comparator that handles:
    • numeric fields (pullRequestNumber, commitCount, score, total lines = additions + deletions)
    • string fields (pullRequestTitle, author) via localeCompare
    • mergedAt via new Date().getTime() with unmerged PRs sorting to 0
    • status via a stable rank order (OPEN → MERGED → CLOSED)
  • Wrapped every header cell in <TableSortLabel> so users see MUI's standard arrow indicator on the active column.

No behavior change on initial render (default is still score desc). No new API calls; all sorting is client-side on the already-fetched PR list.

Type of Change

  • Enhancement / UX

Testing

Manual on any repo Pull Requests tab:

  • Default render shows score descending (arrow on Score header)
  • Click a column → rows re-sort, arrow moves to that column
  • Click the same column again → asc/desc flips
  • String columns (Title, Author) default to asc on first click; numeric / date columns default to desc
  • Merged column sorts PRs with mergedAt above the dashed placeholders
  • Status column groups OPEN / MERGED / CLOSED consistently
  • Filter chips (All/Open/Merged/Closed) still work alongside sort

Checklist

  • No new dependencies
  • One file touched
  • Follows the TableSortLabel pattern already used elsewhere in the repo
  • Default sort unchanged (score desc)

Media to upload

2.mp4

Fixes #282

@edwin-rivera-dev
Copy link
Copy Markdown
Contributor Author

@anderdc can you please review my PR and let me know your feedback?

@anderdc anderdc merged commit a45ebf6 into entrius:test Apr 15, 2026
2 checks passed
@anderdc anderdc added feature Net-new functionality enhancement New feature or request and removed feature Net-new functionality labels Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UI] Pull Requests table on Repository page is not sortable

2 participants