Skip to content

Conversation

@abhayymishraa
Copy link
Collaborator

@abhayymishraa abhayymishraa commented Apr 13, 2025

Resolves #1349

Add the PR description here.

  • Added repository Name
  • Added Tooltip for avatars
  • Fixed testcase

image

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 13, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced the GraphQL API to include repository names for issues and pull requests.
    • Updated the user interface to showcase repository details—now replacing comment counts and certain author details—with tooltips and direct links.
  • Tests

    • Revised unit and end-to-end tests to ensure the correct display of repository information across issues, pull requests, and releases.

Walkthrough

This set of changes updates the backend GraphQL schema and frontend components to expose a new repository_name (or repositoryName) field. In the GraphQL nodes and queries, the field and its resolver have been introduced or updated. In the frontend, UI components now display the repository name (often as a clickable link) instead of author or comments count details, and tooltips have been added for avatar hover events. Corresponding type definitions and tests (unit and end-to-end) have been revised to validate these updates.

Changes

Files Change Summaries
backend/apps/github/graphql/nodes/issue.py, backend/apps/github/graphql/nodes/pull_request.py Added new field (repository_name/repository_name = graphene.String()) and resolver methods to expose repository name in GraphQL nodes.
frontend/src/server/queries/{home, organization, project, user, repository}Queries.ts Updated GraphQL queries: added/reordered fields, introduced repositoryName, and replaced commentsCount where applicable.
frontend/src/{app,components}/**/*.tsx Modified UI components to display the repository name as a link, removed author/comment-related displays, and wrapped avatar elements with a tooltip for hover details.
frontend/src/types/{project,user}.ts; backend/tests/**; frontend/__tests__/** Revised type definitions to include an optional repositoryName property and updated tests/mocks to verify repository name display instead of previous comment or author information.

Assessment against linked issues

Objective Addressed Explanation
Show repository name with a link in all components and display the author's name on hover (#1349)

Possibly related PRs


📜 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 3f302c8 and d3f2342.

📒 Files selected for processing (10)
  • frontend/__tests__/e2e/pages/ProjectDetails.spec.ts (1 hunks)
  • frontend/__tests__/e2e/pages/RepositoryDetails.spec.ts (1 hunks)
  • frontend/__tests__/e2e/pages/UserDetails.spec.ts (2 hunks)
  • frontend/__tests__/unit/data/mockProjectDetailsData.ts (1 hunks)
  • frontend/__tests__/unit/data/mockRepositoryData.ts (1 hunks)
  • frontend/__tests__/unit/data/mockUserDetails.ts (2 hunks)
  • frontend/__tests__/unit/pages/ProjectDetails.test.tsx (1 hunks)
  • frontend/__tests__/unit/pages/RepositoryDetails.test.tsx (1 hunks)
  • frontend/__tests__/unit/pages/UserDetails.test.tsx (1 hunks)
  • frontend/src/app/members/[memberKey]/page.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
  • frontend/tests/e2e/pages/ProjectDetails.spec.ts
  • frontend/tests/e2e/pages/RepositoryDetails.spec.ts
  • frontend/tests/unit/data/mockProjectDetailsData.ts
  • frontend/tests/unit/pages/RepositoryDetails.test.tsx
  • frontend/tests/unit/pages/UserDetails.test.tsx
  • frontend/tests/unit/pages/ProjectDetails.test.tsx
  • frontend/tests/unit/data/mockUserDetails.ts
  • frontend/tests/unit/data/mockRepositoryData.ts
  • frontend/tests/e2e/pages/UserDetails.spec.ts
  • frontend/src/app/members/[memberKey]/page.tsx
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Run frontend unit tests
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: Run backend tests

🪧 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 plan to trigger planning for file edits and PR creation.
  • @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 (4)
frontend/src/types/user.ts (1)

89-99: Consider adding repositoryName to ItemCardPullRequests interface

For consistency with the PullRequestsType interface, you might want to consider adding the repositoryName property to the ItemCardPullRequests interface as well, especially if both interfaces represent similar data used in different contexts.

export interface ItemCardPullRequests {
  createdAt: string
  title: string
  author: {
    login: string
    avatarUrl: string
    key: string
    name: string
  }
  url: string
+  repositoryName?: string
}
frontend/src/types/project.ts (1)

87-100: Consider consistency in property optionality

I noticed that ProjectReleaseType already has a non-optional repositoryName property, while the newly added property in ProjectIssuesType is optional. If this is intentional (perhaps releases always have a repository name, while issues might not), that's fine. Otherwise, consider making the optionality consistent across similar types.

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

27-37: Simplify redundant conditional check.

The repository name display is implemented well, showing the repository name with an icon and making it a clickable link. However, there's a redundant conditional check in the link href.

  {item?.repositoryName && (
    <div className="item-center flex">
      <FontAwesomeIcon icon={faFileCode} className="ml-4 mr-2 h-4 w-4" />
      <Link
        className="text-gray-600 hover:underline dark:text-gray-400"
-       href={`/repositories/${item?.repositoryName ? item.repositoryName.toLowerCase() : ''}`}
+       href={`/repositories/${item.repositoryName.toLowerCase()}`}
      >
        <span>{item.repositoryName}</span>
      </Link>{' '}
    </div>
  )}

The redundant check is unnecessary since we're already inside a conditional block that confirms item?.repositoryName exists.

backend/apps/github/graphql/nodes/issue.py (1)

25-27: Consider adding a null check to the resolver.

The resolver implementation correctly retrieves the repository name. However, consider adding a null check to handle edge cases where the repository might be None.

def resolve_repository_name(self, info):
    """Resolve the repository name."""
-   return self.repository.name
+   return self.repository.name if self.repository else None

While this is likely an edge case, adding the null check would make the code more robust.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 09de2e9 and 6bdc85d.

📒 Files selected for processing (14)
  • backend/apps/github/graphql/nodes/issue.py (2 hunks)
  • backend/apps/github/graphql/nodes/pull_request.py (2 hunks)
  • frontend/src/app/members/[memberKey]/page.tsx (3 hunks)
  • frontend/src/app/page.tsx (1 hunks)
  • frontend/src/components/ItemCardList.tsx (3 hunks)
  • frontend/src/components/RecentIssues.tsx (2 hunks)
  • frontend/src/components/RecentPullRequests.tsx (3 hunks)
  • frontend/src/components/RecentReleases.tsx (2 hunks)
  • frontend/src/server/queries/homeQueries.ts (2 hunks)
  • frontend/src/server/queries/organizationQueries.ts (2 hunks)
  • frontend/src/server/queries/projectQueries.ts (1 hunks)
  • frontend/src/server/queries/userQueries.ts (1 hunks)
  • frontend/src/types/project.ts (1 hunks)
  • frontend/src/types/user.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (6)
frontend/src/components/RecentReleases.tsx (1)
frontend/src/types/link.ts (1)
  • Link (1-6)
frontend/src/components/RecentIssues.tsx (1)
frontend/src/types/link.ts (1)
  • Link (1-6)
frontend/src/components/ItemCardList.tsx (1)
frontend/src/types/link.ts (1)
  • Link (1-6)
frontend/src/components/RecentPullRequests.tsx (1)
frontend/src/types/link.ts (1)
  • Link (1-6)
frontend/src/app/members/[memberKey]/page.tsx (1)
frontend/src/types/user.ts (1)
  • user (3-17)
backend/apps/github/graphql/nodes/pull_request.py (1)
backend/apps/github/graphql/nodes/issue.py (1)
  • resolve_repository_name (25-27)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Run frontend unit tests
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: Run backend tests
  • GitHub Check: CodeQL (python)
  • GitHub Check: CodeQL (javascript-typescript)
🔇 Additional comments (27)
frontend/src/types/user.ts (1)

84-84: LGTM! Good addition of repository name field.

The addition of an optional repositoryName property to the PullRequestsType interface is appropriate and well-aligned with the PR objective of adding tooltip functionality when hovering over repository names.

frontend/src/types/project.ts (1)

13-13: LGTM! Well-structured property addition.

The addition of an optional repositoryName property to the ProjectIssuesType interface is appropriate and aligns well with the rest of the changes in this PR.

frontend/src/app/page.tsx (1)

280-280: LGTM! Appropriate prop removal.

Removing the showAuthor prop from the RecentPullRequests component makes sense given the shift from displaying author details to repository information. This change aligns well with the addition of the repositoryName property to the relevant data types.

frontend/src/server/queries/userQueries.ts (1)

8-8: LGTM! Well-implemented GraphQL query enhancement.

Adding the repositoryName field to both the recentIssues and recentPullRequests GraphQL queries is a necessary and well-executed change to support the new UI features. This ensures that the frontend will receive the repository name data it needs to display tooltips on hover.

Also applies to: 14-14

frontend/src/server/queries/homeQueries.ts (2)

38-38: GraphQL query field addition looks good.

The addition of repositoryName to the recentIssues section aligns with the PR objective of displaying repository information on hover. This field will allow the component to access and display the repository name.


55-55: GraphQL query field addition looks good.

The addition of repositoryName to the recentPullRequests section is consistent with the changes made to the recentIssues section, maintaining a uniform approach across different entity types in the query.

frontend/src/server/queries/organizationQueries.ts (3)

37-40: Field ordering and addition look good.

The addition of repositoryName and reordering of fields in the recentPullRequests section is well-implemented. GraphQL query field order doesn't affect functionality, and the new field enhances the data available to the frontend.


47-51: Field ordering and addition look good.

The addition of repositoryName and reordering of fields in the recentReleases section is consistent with the changes in other sections. This ensures a consistent approach across different entity types.


69-69: GraphQL query field addition looks good.

The addition of repositoryName to the recentIssues section is consistent with the changes made to other sections and aligns with the PR objective of displaying repository information.

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

3-3: Import addition is appropriate.

The addition of the Link import from next/link is necessary for the new repository link functionality implemented in this component.

backend/apps/github/graphql/nodes/issue.py (2)

3-4: Import style improvement looks good.

Moving graphene to its own import line improves code readability, following Python style best practices.


12-13: Adding repository_name field looks good.

The addition of the repository_name field to the IssueNode class is well-implemented, using the appropriate GraphQL type.

backend/apps/github/graphql/nodes/pull_request.py (2)

12-12: LGTM: Adding repository_name field to PullRequestNode

The addition of the repository_name field to the PullRequestNode class is appropriate and aligns with your PR objective of displaying repository names in the UI.


23-25: LGTM: Well-implemented resolver method

The resolver implementation is correct and consistent with the same pattern used in the issue node. It properly returns the repository name from the repository attribute.

frontend/src/components/RecentReleases.tsx (2)

3-3: LGTM: Appropriate tooltip import

Importing the Tooltip component from @heroui/tooltip is the correct approach for implementing the hover functionality requested in the PR.


34-54: LGTM: Well-implemented tooltip for author avatars

The tooltip implementation is well-structured with appropriate configuration:

  • Shows author name or fallback to login
  • Has proper delay settings for good UX
  • Includes unique ID with index for accessibility
  • Correctly positions the tooltip at the bottom
  • Includes an arrow for better visual indication

This implementation successfully addresses the PR objective of showing a tooltip when hovering over elements.

frontend/src/components/ItemCardList.tsx (3)

2-2: LGTM: Appropriate tooltip import

Importing the Tooltip component from @heroui/tooltip is consistent with the implementation in RecentReleases.tsx.


26-26: LGTM: Type definition updated for repositoryName

Adding the repositoryName property to the renderDetails function parameter type ensures type safety and proper TypeScript validation.


43-63: LGTM: Consistent tooltip implementation

The tooltip implementation here matches the pattern used in RecentReleases.tsx, providing a consistent user experience across components.

frontend/src/server/queries/projectQueries.ts (1)

22-26: LGTM: GraphQL query updated to include repositoryName

The query has been appropriately updated to include the repositoryName field in the recentIssues object, which aligns with the backend changes made to expose this field through the GraphQL API.

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

1-1: Good update to imports.

Updated imports to include faFileCode for repository icons and Link for navigation, aligning with the new repository name display feature.

Also applies to: 3-3


10-13: Clean interface simplification.

Removing the showAuthor prop simplifies the component interface while maintaining the necessary functionality. Good practice to eliminate unused props.


15-15: Props destructuring properly updated.

Props destructuring has been correctly updated to remove the unused showAuthor prop while maintaining the showAvatar default value.


29-39: Well-implemented repository name display with hover functionality.

The implementation of the repository name display is clean and follows best practices:

  1. Proper conditional rendering based on item?.repositoryName
  2. Appropriate icon selection with faFileCode
  3. Good use of Next.js Link component for navigation
  4. URL path construction with proper casing using toLowerCase()
  5. Clean hover styling with hover:underline

This successfully implements the tooltip functionality when hovering over repository names as specified in the PR objectives.

frontend/src/app/members/[memberKey]/page.tsx (3)

113-129: Good addition of repositoryName to issues data structure.

The implementation correctly adds the repositoryName property to the mapped issues data, along with the login field to the author object. This provides the necessary data for the repository name tooltip feature.


131-146: Well-implemented repositoryName addition to pull requests.

The addition of the repositoryName property to pull requests and the login field to the author object is consistent with the changes in the issues mapping. This ensures a uniform implementation of the repository tooltip feature across different data types.


148-165: Consistent implementation for releases data structure.

The changes to the formattedReleases function follow the same pattern as the issues and pull requests, maintaining consistency throughout the codebase. The repositoryName is correctly added and the properties are logically ordered.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2d54912 and 33a7bc6.

📒 Files selected for processing (5)
  • frontend/__tests__/e2e/data/mockHomeData.ts (3 hunks)
  • frontend/__tests__/e2e/pages/Home.spec.ts (1 hunks)
  • frontend/__tests__/e2e/pages/ProjectDetails.spec.ts (1 hunks)
  • frontend/__tests__/e2e/pages/RepositoryDetails.spec.ts (1 hunks)
  • frontend/__tests__/e2e/pages/UserDetails.spec.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Run Code Scan
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: Run CI Denendencies Scan
  • GitHub Check: Run frontend unit tests
  • GitHub Check: Run backend tests
  • GitHub Check: CodeQL (javascript-typescript)
🔇 Additional comments (8)
frontend/__tests__/e2e/pages/RepositoryDetails.spec.ts (1)

77-77: Test updated to verify repository name display.

The test has been correctly updated to verify the visibility of repository name ("Test Repo 2") instead of comment count, which aligns with the UI changes made in this PR to display repository names with tooltips.

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

68-68: Test correctly updated to verify repository name.

The test now properly checks for the visibility of "Dependency-Track" repository name instead of comment count, which matches the UI changes implemented in this PR.

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

82-82: Test properly updated to validate repository name display.

The test has been correctly modified to verify the visibility of "Test Repo" repository name instead of comment count, which aligns with the UI changes to display repository names with tooltips on hover.

frontend/__tests__/e2e/pages/UserDetails.spec.ts (2)

43-43: Test correctly updated to verify repository name.

The test now checks for "Test repo 1" visibility instead of comment count, which corresponds to the UI changes made in this PR to display repository names with tooltips.


58-58: Test updated to verify repository name.

The test has been properly modified to check for "Test Repo 2" visibility, which aligns with the PR's focus on displaying repository names with tooltips.

frontend/__tests__/e2e/data/mockHomeData.ts (3)

118-119: LGTM! Correct repository name

The repository name "Dependency-Track" is consistent with the URL that points to "DependencyTrack/hyades", accurately representing the parent repository.


132-133: LGTM! Correct repository name

The repository name "BLT" matches the URL which points to "OWASP-BLT/BLT", providing accurate repository information.


114-155: Consider updating test data structure if the UI is changing

Based on the PR objectives, you're adding tooltips that appear when hovering over repository names. If the UI implementation is replacing comment counts with repository names (as suggested in the AI summary), ensure that your tests are updated accordingly to validate this new behavior.

Are there corresponding test changes to verify that the repository names are displayed correctly and that tooltips function as expected when hovering?

@abhayymishraa abhayymishraa marked this pull request as ready for review April 14, 2025 00:44
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.

Please look into these when you get a chance:

login: user?.login || '',
name: user?.name || user?.login || '',
},
commentsCount: issue.commentsCount,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still use the comments count?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no no . somehow i didn't noticed that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i will do the cleanup!!!

@abhayymishraa abhayymishraa requested a review from arkid15r April 14, 2025 17:57
@abhayymishraa
Copy link
Collaborator Author

Done Suggested Changes !!!!

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@arkid15r arkid15r enabled auto-merge April 14, 2025 19:11
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

@arkid15r arkid15r added this pull request to the merge queue Apr 14, 2025
Merged via the queue into OWASP:main with commit 92a0ee8 Apr 14, 2025
21 of 22 checks passed
shdwcodr pushed a commit to shdwcodr/Nest that referenced this pull request Jun 5, 2025
* Added tooltip when hover &&  repository name

* fixed backend tests

* fixed unit tests

* fixed e2e tests

* fixed some bugs & alphabatically arrangement

* Added suggestions and some query cleanup

* Update code

---------

Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>
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.

Improve recent isssues/prs/releases components

2 participants