Skip to content

Hide Contribution activity when no contributions exist#3314

Merged
kasya merged 2 commits intoOWASP:mainfrom
udaykiran243:fix-hide-zero-contributions
Jan 13, 2026
Merged

Hide Contribution activity when no contributions exist#3314
kasya merged 2 commits intoOWASP:mainfrom
udaykiran243:fix-hide-zero-contributions

Conversation

@udaykiran243
Copy link
Contributor

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

  • Added a guard condition so ContributionStats and ContributionHeatmap render only when contribution data exists and total contributions > 0.
  • Applied the same logic consistently to both Project and Chapter entities.
  • Preserved the existing layout, styles, and component structure.
  • No changes were made to fetching logic, data models, or APIs.

What was NOT changed

  • Project Details, Summary, Leaders, Statistics, Repositories, Health Metrics, and all other sections remain unchanged.
  • Entities with valid contribution data continue to display the Contribution Activity exactly as before.
  • No visual or behavioral changes were introduced outside the Contribution Activity section.

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

image

After

image

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 12, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Fixed contributions section visibility to display only when actual contributions exist, preventing empty contribution blocks on the card details page.

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

Walkthrough

Adds a local hasContributions boolean in CardDetailsPage and changes the contributions section to render only when contributionStats.total > 0 or contributionData is non-empty, replacing the previous inline conditional.

Changes

Cohort / File(s) Summary
Contribution Rendering Logic
frontend/src/components/CardDetailsPage.tsx
Introduced hasContributions (true if contributionStats.total > 0 or contributionData is a non-empty object) and replaced the prior inline conditional with a gate that renders the contributions block only when hasContributions is true.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • arkid15r
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: hiding the Contribution activity section when there are no contributions.
Description check ✅ Passed The description is well-detailed and clearly related to the changeset, explaining what was changed, why it was changed, and providing screenshots to demonstrate the improvement.
Linked Issues check ✅ Passed The code changes meet the objective from issue #3262: adding a hasContributions guard condition to prevent rendering Contribution Activity when there are zero contributions.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue #3262 objective; the modifications only affect the Contribution Activity section's rendering logic without changing unrelated components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5dcc11d and 12700be.

📒 Files selected for processing (1)
  • frontend/src/components/CardDetailsPage.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/components/CardDetailsPage.tsx

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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 318d333 and 5dcc11d.

📒 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 hasContributions guard correctly prevents the entire Contribution Activity section from rendering when there are no contributions. The inner null checks remain appropriate since hasContributions can be true from either contributionStats or contributionData independently. This pattern aligns well with similar guards elsewhere in the component (e.g., healthMetricsData.length > 0 for HealthMetrics). Based on learnings, this follows the established pattern in this codebase.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 12, 2026
@sonarqubecloud
Copy link

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.

@udaykiran243 Hi! Thanks for working on this. I liked your solution the most 👍🏼

@udaykiran243
Copy link
Contributor Author

@kasya Thank you so much! 😊 I’m glad you liked the solution—happy to make any further improvements if needed.

Merged via the queue into OWASP:main with commit 8ef055b Jan 13, 2026
27 checks passed
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.

Do not show contribution heatmap for 0 contribution chapters/projects

2 participants