Skip to content

feat: add recent pull requests to public module page#3516

Merged
kasya merged 3 commits intoOWASP:mainfrom
HarshitVerma109:feat/module-pr-card-design
Jan 26, 2026
Merged

feat: add recent pull requests to public module page#3516
kasya merged 3 commits intoOWASP:mainfrom
HarshitVerma109:feat/module-pr-card-design

Conversation

@HarshitVerma109
Copy link
Contributor

Proposed change

Resolves #3380

  • Created a new PullRequestList.tsx component to standardize the PR display.
  • Updated the Public Module Page to show "Recent Pull Requests" using this new component, matching the design of the Issue Detail page.
  • Updated other places (like the Admin Issue page) to also use PullRequestList, ensuring a consistent UI across the application.

Checklist

  • Required: I followed the contributing workflow
  • Required: I verified that my code works as intended and resolves the issue as described
  • Required: I ran make check-test locally: all warnings addressed, tests passed
  • I used AI for code, documentation, tests, or communication related to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2026

Summary by CodeRabbit

Release Notes

  • New Features
    • Added display of recent pull requests on module details pages, showing PR title, author, creation date, and status badge.
    • Added "Show more"/"Show less" toggle to expand and collapse the pull request list (default displays 4 items).

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

This PR introduces a feature to display related pull requests on module view pages. It adds a GraphQL resolver to fetch recent pull requests linked to module issues, creates a new MentorshipPullRequest component to render PR details, updates the CardDetailsPage to conditionally display PRs for modules, and expands GraphQL queries to include PR author information. Tests are added to verify the rendering and expansion behavior.

Changes

Cohort / File(s) Summary
Backend GraphQL Resolver
backend/apps/mentorship/api/internal/nodes/module.py
Adds recent_pull_requests(limit: int = 5) method to ModuleNode that queries linked PullRequest objects via related_issues, selects author, orders by creation date descending, and returns a limited list.
Frontend Component
frontend/src/components/MentorshipPullRequest.tsx
New component rendering pull request details (avatar, title, author, creation date, status badge). Includes getPRStatus() helper function to compute badge styling based on merge/close state.
Frontend Pages
frontend/src/app/mentorship/programs/[programKey]/modules/[moduleKey]/page.tsx, frontend/src/app/my/mentorship/programs/[programKey]/modules/[moduleKey]/issues/[issueId]/page.tsx
First file passes pullRequests prop from GraphQL data to DetailsCard. Second file replaces inline PR rendering with MentorshipPullRequest component and ShowMoreButton toggle.
Frontend Page Component
frontend/src/components/CardDetailsPage.tsx
Adds conditional SecondaryCard rendering for recent pull requests when type is "module" with show-more toggle defaulting to 4 items. Wraps ModuleCard in margin div under specific conditions.
GraphQL Query
frontend/src/server/queries/moduleQueries.ts
Adds recentPullRequests field group to GET_PROGRAM_ADMINS_AND_MODULES query, exposing PR metadata and author details (id, title, url, state, dates, repository info).
Test Suite
frontend/__tests__/unit/components/CardDetailsPage.test.tsx
Adds comprehensive test suite "Module Pull Requests Display" verifying initial render (4 PRs), show-more expansion, collapse behavior, and absence of toggle when PRs ≤ 4. Includes mock PR data generator.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • arkid15r
  • kasya
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding recent pull requests to the public module page. It is concise, specific, and directly reflects the primary objective of the PR.
Description check ✅ Passed The description is related to the changeset, outlining the creation of a new component and updates to pages to display recent PRs. However, the component name mentioned (PullRequestList.tsx) does not match the actual implementation (MentorshipPullRequest.tsx).
Linked Issues check ✅ Passed The PR implements all core requirements from #3380: adds recent_pull_requests resolver to ModuleNode, updates moduleQueries.ts to fetch recentPullRequests, updates CardDetailsPage.tsx to render PRs when type is 'module', and passes pullRequests prop from the public module page.
Out of Scope Changes check ✅ Passed All changes are directly related to the objective of displaying recent pull requests on the public module page. The new component, GraphQL updates, and page modifications are all within scope of issue #3380.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 24, 2026
Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

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

@HarshitVerma109 hi! Left some comments ⬇️

I also found an issue with padding for the new milestone block.

Image

I will push that fix (really tiny) to this PR if you don't mind.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we somehow specify that this is a mentorship view PR list in the name? I can see how this could now be confusing between regular RecentPullRequests component and PullRequestList component.

also, do you think it would make sense for component to be an actual item you're building with a map and not the whole list? 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, it would be good to add a Load more button to this view at some point that would load more PRs - can totally do it in a separate task. I was expecting to see more items initially, since I knew there were way more than 5 PRs open for the label I use.

Just a thought, don't need to add it right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have implemented the 'Show More/Less' toggle. Please let me know if this meets the requirements.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 24, 2026
@HarshitVerma109 HarshitVerma109 requested a review from kasya January 25, 2026 02:40
@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

❌ Patch coverage is 77.50000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.49%. Comparing base (4643156) to head (9e96645).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
frontend/src/components/MentorshipPullRequest.tsx 69.56% 4 Missing and 3 partials ⚠️
[...Key]/modules/[moduleKey]/issues/[issueId]/page.tsx](https://app.codecov.io/gh/OWASP/Nest/pull/3516?src=pr&el=tree&filepath=frontend%2Fsrc%2Fapp%2Fmy%2Fmentorship%2Fprograms%2F%5BprogramKey%5D%2Fmodules%2F%5BmoduleKey%5D%2Fissues%2F%5BissueId%5D%2Fpage.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OWASP#diff-ZnJvbnRlbmQvc3JjL2FwcC9teS9tZW50b3JzaGlwL3Byb2dyYW1zL1twcm9ncmFtS2V5XS9tb2R1bGVzL1ttb2R1bGVLZXldL2lzc3Vlcy9baXNzdWVJZF0vcGFnZS50c3g=) 77.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3516      +/-   ##
==========================================
- Coverage   85.61%   85.49%   -0.13%     
==========================================
  Files         461      462       +1     
  Lines       14254    14260       +6     
  Branches     1905     1900       -5     
==========================================
- Hits        12203    12191      -12     
- Misses       1672     1689      +17     
- Partials      379      380       +1     
Flag Coverage Δ
backend 84.48% <ø> (+<0.01%) ⬆️
frontend 88.27% <77.50%> (-0.47%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...programs/[programKey]/modules/[moduleKey]/page.tsx 100.00% <100.00%> (ø)
frontend/src/components/CardDetailsPage.tsx 87.59% <100.00%> (+0.71%) ⬆️
[...Key]/modules/[moduleKey]/issues/[issueId]/page.tsx](https://app.codecov.io/gh/OWASP/Nest/pull/3516?src=pr&el=tree&filepath=frontend%2Fsrc%2Fapp%2Fmy%2Fmentorship%2Fprograms%2F%5BprogramKey%5D%2Fmodules%2F%5BmoduleKey%5D%2Fissues%2F%5BissueId%5D%2Fpage.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OWASP#diff-ZnJvbnRlbmQvc3JjL2FwcC9teS9tZW50b3JzaGlwL3Byb2dyYW1zL1twcm9ncmFtS2V5XS9tb2R1bGVzL1ttb2R1bGVLZXldL2lzc3Vlcy9baXNzdWVJZF0vcGFnZS50c3g=) 87.28% <77.77%> (+2.79%) ⬆️
frontend/src/components/MentorshipPullRequest.tsx 69.56% <69.56%> (ø)

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4643156...9e96645. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

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

@HarshitVerma109 this looks good 👍🏼 Thank you!

Comment on lines +164 to +173
def recent_pull_requests(self, limit: int = 5) -> list[PullRequestNode]:
"""Return recent pull requests linked to issues in this module."""
issue_ids = self.issues.values_list("id", flat=True)
return list(
PullRequest.objects.filter(related_issues__id__in=issue_ids)
.select_related("author")
.distinct()
.order_by("-created_at")[:limit]
)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@HarshitVerma109 What I meant by Show more button is more like a pagination. Right now the limit is still 5, so at most you'll go from 4 to 5 items when clicking Show more.

The idea is to allow loading more PRs on request from user. This might be a bit more tricky and as I said before we can (and probably should) work on that in a separate task.

@kasya kasya added this pull request to the merge queue Jan 26, 2026
Merged via the queue into OWASP:main with commit a524b2d Jan 26, 2026
35 of 37 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Feb 5, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show related PRs on public module view page

2 participants