Skip to content

Fixed issue: 1082 Fixing the top contributors card to make it similar to recent issues card.#1137

Merged
arkid15r merged 4 commits intoOWASP:mainfrom
KaranNegi20Feb:fix-topc
Mar 20, 2025
Merged

Fixed issue: 1082 Fixing the top contributors card to make it similar to recent issues card.#1137
arkid15r merged 4 commits intoOWASP:mainfrom
KaranNegi20Feb:fix-topc

Conversation

@KaranNegi20Feb
Copy link
Contributor

Fixed Issues:#1082
The Links in top contributors of home page does not redirect to the correct URL and fixing expandable clicking area.

Changes made:
make the entire highlighted contributor card area clickable (link to OWASP Nest user details page)
show just a project name (no link) on the main page while keeping the contribution count on the project details page
have the link the same style as with recent issues / recent releases for both main/project details page

Screen.Recording.2025-03-18.at.6.10.23.AM.mov
Screen.Recording.2025-03-18.at.6.10.42.AM.mov

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2025

Summary by CodeRabbit

  • New Features
    • Enhanced the display of top contributors across the app.
    • The Home page now initially shows more contributors, with clear differentiation between types (e.g., company vs. contributor).
    • Refined the contributor section styling with improved text formatting, smaller avatars, and updated grid spacing for a more polished, user-friendly experience.

Walkthrough

This pull request updates both test and component files to revise how contributor details are rendered and verified. In tests, the "Top Contributors" section now focuses on visibility checks for text elements, and contributor identifiers have been updated from "user1" to "Contributor 1". In the components, the TopContributors component has been modified to accept a new type prop for categorizing contributors, and the initial contributor display count on the Home page has been increased from 6 to 9.

Changes

File(s) Change Summary
frontend/__tests__/e2e/pages/Home.spec.ts Refactored the "Top Contributors" test to focus on visibility checks for text elements; removed click and link action tests.
frontend/__tests__/unit/pages/ChapterDetails.test.tsx,
frontend/__tests__/unit/pages/CommitteeDetails.test.tsx
Updated test data and assertions to change the contributor identifier from "user1" to "Contributor 1".
frontend/src/components/CardDetailsPage.tsx,
frontend/src/components/ToggleContributors.tsx
Introduced a new type prop to the TopContributors component; modified internal logic and layout for contributor rendering.
frontend/src/pages/Home.tsx Increased the maxInitialDisplay value in TopContributors from 6 to 9 and added a new type prop with the value "company".

Suggested reviewers

  • kasya
  • arkid15r
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
frontend/src/components/ToggleContributors.tsx (1)

1-78: Consider renaming the component file to match its exported component name

The file is named ToggleContributors.tsx but exports a component called TopContributors. This might lead to confusion for developers working on the codebase.

Consider renaming the file to TopContributors.tsx to match the exported component name for better code organization and clarity.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bf6ccb7 and 0a8391d.

📒 Files selected for processing (6)
  • frontend/__tests__/e2e/pages/Home.spec.ts (1 hunks)
  • frontend/__tests__/unit/pages/ChapterDetails.test.tsx (2 hunks)
  • frontend/__tests__/unit/pages/CommitteeDetails.test.tsx (2 hunks)
  • frontend/src/components/CardDetailsPage.tsx (1 hunks)
  • frontend/src/components/ToggleContributors.tsx (2 hunks)
  • frontend/src/pages/Home.tsx (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
frontend/src/components/ToggleContributors.tsx (1)
frontend/src/types/contributor.ts (1) (1)
  • TopContributorsTypeGraphql (8:15)
🔇 Additional comments (9)
frontend/__tests__/unit/pages/ChapterDetails.test.tsx (1)

90-90: LGTM! Contributor naming consistency update.

The change from 'user1' to 'Contributor 1' improves naming clarity and consistency across tests.

Also applies to: 103-103

frontend/__tests__/unit/pages/CommitteeDetails.test.tsx (1)

83-83: LGTM! Consistent naming update aligned with other test files.

The change from 'user1' to 'Contributor 1' maintains consistency with the updates in ChapterDetails.test.tsx.

Also applies to: 97-97

frontend/src/components/CardDetailsPage.tsx (1)

90-100: Good implementation of the contributor details rendering.

The addition of the renderDetails prop enables displaying contribution counts in a standardized format, addressing the PR objective to make styling consistent with recent issues and releases sections.

frontend/__tests__/e2e/pages/Home.spec.ts (1)

52-56: Improved test structure for top contributors.

The updated test now properly verifies the visibility of contributor elements through a structured parent element reference, which better aligns with the component changes. This approach is more robust and maintainable.

frontend/src/pages/Home.tsx (1)

252-262: Good improvement to the Top Contributors component

The changes successfully address PR objective #1082 by making the contributor cards consistent with the recent issues card. The increased maxInitialDisplay value (from 6 to 9) provides better visibility of contributors on the main page.

I like how the project name is now displayed in a standardized way, matching the pattern used for recent issues and releases.

frontend/src/components/ToggleContributors.tsx (4)

4-5: Good addition of necessary imports

The addition of JSX type from React and the capitalize utility function are appropriate for the component's enhanced functionality.


14-14: New prop enhances component flexibility

The addition of the renderDetails prop properly addresses the PR objectives by allowing customized content rendering for each contributor. The type definition is well-structured and matches the component's usage in Home.tsx.

Also applies to: 20-20


37-37: Improved responsive grid layout

The updated grid layout with gap-x-5 sm:grid-cols-2 md:grid-cols-3 provides better spacing and responsiveness, matching the styling of other card components on the page.


38-54: Well-implemented clickable contributor cards

The changes successfully implement the main objective of making the entire contributor card clickable (via the button wrapper) while maintaining a clean, structured layout. The use of:

  • A test ID (data-testid="top-contributor") improves testability
  • Properly structured nested divs for layout
  • Capitalized names for consistent display
  • Text overflow handling with overflow-hidden text-ellipsis whitespace-nowrap
  • The renderDetails function to display custom content

All work together to create a more consistent and user-friendly experience.

@KaranNegi20Feb
Copy link
Contributor Author

Hey @KaranNegi20Feb can you please review the PR.
Thank you for guiding.

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.

You still don't run what is suggested to run locally 🤷‍♂️

Please also don't close and open new PRs for the same issue -- we can work fine within the same PR.

<button
key={index}
className="flex cursor-pointer items-center space-x-3 rounded-lg p-3 hover:bg-gray-200 dark:hover:bg-gray-700"
data-testid="top-contributor"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't use it in the app code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok ill change that

Copy link
Contributor Author

@KaranNegi20Feb KaranNegi20Feb Mar 19, 2025

Choose a reason for hiding this comment

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

Screenshot 2025-03-19 at 6 55 16 AM

Well i did that because it actually fails on the sonarqubecloud.
If you have any suggestions regarding this @arkid15r to guide me through that would be helpful 😊, Thank you.

Copy link
Contributor Author

@KaranNegi20Feb KaranNegi20Feb Mar 19, 2025

Choose a reason for hiding this comment

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

Screenshot 2025-03-19 at 6 59 02 AM

Upon reviewing the code I also saw this particular way is being used in the production code(main branch) aswell, that is why i opted for that 🥲

Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be cleaned up. It's literally the single occurrence. Would you like to address it either here or in a separate issue?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can ignore SonarQube suggestions.

@KaranNegi20Feb KaranNegi20Feb requested a review from arkid15r March 19, 2025 14:52
<TopContributors contributors={topContributors} maxInitialDisplay={6} />
<TopContributors
contributors={topContributors}
renderDetails={(item) => (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would passing just {item.contributionsCount} contributions be enough here?

Copy link
Contributor Author

@KaranNegi20Feb KaranNegi20Feb Mar 19, 2025

Choose a reason for hiding this comment

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

Yes, since we just want to show the contribution numbers by the top contributors in the projects page

Screenshot 2025-03-19 at 10 30 24 PM

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you move the rest (template) inside of the TopContributors component while using the actual content/value for props?

<button
key={index}
className="flex cursor-pointer items-center space-x-3 rounded-lg p-3 hover:bg-gray-200 dark:hover:bg-gray-700"
data-testid="top-contributor"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be cleaned up. It's literally the single occurrence. Would you like to address it either here or in a separate issue?

<button
key={index}
className="flex cursor-pointer items-center space-x-3 rounded-lg p-3 hover:bg-gray-200 dark:hover:bg-gray-700"
data-testid="top-contributor"
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can ignore SonarQube suggestions.

@KaranNegi20Feb
Copy link
Contributor Author

Yeah we can go ahead and create a new issue for that since I haven't tested that part much yet.

@KaranNegi20Feb KaranNegi20Feb marked this pull request as draft March 20, 2025 00:41
@KaranNegi20Feb KaranNegi20Feb marked this pull request as ready for review March 20, 2025 11:14
@KaranNegi20Feb KaranNegi20Feb requested a review from arkid15r March 20, 2025 11:14
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
frontend/src/components/ToggleContributors.tsx (2)

14-20: Consider using a union type for type prop for better type safety.

The type prop currently uses a generic string type. For better type safety and developer experience, consider using a union type to restrict the possible values.

-  type: string
+  type: 'contributor' | 'company'

This would prevent passing invalid values and provide better IDE autocompletion.


38-61: Improved UX with clickable contributor cards and conditional rendering.

Making the entire card clickable as a button element improves user experience by providing a larger click target, which aligns with the PR objectives. The conditional rendering based on the type prop enables flexible display of either contribution count or project name.

Consider adding an aria-label to improve accessibility:

<button
  key={index}
  onClick={() => navigate(`/community/users/${item.login}`)}
  className="mb-4 w-full rounded-lg bg-gray-200 p-4 dark:bg-gray-700"
+ aria-label={`View profile of ${capitalize(item.name) || capitalize(item.login)}`}
>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dfd9712 and 1e41ee1.

📒 Files selected for processing (3)
  • frontend/src/components/CardDetailsPage.tsx (1 hunks)
  • frontend/src/components/ToggleContributors.tsx (2 hunks)
  • frontend/src/pages/Home.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/src/pages/Home.tsx
  • frontend/src/components/CardDetailsPage.tsx
🧰 Additional context used
🧬 Code Definitions (1)
frontend/src/components/ToggleContributors.tsx (1)
frontend/src/types/contributor.ts (1) (1)
  • TopContributorsTypeGraphql (8-15)
🔇 Additional comments (3)
frontend/src/components/ToggleContributors.tsx (3)

37-37: Good responsive grid layout improvement.

Changing to a responsive grid layout with multiple columns on larger screens improves space utilization and creates a more visually appealing display.


46-49: Good use of the capitalize utility function.

Using the capitalize utility function for displaying user names ensures consistent text formatting across the application.


53-57: Effective conditional rendering based on context.

The conditional rendering based on the type prop is well-implemented and provides appropriate information in different contexts:

  • For 'contributor' type: Shows contribution count
  • For other types (like 'company'): Shows project name

This matches the PR objective of displaying only the project name without a link on the main page.

@KaranNegi20Feb
Copy link
Contributor Author

Hey @arkid15r, I made the required changes. You can now review the changes. Thank you.

@arkid15r arkid15r enabled auto-merge March 20, 2025 16:24
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

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
5.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@arkid15r arkid15r added this pull request to the merge queue Mar 20, 2025
Merged via the queue into OWASP:main with commit 0ffa994 Mar 20, 2025
17 of 18 checks passed
shdwcodr pushed a commit to shdwcodr/Nest that referenced this pull request Jun 5, 2025
… to recent issues card. (OWASP#1137)

* correction after review

* resolved review

* review corrections

---------

Co-authored-by: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>
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.

The Links in top contributors of home page does not redirect to the correct URL and fixing expandable clicking area.

2 participants