Skip to content
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

fix: clickable org if there is any @ text in user bio #951

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

Conversation

jaiakash
Copy link
Contributor

@jaiakash jaiakash commented Feb 27, 2025

Resolves #950

If user bio has any @ text then it will redirect to GitHub.
Screenshot 2025-02-28 at 1 56 25 AM

Signed-off-by: Akash Jaiswal <[email protected]>
Copy link
Contributor Author

@jaiakash jaiakash left a comment

Choose a reason for hiding this comment

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

Added units tests as well.

Copy link

coderabbitai bot commented Mar 1, 2025

Summary by CodeRabbit

  • New Features
    • Enhanced the user profile display by converting GitHub username mentions in the bio into clickable links. The updated bio content now renders interactive links for improved navigation to GitHub profiles.

Walkthrough

The changes update the user bio representation across tests and the component. The bio data in mock files is modified from "This is a test user" to "Test @user". Correspondingly, unit tests now assert the presence of "Test" and "@user" instead of the full original text. The primary component change is in the User Details page, where the bio text is now split into words, and any word starting with "@" is rendered as a clickable link pointing to the corresponding GitHub profile.

Changes

Files Change Summary
frontend/__tests__/unit/data/mockUserDetails.ts
frontend/__tests__/unit/pages/UserDetails.test.tsx
Updated test data and assertions: changed the bio from "This is a test user" to "Test @user" and modified tests to expect separate text fragments "Test" and "@user".
frontend/src/pages/UserDetails.tsx Updated the bio rendering logic to split the bio into words and render words starting with "@" as clickable links directing to the corresponding GitHub profile.

Suggested reviewers

  • 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 25c1c4a and d5d12a7.

📒 Files selected for processing (1)
  • frontend/src/pages/UserDetails.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/pages/UserDetails.tsx
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: CodeQL (python)
  • GitHub Check: Run backend tests
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: Run frontend unit tests
  • GitHub Check: CodeQL (javascript-typescript)

🪧 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

@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: 1

🧹 Nitpick comments (2)
frontend/src/pages/UserDetails.tsx (2)

153-172: Add missing space after mentions.

The implementation successfully makes @ mentions in user bios clickable, which addresses the PR objective. However, there's an inconsistency in spacing when rendering the bio text.

-                          {word}
+                          {word}{' '}

When rendering regular words on line 169, you add a space after each word, but no space is added after mentions. This will cause inconsistent spacing in the rendered output. Adding a space after mentions would maintain consistent spacing throughout the text.


158-166: Enhance accessibility for mention links.

Add an aria-label to the mention links to improve accessibility for screen readers.

                        <Link
                          key={index}
                          href={`https://github.com/${word.substring(1)}`}
                          target="_blank"
                          rel="noopener noreferrer"
+                          aria-label={`${word.substring(1)}'s GitHub profile`}
                          className="text-blue-500 hover:underline"
                        >
                          {word}
                        </Link>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 126b0b1 and 658aa7e.

📒 Files selected for processing (3)
  • frontend/__tests__/unit/data/mockUserDetails.ts (1 hunks)
  • frontend/__tests__/unit/pages/UserDetails.test.tsx (1 hunks)
  • frontend/src/pages/UserDetails.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • frontend/tests/unit/data/mockUserDetails.ts
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: CodeQL (python)
  • GitHub Check: Run backend tests
  • GitHub Check: CodeQL (javascript-typescript)
  • GitHub Check: Run frontend unit tests
  • GitHub Check: Run frontend e2e tests
🔇 Additional comments (1)
frontend/__tests__/unit/pages/UserDetails.test.tsx (1)

75-76: LGTM - Test assertions match updated functionality.

The updated test assertions correctly verify the presence of both parts of the bio text ("Test" and "@user") in the rendered component, which aligns with the changes made to make @ mentions clickable in the UserDetails component.

@arkid15r arkid15r requested a review from aramattamara March 1, 2025 04:49
{user.bio && <p className="text-lg text-gray-700 dark:text-gray-300">{user.bio}</p>}
{user.bio && (
<p className="text-lg text-gray-700 dark:text-gray-300">
{user.bio.split(' ').map((word, index) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If there's a dot after the link like in this example - the dot is added to the link, which makes it a 404.
Screenshot 2025-03-01 at 5 58 41 PM
There could also be a ;!? or any other thing like that.
Could you fix this?

jaiakash and others added 2 commits March 2, 2025 10:19
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@jaiakash jaiakash requested a review from kasya March 2, 2025 04:53
{user.bio && (
<p className="text-lg text-gray-700 dark:text-gray-300">
{user.bio.split(' ').map((word, index) => {
const mentionMatch = word.match(/^@(\w+)/)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This works for the link but it still shows the dot highlighted in the UI. You should be able to fix that by updating both regexes here and at the top. The taking out the correct group item.
Also, could we move this logic out of the template? It's getting messy.
Screenshot 2025-03-02 at 9 56 30 AM

Copy link

sonarqubecloud bot commented Mar 3, 2025

@jaiakash
Copy link
Contributor Author

jaiakash commented Mar 3, 2025

Screenshot 2025-03-03 at 10 14 47 PM

here is the final version

  • removes dot if its present at last of username/org name
  • decouple the logic outside the UI code

@jaiakash jaiakash requested a review from kasya March 3, 2025 16:46
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.

Adding clickable links for user bio
2 participants