Skip to content

[WEB-2606] fix: project members shouldn't be able to change others roles#5780

Closed
sharma01ketan wants to merge 18 commits intopreviewfrom
fix/project-member-can-change-project-member-roles
Closed

[WEB-2606] fix: project members shouldn't be able to change others roles#5780
sharma01ketan wants to merge 18 commits intopreviewfrom
fix/project-member-can-change-project-member-roles

Conversation

@sharma01ketan
Copy link
Contributor

@sharma01ketan sharma01ketan commented Oct 9, 2024

[WEB-2606]

This PR aims to fix the bug where a Project Member is able to edit the details in the frontend of other Project Members in the Project Settings

Previous State:

Screen.Recording.2024-10-09.at.4.18.21.PM.mov

Current State:

No Dropdown appears on other Project Members name.

Screenshot 2024-10-09 at 4 19 28 PM

Summary by CodeRabbit

  • New Features

    • Enhanced role management logic for project members, allowing for more nuanced control based on user membership status.
  • Bug Fixes

    • Improved determination of non-editable roles by incorporating checks for project membership.

NarayanBavisetti and others added 18 commits October 7, 2024 20:07
* fix: drag handle scrolling fixed

* fix: closest scrollable parent found and scrolled

* fix: removed overflow auto from framerenderer

* fix: make dragging dynamic and smoother
* Updated layout names

* Corrected character casing for titles
* fix: custom theme mutation logic

* chore: update querySelector element
* fix: workspace draft issues

* chore: changed the timezone key

* chore: migration changes
* feat: export page as pdf and markdown

* chore: add image conversion logic
* chore: cycle sidebar refactor

* chore: code splitting

* chore: code refactor

* chore: code refactor
* fix: remove validation of roles from the live server

* chore: remove the service

* fix: remove all validation of authorization

* fix: props updated
…5770)

* move mark all as read to header and remove it from dropdown

* made recommended changes
)

* feat: add text color and highlight options to pages

* style: rich text editor floating toolbar

* chore: remove unused function

* refactor: slash command components

* chore: move default text and background options to the top

* fix: sections filtering logic
* fix: create cycle function

* chore: draft and cycle version changes

---------

Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
@sharma01ketan sharma01ketan added 🐛bug Something isn't working 🌐frontend labels Oct 9, 2024
@sharma01ketan sharma01ketan added this to the v0.24.0 milestone Oct 9, 2024
@sharma01ketan sharma01ketan self-assigned this Oct 9, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 9, 2024

Walkthrough

The changes in this pull request focus on the AccountTypeColumn component within the member-columns.tsx file. A new method, getProjectMemberDetails, has been added to the project object from the useMember hook to enhance the logic for determining project membership based on user roles. This modification allows for a more nuanced approach to role management, integrating checks for membership status alongside existing role filters. The overall structure of the component remains unchanged, with the primary focus on improving role management logic.

Changes

File Path Change Summary
web/core/components/project/settings/member-columns.tsx Added getProjectMemberDetails method to project object; updated logic for determining non-editable roles based on project membership.

Possibly related PRs

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham
  • rahulramesha

🐰 In the meadow where we play,
New logic hops in bright array.
Roles and members now align,
A dance of permissions, oh so fine!
With every change, we grow and thrive,
In our project, we come alive! 🌼


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

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 UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6d78418 and 807b6d5.

📒 Files selected for processing (1)
  • web/core/components/project/settings/member-columns.tsx (2 hunks)
🧰 Additional context used
🔇 Additional comments (2)
web/core/components/project/settings/member-columns.tsx (2)

93-93: Addition of getProjectMemberDetails is appropriate

The inclusion of getProjectMemberDetails from the useMember hook is necessary for fetching project member details and implementing the updated role management logic.


105-106: Updated isRoleNonEditable logic correctly prevents Project Members from editing others' roles

The inclusion of isCurrentUserProjectMember in the isRoleNonEditable condition ensures that Project Members cannot edit the roles of other members, effectively addressing the bug described in the PR objectives.

Number(getWorkspaceMemberDetails(rowData.member.id)?.role) ?? EUserPermissions.GUEST
);
const isRoleNonEditable = isCurrentUser || (isProjectAdminOrGuest && !isWorkspaceMember);
const isCurrentUserProjectMember = getProjectMemberDetails(currentUser?.id ?? "")?.role == EUserPermissions.MEMBER;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle potential undefined currentUser when fetching member details

In the line:

const isCurrentUserProjectMember = getProjectMemberDetails(currentUser?.id ?? "")?.role == EUserPermissions.MEMBER;

If currentUser is undefined, currentUser?.id will be undefined, and the nullish coalescing operator ?? will result in an empty string "". Passing an empty string to getProjectMemberDetails may not return the expected member details and could potentially cause issues. Consider adding a null check for currentUser before calling getProjectMemberDetails.

Apply this diff to add a null check:

- const isCurrentUserProjectMember = getProjectMemberDetails(currentUser?.id ?? "")?.role == EUserPermissions.MEMBER;
+ const isCurrentUserProjectMember = currentUser && getProjectMemberDetails(currentUser.id)?.role === EUserPermissions.MEMBER;

@sharma01ketan sharma01ketan removed the request for review from gurusainath October 11, 2024 10:33
@sriramveeraghanta sriramveeraghanta deleted the fix/project-member-can-change-project-member-roles branch February 10, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛bug Something isn't working 🌐frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants