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

[WEB-3251] fix: add to projects list API #6550

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

prateekshourya29
Copy link
Member

@prateekshourya29 prateekshourya29 commented Feb 5, 2025

Description

In this PR, I have removed is_member property from the projects API and added member_role instead.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

References

WEB-3251

Summary by CodeRabbit

  • New Features

    • Enhanced the project page with reactive data fetching and improved state management for a more dynamic user experience.
  • Refactor

    • Transitioned from a simple membership flag to a descriptive role-based system across project listings and cards.
    • Updated permission checks and filtering logic, ensuring that user roles are now more clearly represented in project interactions.

Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Walkthrough

The changes update how project membership is represented across the codebase. The boolean field is_member has been removed from serializers, views, type definitions, and filtering logic, and is replaced by a role-based field member_role. UI components and helper functions are updated to align with this new system, and the project page component now uses reactive state management for data fetching.

Changes

File(s) Change Summary
apiserver/…/serializers/project.py
apiserver/…/views/project/base.py
Removed the is_member field and queryset annotation; updated serializers and view methods to use member_role instead.
packages/types/…/projects.d.ts Modified interfaces by replacing is_member with member_role in IPartialProject and removing member_role from IProject.
web/ce/…/page.tsx Updated ProjectPageRoot to be wrapped with observer and to fetch data reactively using useParams and useSWR.
web/core/components/…/card.tsx Renamed variables (isOwnerhasAdminRole, isMemberhasMemberRole) and added isMemberOfProject to clarify role-check logic.
web/core/store/…/project.store.ts
web/helpers/…/project.helper.ts
Revised filtering and helper logic to check for member_role rather than the boolean is_member.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant PP as ProjectPageRoot
    participant NS as useParams Hook
    participant SW as useSWR
    participant API as fetchProjects API

    U->>PP: Load project page
    PP->>NS: Retrieve workspaceSlug
    PP->>SW: Initiate data fetch with workspaceSlug
    SW->>API: Request project data
    API-->>SW: Return projects with member_role info
    SW-->>PP: Provide data to component
    PP->>U: Render updated project page
Loading

Possibly related PRs

Suggested labels

🐛bug, ⚙️backend

Suggested reviewers

  • sriramveeraghanta
  • rahulramesha
  • pushya22

Poem

I'm a hopping coder with ears so keen,
Leaving behind the old boolean scene.
Membership now whispers roles so bright,
Code and logic dancing in the light.
Bounce with joy in this refactor spree,
Cheers from a rabbit, as happy as can be! 🐇

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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. (Beta)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@sriramveeraghanta sriramveeraghanta merged commit 89d1926 into preview Feb 5, 2025
8 of 14 checks passed
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)
web/helpers/project.helper.ts (1)

90-90: Consider validating the member role value.

The condition !project.member_role only checks for the existence of a role. Consider validating that the role meets minimum permission requirements:

-  if (displayFilters.my_projects && !project.member_role) fallsInFilters = false;
+  if (displayFilters.my_projects && (!project.member_role || project.member_role < EUserPermissions.MEMBER)) fallsInFilters = false;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9bd70cd and c6f926b.

📒 Files selected for processing (7)
  • apiserver/plane/app/serializers/project.py (0 hunks)
  • apiserver/plane/app/views/project/base.py (2 hunks)
  • packages/types/src/project/projects.d.ts (1 hunks)
  • web/ce/components/projects/page.tsx (1 hunks)
  • web/core/components/project/card.tsx (7 hunks)
  • web/core/store/project/project.store.ts (2 hunks)
  • web/helpers/project.helper.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • apiserver/plane/app/serializers/project.py
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (6)
web/ce/components/projects/page.tsx (1)

11-25: LGTM! Well-structured reactive component with proper data fetching.

The changes improve the component by:

  • Adding reactive state management with mobx-react
  • Implementing efficient data fetching with SWR
  • Including proper null checks for dependencies
packages/types/src/project/projects.d.ts (1)

19-19: LGTM! Type definition properly reflects role-based membership.

The change from boolean is_member to nullable member_role: TUserPermissions | null is a good improvement that provides more granular control over project access.

web/core/components/project/card.tsx (1)

66-68: LGTM! Clear and consistent role-based checks.

The changes improve code clarity by:

  • Using descriptive role variables
  • Implementing consistent role-based checks
  • Properly handling different permission levels
web/core/store/project/project.store.ts (2)

218-218: LGTM! Clean transition from boolean to role-based membership check.

The change from is_member to !!project.member_role maintains the same boolean logic while transitioning to the new role-based system.


236-236: LGTM! Consistent role-based membership check.

The change aligns with the joinedProjectIds getter, maintaining consistency in how project membership is determined.

apiserver/plane/app/views/project/base.py (1)

157-161: LGTM! Clean transition to role-based membership in API response.

The changes correctly:

  1. Annotate the user's role in the project using a subquery
  2. Include the role in the API response

Also applies to: 172-172

@sriramveeraghanta sriramveeraghanta deleted the fix-project-member-role branch February 5, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants