Skip to content

Add sponsor section component #1536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

M-ayank2005
Copy link
Contributor

This PR adds a contextual sponsor section to the details pages for certain entity types.

Resolves: #1424

Changes Made :

  • Updated DetailsCardProps interface: Added a new key property.
  • Donation URL generation: Created a utility function to format the donation URL based on the entity type.
  • Conditional rendering: The sponsor section is only shown for: Projects , Chapters and Repositories

Sponsor section UI:

  • Includes explanatory text
  • Features a donation button with contextual text based on the entity type

Placement: The sponsor section appears at the bottom of the relevant details pages.

Copy link
Contributor

coderabbitai bot commented May 30, 2025

Summary by CodeRabbit

  • New Features

    • Added a Sponsor Section to detail pages for projects, chapters, and repositories, allowing users to access donation links tailored to each entity.
  • Style

    • Introduced a styled donation button and descriptive sponsor messaging on applicable detail pages.

Summary by CodeRabbit

  • New Features
    • Added a sponsor section to the details card for projects, chapters, and repositories, allowing users to access a donation call-to-action with a direct link.
  • Enhancements
    • Donation links are personalized based on the entity type and title, improving the relevance of the sponsor section.

Walkthrough

A sponsor section was added to the DetailsCard component, conditionally displaying a donation call-to-action for entities of type "project," "chapter," or "repository." The donation URL is dynamically constructed using the entity type, key, and title. The DetailsCardProps interface was updated to include an optional key property.

Changes

File(s) Change Summary
frontend/src/components/CardDetailsPage.tsx Added a sponsor section with conditional rendering and donation URL logic; added key prop.
frontend/src/types/card.ts Updated DetailsCardProps interface to include optional key?: string.

Assessment against linked issues

Objective Addressed Explanation
Implement a Sponsor component, configurable and reused on project/chapter/repository detail pages (#1424)
Donation link should be unique per entity, using correct prefix and title encoding (#1424)
Add sponsor section at the bottom of each relevant details page (#1424)

Suggested reviewers

  • kasya
  • arkid15r

📜 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 02a0108 and 974d9f7.

📒 Files selected for processing (1)
  • frontend/src/components/CardDetailsPage.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/components/CardDetailsPage.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • @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 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

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 generate sequence diagram to generate a sequence diagram of the changes in 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/types/card.ts (1)

43-43: Consider renaming the property to avoid confusion with React's key prop.

While this won't cause technical issues since the prop is destructured in the component, using key as a property name could be confusing since React uses key as a special prop for reconciliation. Consider a more descriptive name like entityKey or identifier.

- key?: string 
+ entityKey?: string 
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 59c8fff and 4fd3b43.

📒 Files selected for processing (2)
  • frontend/src/components/CardDetailsPage.tsx (4 hunks)
  • frontend/src/types/card.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
frontend/src/components/CardDetailsPage.tsx (3)
backend/apps/owasp/graphql/nodes/chapter.py (1)
  • key (49-51)
backend/apps/owasp/graphql/nodes/project.py (1)
  • key (43-45)
backend/apps/github/models/common.py (1)
  • title (35-39)
🔇 Additional comments (5)
frontend/src/components/CardDetailsPage.tsx (5)

12-12: Good addition of Next.js Link import.

The Link import is necessary for the new sponsor section functionality and follows Next.js best practices.


39-39: Parameter addition aligns with interface change.

The key parameter correctly matches the new optional property in DetailsCardProps interface.


52-66: Robust URL construction with proper encoding.

The function correctly handles different entity types and safely encodes the title parameter. The fallback URL ensures functionality even when the key is missing.

The logic appropriately:

  • Provides a fallback donation URL when no key is provided
  • Uses different repository prefixes based on entity type
  • Safely encodes the title to prevent URL issues
  • Constructs query parameters correctly

68-68: Clear conditional logic for sponsor display.

The boolean clearly defines which entity types should show the sponsor section, matching the PR requirements.


223-241: Well-implemented sponsor section with good accessibility.

The sponsor section implementation includes:

  • Proper conditional rendering
  • Accessibility attributes (target="_blank", rel="noopener noreferrer")
  • Responsive styling with dark mode support
  • Dynamic button text based on entity type
  • Appropriate positioning at the bottom of the page

The UI provides a clear call-to-action while maintaining consistency with the existing design system.

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.

Thanks for working on this. You'll need to fix some issues:

@@ -40,6 +40,7 @@ export interface DetailsCardProps {
geolocationData?: GeoLocDataGraphQL | null
heatmap?: JSX.Element
is_active?: boolean
key?: string
Copy link
Collaborator

Choose a reason for hiding this comment

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

@M-ayank2005 You added this new property here, but I don't see any key being passed on any page 🤔
Without it - links don't work as they should.

@kasya
Copy link
Collaborator

kasya commented Jun 1, 2025

Could you also add tests to cover this new component added to project, chapter and repo pages?

@arkid15r arkid15r changed the title updated detailscard component Add sponsor section component Jun 1, 2025
@@ -51,19 +51,16 @@ const DetailsCard = ({
}: DetailsCardProps) => {
const getDonationUrl = () => {
if (!key) return 'https://owasp.org/donate/'
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is still not addressed. No key is present (ever) so all links only direct to https://owasp.org/donate/
You need to update the backend to pass in this data for a key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kasya Will it work as expected just by passing key in DetailsCard props?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@M-ayank2005 depends on what you expect to have in that key 🤔 . But I assume it should.
The thing is - you need to actually work on passing it in in this same PR.

Copy link

@kasya
Copy link
Collaborator

kasya commented Jun 15, 2025

@M-ayank2005 Hi! Any updates here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Sponsor component
2 participants