Skip to content

Conversation

@divyanshu-vr
Copy link
Contributor

Proposed change

Resolves #1959

Refactored the RepositoriesCard component to use the shared ShowMoreButton component instead of its custom show more/less implementation.

Checklist

  • I've read and followed the contributing guidelines.
  • I've run make check-test locally; all checks and tests passed.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 4, 2025

Summary by CodeRabbit

  • New Features
    • Added the ability to control how many repositories are initially displayed in the repositories card, with a default of 4.
  • Improvements
    • Updated the repositories card to use a streamlined "Show More" button for expanding and collapsing the list.
  • Tests
    • Introduced comprehensive unit tests for the repositories card component.

Walkthrough

The RepositoriesCard component was refactored to use the ShowMoreButton component for toggling repository list visibility. Unused imports were removed, and the toggle logic was delegated to ShowMoreButton. A comprehensive new test suite was added to verify rendering, toggle behavior, and edge cases for the RepositoriesCard component.

Changes

Cohort / File(s) Change Summary
RepositoriesCard Refactor
frontend/src/components/RepositoriesCard.tsx
Refactored to use the ShowMoreButton component for toggling, removed unused imports, and simplified toggle logic.
RepositoriesCard Tests
frontend/__tests__/unit/components/RepositoriesCard.test.tsx
Added comprehensive unit tests covering rendering, toggle behavior, edge cases, and navigation for RepositoriesCard.
RepositoriesCard Usage Update
frontend/src/components/CardDetailsPage.tsx
Added maxInitialDisplay={4} prop when rendering RepositoriesCard to limit initial displayed repositories.
Type Definition Update
frontend/src/types/project.ts
Added optional maxInitialDisplay property to RepositoriesCardProps type.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Refactor RepositoriesCard to use ShowMoreButton (#1959)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related issues

Possibly related PRs

Suggested reviewers

  • arkid15r
  • kasya

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3034460 and 875240a.

📒 Files selected for processing (3)
  • frontend/src/components/CardDetailsPage.tsx (1 hunks)
  • frontend/src/components/RepositoriesCard.tsx (1 hunks)
  • frontend/src/types/project.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • frontend/src/types/project.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/components/RepositoriesCard.tsx
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: adithya-naik
PR: OWASP/Nest#1894
File: frontend/src/components/TopContributorsList.tsx:74-74
Timestamp: 2025-07-28T14:51:14.736Z
Learning: In the OWASP/Nest project, the maintainer adithya-naik prefers not to create separate components for code that's only used in two specific cases, following the YAGNI principle to avoid over-engineering when the duplication is limited and manageable.
📚 Learning: in the detailscard component (frontend/src/components/carddetailspage.tsx), there's a length check b...
Learnt from: ahmedxgouda
PR: OWASP/Nest#1633
File: frontend/src/components/HealthMetrics.tsx:30-30
Timestamp: 2025-06-20T16:12:59.256Z
Learning: In the DetailsCard component (frontend/src/components/CardDetailsPage.tsx), there's a length check before rendering HealthMetrics: `healthMetricsData.length > 0`. This ensures that when HealthMetrics is rendered, the data array has at least one element, making accessing data[0] safe within the HealthMetrics component.

Applied to files:

  • frontend/src/components/CardDetailsPage.tsx
📚 Learning: in the detailscard component (frontend/src/components/carddetailspage.tsx), there's a safety check t...
Learnt from: ahmedxgouda
PR: OWASP/Nest#1633
File: frontend/src/components/HealthMetrics.tsx:30-30
Timestamp: 2025-06-20T16:12:59.256Z
Learning: In the DetailsCard component (frontend/src/components/CardDetailsPage.tsx), there's a safety check that ensures HealthMetrics component is only rendered when healthMetricsData exists and has at least one element: `healthMetricsData && healthMetricsData.length > 0`. This makes accessing data[0] safe within the HealthMetrics component.

Applied to files:

  • frontend/src/components/CardDetailsPage.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: Run backend tests
  • GitHub Check: Run frontend unit tests
🔇 Additional comments (1)
frontend/src/components/CardDetailsPage.tsx (1)

213-213: LGTM! Proper integration of the refactored RepositoriesCard.

The addition of maxInitialDisplay={4} correctly integrates with the refactored RepositoriesCard component that now uses ShowMoreButton for consistent toggle functionality across the site. The value of 4 is appropriate for repositories display and aligns with the PR objective of standardizing the show more/less behavior.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@arkid15r arkid15r enabled auto-merge August 4, 2025 19:06
@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 4, 2025

Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@arkid15r arkid15r added this pull request to the merge queue Aug 4, 2025
Merged via the queue into OWASP:main with commit 438b5a3 Aug 4, 2025
24 checks passed
@divyanshu-vr divyanshu-vr deleted the feature/RefactorRepositoriesCard branch August 4, 2025 21:13
trucodd pushed a commit to trucodd/Nest that referenced this pull request Aug 5, 2025
* Refactored RepositoriesCard

* test update

* Test files Updated

* Update code

---------

Co-authored-by: Divyanshu Verma <[email protected]>
Co-authored-by: Arkadii Yakovets <[email protected]>
Co-authored-by: Arkadii Yakovets <[email protected]>
@coderabbitai coderabbitai bot mentioned this pull request Oct 17, 2025
2 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.

Refactor RepositoriesCard component to use ShowMoreButton

3 participants