Hide Contribution activity when no contributions exist#3314
Hide Contribution activity when no contributions exist#3314kasya merged 2 commits intoOWASP:mainfrom
Conversation
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughAdds a local Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
frontend/src/components/CardDetailsPage.tsx (1)
111-113: Indentation misalignment on continuation lines.The continuation lines (112-113) are indented with 2 spaces instead of aligning with the opening parenthesis or using a consistent 4-space continuation indent. This may cause linting warnings depending on your ESLint/Prettier configuration.
Suggested alignment
const hasContributions = - (contributionStats && contributionStats.total > 0) || - (contributionData && Object.keys(contributionData).length > 0) + (contributionStats && contributionStats.total > 0) || + (contributionData && Object.keys(contributionData).length > 0)
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/src/components/CardDetailsPage.tsx
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: ahmedxgouda
Repo: OWASP/Nest PR: 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.
📚 Learning: 2025-06-20T16:12:59.256Z
Learnt from: ahmedxgouda
Repo: OWASP/Nest PR: 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: 2025-06-20T16:12:59.256Z
Learnt from: ahmedxgouda
Repo: OWASP/Nest PR: 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
🔇 Additional comments (1)
frontend/src/components/CardDetailsPage.tsx (1)
268-294: LGTM!The
hasContributionsguard correctly prevents the entire Contribution Activity section from rendering when there are no contributions. The inner null checks remain appropriate sincehasContributionscan be true from eithercontributionStatsorcontributionDataindependently. This pattern aligns well with similar guards elsewhere in the component (e.g.,healthMetricsData.length > 0for HealthMetrics). Based on learnings, this follows the established pattern in this codebase.
|
kasya
left a comment
There was a problem hiding this comment.
@udaykiran243 Hi! Thanks for working on this. I liked your solution the most 👍🏼
|
@kasya Thank you so much! 😊 I’m glad you liked the solution—happy to make any further improvements if needed. |



Proposed change
Resolves #3262
This PR updates the Project and Chapter details pages to avoid rendering the Contribution Activity section when there are zero contributions.
What was changed
ContributionStatsandContributionHeatmaprenderonly when contribution data exists and total contributions > 0.What was NOT changed
Why this change is needed
Projects or chapters with zero contributions were displaying an empty or misleading Contribution Activity section.
This change improves clarity and UX by showing contribution-related components only when meaningful data is available.
ScreenShots
Before
After
Checklist
make check-testlocally: all warnings addressed, tests passed