-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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-2606] fix: project members shouldn't be able to change others roles #5802
Conversation
…oject member's roles
WalkthroughThe changes in this pull request focus on the Changes
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- web/core/components/project/settings/member-columns.tsx (2 hunks)
🧰 Additional context used
🔇 Additional comments (1)
web/core/components/project/settings/member-columns.tsx (1)
93-93
: Proper inclusion ofgetProjectMemberDetails
The addition of
getProjectMemberDetails
allows for checking project member details, which is necessary for role verification.
@@ -101,7 +101,9 @@ export const AccountTypeColumn: React.FC<AccountTypeProps> = observer((props) => | |||
const isWorkspaceMember = [EUserPermissions.MEMBER].includes( | |||
Number(getWorkspaceMemberDetails(rowData.member.id)?.role) ?? EUserPermissions.GUEST | |||
); | |||
const isRoleNonEditable = isCurrentUser || (isProjectAdminOrGuest && !isWorkspaceMember); | |||
const isCurrentUserProjectMember = getProjectMemberDetails(currentUser?.id ?? "")?.role == EUserPermissions.MEMBER; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure currentUser
is defined to prevent potential errors
When currentUser
is undefined, currentUser?.id ?? ""
results in an empty string. Calling getProjectMemberDetails
with an empty string may lead to unexpected behavior or errors. Consider checking if currentUser
is defined before calling getProjectMemberDetails
.
Apply this diff to address the issue:
-const isCurrentUserProjectMember = getProjectMemberDetails(currentUser?.id ?? "")?.role == EUserPermissions.MEMBER;
+const isCurrentUserProjectMember = currentUser
+ ? getProjectMemberDetails(currentUser.id)?.role === EUserPermissions.MEMBER
+ : false;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const isCurrentUserProjectMember = getProjectMemberDetails(currentUser?.id ?? "")?.role == EUserPermissions.MEMBER; | |
const isCurrentUserProjectMember = currentUser | |
? getProjectMemberDetails(currentUser.id)?.role === EUserPermissions.MEMBER | |
: false; |
🛠️ Refactor suggestion
Use strict equality operator (===
) for role comparison
It's recommended to use the strict equality operator ===
instead of ==
to prevent unintended type coercion during comparison.
Apply this diff:
-const isCurrentUserProjectMember = getProjectMemberDetails(currentUser?.id ?? "")?.role == EUserPermissions.MEMBER;
+const isCurrentUserProjectMember = getProjectMemberDetails(currentUser?.id ?? "")?.role === EUserPermissions.MEMBER;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const isCurrentUserProjectMember = getProjectMemberDetails(currentUser?.id ?? "")?.role == EUserPermissions.MEMBER; | |
const isCurrentUserProjectMember = getProjectMemberDetails(currentUser?.id ?? "")?.role === EUserPermissions.MEMBER; |
[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.
Summary by CodeRabbit
New Features
Bug Fixes