Skip to content

Conversation

@Dishant1804
Copy link
Collaborator

@Dishant1804 Dishant1804 commented Apr 15, 2025

Resolves #1351

  • move /repositories under organization
  • make URL case insensitive

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 15, 2025

Summary by CodeRabbit

  • New Features

    • Repository, issue, pull request, and release details now display associated organization information throughout the app.
    • Navigation to repository pages now includes the organization context in URLs for improved clarity and structure.
  • Improvements

    • Enhanced GraphQL queries and API responses to provide organization data for repositories, issues, pull requests, and releases.
    • Updated UI components and navigation logic to consistently reflect organization context across lists and detail pages.
  • Bug Fixes

    • Adjusted tests and mock data to support new organization-related fields and URL structures.

Summary by CodeRabbit

  • New Features

    • Repository details and navigation now include organization context in URLs and data display.
    • Organization information is now available for repositories across project, user, and organization views.
  • Bug Fixes

    • Repository links now preserve the original casing of repository names in URLs.
  • Tests

    • Updated tests and mock data to support organization-aware repository queries and navigation.
  • Chores

    • Adjusted GraphQL queries and component logic to require and handle organization keys for repository lookups.

Walkthrough

This change restructures repository-related routes and data queries to nest repositories under organizations, both in the backend and frontend. The backend GraphQL schema and resolvers now require and use an organization key for repository lookups, performing case-insensitive matching. Corresponding frontend code updates include changes to GraphQL queries, URL structures, navigation logic, and test data to reflect the new organization-based hierarchy. Mock data and tests have been updated to include organization information and to verify the new lookup and routing logic. The casing of repository names in URLs is now preserved rather than being forced to lowercase.

Changes

Files/Paths Change Summary
backend/apps/github/graphql/nodes/repository.py, backend/tests/apps/github/graphql/nodes/repository_test.py Added the organization field to the RepositoryNode GraphQL node and updated the corresponding test to expect this field.
backend/apps/github/graphql/queries/repository.py, backend/tests/apps/github/graphql/queries/repository_test.py Updated the repository query and resolver to require an organization_key argument, perform case-insensitive matching on both repository and organization keys, and updated tests to mock and assert the new query logic.
backend/apps/github/graphql/nodes/issue.py, backend/apps/github/graphql/nodes/pull_request.py, backend/apps/github/graphql/nodes/release.py, backend/tests/apps/github/graphql/nodes/issue_test.py, backend/tests/apps/github/graphql/nodes/release_test.py Added organization_name field and resolver to IssueNode, PullRequestNode, and ReleaseNode GraphQL nodes; updated tests to expect this field in the nodes' Meta configurations.
frontend/src/server/queries/repositoryQueries.ts, frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx Modified the repository GraphQL query to require both repositoryKey and organizationKey, updated the page logic to extract both keys from the URL and pass them to the query, and included organization info in the query selection.
frontend/src/server/queries/projectQueries.ts, frontend/src/server/queries/organizationQueries.ts, frontend/src/server/queries/userQueries.ts, frontend/src/server/queries/homeQueries.ts Extended queries to include the organization { login } field and organizationName in recent issues, pull requests, releases, and repositories in project, organization, user, and home contexts.
frontend/src/types/project.ts, frontend/src/types/home.ts, frontend/src/types/user.ts Added optional organization property to RepositoryCardProps, and added organizationName string properties to relevant issue, release, and pull request types/interfaces.
frontend/src/components/RepositoriesCard.tsx Updated the navigation logic to use the new organization-based repository URL structure.
frontend/src/components/RecentIssues.tsx, frontend/src/components/RecentPullRequests.tsx, frontend/src/components/RecentReleases.tsx Replaced Next.js Link components with button elements triggering programmatic navigation via useRouter, updated URLs to include organization segment, and removed forced lowercasing of repository names.
frontend/tests/e2e/pages/ProjectDetails.spec.ts, frontend/tests/e2e/pages/RepositoryDetails.spec.ts Updated e2e tests to expect and use the new organization-based repository URLs.
frontend/tests/unit/data/mockProjectDetailsData.ts Enhanced mock repository data to include the organization field.
frontend/tests/unit/pages/RepositoryDetails.test.tsx Updated the import path to reflect the new organization-based page structure.
frontend/src/app/members/[memberKey]/page.tsx Added organizationName property to mapped issues, pull requests, and releases in user details page.
frontend/src/components/ItemCardList.tsx Extended the renderDetails function parameter type to include the required organizationName string property.

Assessment against linked issues

Objective Addressed Explanation
Move repositories under /organizations and include organization in lookup (#1351)
Make repository lookup case-insensitive for both organization and repository keys (#1351)

Possibly related PRs

Suggested reviewers

  • kasya
  • arkid15r

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 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 8b803d4 and 36f71d0.

📒 Files selected for processing (4)
  • backend/apps/github/graphql/nodes/issue.py (2 hunks)
  • backend/apps/github/graphql/nodes/pull_request.py (2 hunks)
  • backend/apps/github/graphql/nodes/release.py (2 hunks)
  • backend/apps/github/graphql/queries/repository.py (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • backend/apps/github/graphql/nodes/issue.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • backend/apps/github/graphql/nodes/release.py
  • backend/apps/github/graphql/nodes/pull_request.py
  • backend/apps/github/graphql/queries/repository.py
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Run frontend unit tests
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: Run backend 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
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

🧹 Nitpick comments (1)
frontend/__tests__/e2e/pages/RepositoryDetails.spec.ts (1)

20-20: Add leading slash to URL path

The URL path should start with a leading slash to ensure proper routing in the application.

-    await page.goto('organizations/OWASP/repositories/test-repository')
+    await page.goto('/organizations/OWASP/repositories/test-repository')
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 317b881 and 70c7c1b.

📒 Files selected for processing (13)
  • backend/apps/github/graphql/nodes/repository.py (1 hunks)
  • backend/apps/github/graphql/nodes/user.py (3 hunks)
  • backend/tests/apps/github/graphql/nodes/repository_test.py (1 hunks)
  • backend/tests/apps/github/graphql/nodes/user_test.py (1 hunks)
  • frontend/__tests__/e2e/pages/ProjectDetails.spec.ts (1 hunks)
  • frontend/__tests__/e2e/pages/RepositoryDetails.spec.ts (1 hunks)
  • frontend/__tests__/unit/data/mockProjectDetailsData.ts (2 hunks)
  • frontend/__tests__/unit/pages/RepositoryDetails.test.tsx (1 hunks)
  • frontend/src/components/RepositoriesCard.tsx (1 hunks)
  • frontend/src/server/queries/organizationQueries.ts (1 hunks)
  • frontend/src/server/queries/projectQueries.ts (1 hunks)
  • frontend/src/server/queries/userQueries.ts (1 hunks)
  • frontend/src/types/project.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
backend/apps/github/graphql/nodes/user.py (1)
backend/apps/github/graphql/nodes/organization.py (1)
  • OrganizationNode (22-75)
⏰ 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 (15)
backend/tests/apps/github/graphql/nodes/user_test.py (1)

31-31: LGTM: Organization field added to expected fields

The addition of the "organization" field to the expected fields list in the UserNode tests correctly reflects the schema changes for exposing organization context in the GraphQL API.

frontend/__tests__/unit/pages/RepositoryDetails.test.tsx (2)

6-6: Updated import path correctly uses new organization-nested routing

The import path has been properly updated to reflect the new route structure where repositories are nested under organizations.


28-28:

❓ Verification inconclusive

Update useParams mock to include organizationKey

The component is now imported from a path that includes an organizationKey parameter, but the useParams mock doesn't include this parameter. This could potentially cause issues if the component requires this value.


🏁 Script executed:

#!/bin/bash
# Check if the component uses organizationKey from useParams
rg -A 2 -B 2 "useParams" "app/organizations/\[organizationKey\]/repositories/\[repositoryKey\]/page.tsx"

Length of output: 222


Update the useParams mock to include organizationKey

The component now appears to expect an organizationKey field from the URL parameters. However, our initial verification (attempting to search for the file at app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx) couldn’t locate the component file, which prevents a definitive automated confirmation that organizationKey is used. Please verify manually that the component under test correctly consumes the organizationKey parameter. Once confirmed, update the test mock accordingly. For example, the updated mock should resemble:

useParams: () => ({
  repositoryKey: 'test-repository',
  organizationKey: 'test-organization'
}),
frontend/src/types/project.ts (1)

81-83: LGTM: Repository type properly extended with organization data

The RepositoryCardProps interface has been correctly updated to include the optional organization field with login information, which aligns with the backend GraphQL schema changes and supports the new URL structure.

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

105-105: Great update to reflect the new repository URL structure.

The test assertion has been correctly updated to verify the new URL pattern that includes the organization path segment. This aligns with the PR objectives of moving repository routes under the organization context.

backend/tests/apps/github/graphql/nodes/repository_test.py (1)

30-30: Good addition of organization field to expected test fields.

This test update properly validates that the RepositoryNode GraphQL type exposes the organization field, which is essential for the new nested URL structure and organization-aware routing.

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

39-39: Correct implementation of organization field in repository schema.

Adding the organization field to the RepositoryNode's Meta fields tuple is the key backend change needed to support the repository-under-organization structure. This field will allow GraphQL queries to access the organization data associated with repositories.

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

61-63: Well-structured GraphQL query update to fetch organization data.

The query now properly requests the organization's login for each repository, which is essential for constructing the new organization-scoped repository URLs and implementing the updated routing structure.

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

31-33: Consistent addition of organization context to repository data.

The addition of organization { login } to topContributedRepositories is aligned with the PR's objective of moving repositories under organizations. This change correctly enables the frontend to reference the organization login when working with repositories.

frontend/__tests__/unit/data/mockProjectDetailsData.ts (2)

58-60: Mock data properly updated to include organization information.

The addition of the organization object with login: 'OWASP' to the first repository mock correctly matches the data structure changes in the GraphQL queries.


71-73: Mock data properly updated to include organization information.

The addition of the organization object with login: 'OWASP' to the second repository mock correctly matches the data structure changes in the GraphQL queries.

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

45-47: Appropriate schema update to include organization context in repositories.

The addition of organization { login } to the repository data structure in the GET_PROJECT_DATA query correctly aligns with the PR's objective of moving repositories under organizations.

backend/apps/github/graphql/nodes/user.py (3)

6-6: Correct import of OrganizationNode for the schema update.

The import of OrganizationNode from the organization module is appropriate for adding the organization field to the UserNode.


22-22: GraphQL schema properly extended to include organization relationship.

The addition of the organization field to the UserNode schema with the correct type (OrganizationNode) aligns with the PR objective of connecting repositories to organizations.


51-54: Appropriate resolver implementation for the organization field.

The resolver correctly returns the organization attribute from the user instance, which completes the schema update for exposing organization data through the UserNode.

@Dishant1804 Dishant1804 marked this pull request as draft April 15, 2025 10:04
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/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx (1)

36-36: Consider adding organizationKey to the dependency array

The useEffect dependency array includes repositoryKey but not organizationKey. While unlikely to cause issues in typical navigation patterns, adding organizationKey would ensure the effect re-runs if only the organization changes.

- }, [data, graphQLRequestError, repositoryKey])
+ }, [data, graphQLRequestError, repositoryKey, organizationKey])
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 70c7c1b and 35230d4.

📒 Files selected for processing (4)
  • backend/apps/github/graphql/queries/repository.py (3 hunks)
  • backend/tests/apps/github/graphql/queries/repository_test.py (2 hunks)
  • frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx (1 hunks)
  • frontend/src/server/queries/repositoryQueries.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx (1)
frontend/src/server/queries/repositoryQueries.ts (1)
  • GET_REPOSITORY_DATA (3-54)
backend/tests/apps/github/graphql/queries/repository_test.py (3)
backend/apps/github/graphql/queries/repository.py (2)
  • RepositoryQuery (10-67)
  • resolve_repository (25-44)
backend/tests/apps/github/graphql/queries/user_test.py (2)
  • mock_info (18-20)
  • mock_info (52-54)
backend/apps/github/models/repository.py (1)
  • Repository (22-332)
backend/apps/github/graphql/queries/repository.py (1)
backend/apps/github/models/repository.py (1)
  • Repository (22-332)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Run frontend unit tests
  • GitHub Check: Run backend tests
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: CodeQL (python)
  • GitHub Check: CodeQL (javascript-typescript)
🔇 Additional comments (13)
frontend/src/app/organizations/[organizationKey]/repositories/[repositoryKey]/page.tsx (2)

21-21: URL parameter extraction looks good

The component now correctly extracts both organizationKey and repositoryKey from the URL parameters, aligning with the new nested route structure.


25-25: Good update to query variables

The GraphQL query variables now include both repositoryKey and organizationKey, matching the updated backend requirements.

backend/tests/apps/github/graphql/queries/repository_test.py (5)

26-32: Good test refactoring for select_related

The test has been properly updated to mock the new query structure using select_related. This correctly tests the implementation of the optimized query pattern.


34-35: Correctly updated test parameters

The test now includes the new organization_key parameter, reflecting the updated resolver signature.


38-42: Good assertion for case-insensitive lookup

The test now correctly verifies both the select_related call and the case-insensitive lookup on repository key and organization login.


46-52: Consistent test update for error case

The "not found" test case is consistently updated with the same pattern as the successful case, ensuring both paths are properly tested.


56-65: Proper assertion for not found case

The assertions correctly verify that select_related is called with "organization" and that get is called with the appropriate parameters, even in the failure case.

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

4-5: Updated query parameters match backend changes

The GraphQL query has been properly updated to require both repositoryKey and organizationKey as parameters, aligning with the backend changes.


26-28: Good addition of organization field

The query now includes the organization { login } field, which is necessary for the new nested URL structure and properly reflects the updated data relationships.

backend/apps/github/graphql/queries/repository.py (4)

15-17: Good update to GraphQL field definition

The repository field now correctly requires the organization_key parameter, implementing the API change to nest repositories under organizations.


25-37: Updated resolver signature and documentation

The resolver method signature and documentation have been properly updated to include the organization_key parameter.


39-42: Good implementation of case-insensitive lookup

The repository lookup now:

  1. Uses select_related("organization") for optimized database access
  2. Performs case-insensitive lookup on both repository key and organization login

This properly implements both the nested repository structure and case-insensitive URL handling mentioned in the PR description.


64-64: Consistent case-insensitive implementation

The repositories resolver also uses case-insensitive lookup (__iexact) on organization login, maintaining consistency with the individual repository lookup.

@Dishant1804 Dishant1804 marked this pull request as ready for review April 15, 2025 16:47
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: 3

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 35230d4 and 588f58c.

📒 Files selected for processing (5)
  • backend/apps/github/graphql/queries/repository.py (3 hunks)
  • backend/tests/apps/github/graphql/queries/repository_test.py (2 hunks)
  • frontend/src/components/RecentIssues.tsx (1 hunks)
  • frontend/src/components/RecentPullRequests.tsx (1 hunks)
  • frontend/src/components/RecentReleases.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • backend/tests/apps/github/graphql/queries/repository_test.py
  • backend/apps/github/graphql/queries/repository.py
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: Run frontend unit tests
  • GitHub Check: Run backend tests
  • GitHub Check: CodeQL (python)
  • GitHub Check: CodeQL (javascript-typescript)

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.

@Dishant1804 please look into recent issues/PRs/releases cases.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@arkid15r arkid15r enabled auto-merge April 16, 2025 16:38
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 16, 2025
Merged via the queue into OWASP:main with commit 266695a Apr 16, 2025
21 of 22 checks passed
shdwcodr pushed a commit to shdwcodr/Nest that referenced this pull request Jun 5, 2025
* moved /repositories under organization

* case insensitive URL

* Update code

* recent issues/releases/PR handled

* Update code

---------

Co-authored-by: Arkadii Yakovets <[email protected]>
@coderabbitai coderabbitai bot mentioned this pull request Jun 30, 2025
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.

Move repositories under /organizations

2 participants