-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Prevent removal of admin and default members from workspace chats #43065
Conversation
@mananjadhav Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@brunovjk can you fix the lint issues? I can then review the code. |
All good here @mananjadhav :D |
Thanks @brunovjk for fixing this. I am currently testing it now. |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid-prevent-admin-removal.movAndroid: mWeb Chromemweb-chrome-prevent-admin-removal.moviOS: Nativeios-prevent-admin-removal.moviOS: mWeb Safarimweb-safari-prevent-admin-removal.movMacOS: Chrome / Safariweb-prevent-admin-removal.movMacOS: Desktopdesktop-prevent-admin-removal.mov |
All yours @jasperhuangg :D |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/jasperhuangg in version: 1.4.84-0 🚀
|
This PR is failing because of issue #35391 The issue is reproducible in: Web Screen.Recording.2024-06-16.at.6.50.53.in.the.evening.mp4 |
I'm sorry, but the test steps were wrong. I fixed it now:
reference: https://github.com/Expensify/App?tab=readme-ov-file#workspace-rooms cc: @kbecciv |
🚀 Deployed to production by https://github.com/AndrewGable in version: 1.4.84-3 🚀
|
PR is Pass according to the new step #43065 (comment) Screen.Recording.2024-06-18.at.8.22.37.in.the.morning.mp4 |
@@ -182,12 +184,14 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) { | |||
return; | |||
} | |||
const pendingChatMember = report?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString()); | |||
const isAdmin = !!(policy && policy.employeeList && details.login && policy.employeeList[details.login]?.role === CONST.POLICY.ROLE.ADMIN); | |||
const isDisabled = (isPolicyExpenseChat && isAdmin) || accountID === session?.accountID || pendingChatMember?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; |
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.
Details
This PR addresses an issue where workspace admins and default-added-users were inadvertently selectable for removal from workspace chats. To fix this, the PR implements controls based on user roles, as documented in workspace rooms and workspace chats.
Fixed Issues
$ #35391
PROPOSAL: N/A
Pre-condition:
1. We need 4 accounts for this test:
2. Login in the app as "Workspace Creator"
3. Create a workspace
4. Go to the automatically created "Workspace Chat"
5. Go to the "Report Details"
6. Go to "Members" page > Click "Invite"
7. Invite all the other 3 accounts (
admin
,member
, andinvited
) to the "Workspace Chat"8. Still on the "Members" page, change the
admin
role toAdministrator
8. Click on the "Global Fab" > "Start Chat" > Select "#Room" tab
9. Create a "workspace-room"
10. Invite all the other 3 accounts (
admin
,member
, andinvited
) to the "workspace-room"Tests:
1. Logged as the "Workspace Creator":
i. Go to the "Workspace Chat" > Report Details page
ii. Verify that the "Leave" button doesn't show, as you are a "workspace admin".
iii. Go to "Members" page
iv. Verify that you cannot select/remove admin and default added members
v. Verify that you can "Invite" and "Remove" (admin cannot be removed) members
vi. Go to the "workspace-room" > Report Details page
vii. Go to "Members" page
viii. Verify that you can "Invite" and "Remove" (you cannot remove yourself here) members
2. Logged as the "Workspace Admin":
i. Go to the "Workspace Chat" > Report Details page
ii. Verify that the "Leave" button doesn't show, as you are a "workspace admin".
iii. Go to "Members" page
iv. Verify that you cannot select/remove admin and default added members
v. Verify that you can "Invite" and "Remove" (admin cannot be removed) members
vi. Go to the "workspace-room" > Report Details page
vii. Go to "Members" page
viii. Verify that you can "Invite" and "Remove" (you cannot remove yourself here) members
3. Logged as the "Workspace Member":
i. Go to the "Workspace Chat" > Report Details page
ii. Verify that the "Invite" button does not show.
iii. Go to "Members" page
iv. Verify that you cannot "Invite" and "Remove" members.
vii. Logged as the "Workspace Member" > Go to the "workspace-room" > Report Details page
viii. Verify that the "Invite" button does not show.
x. Go to "Members" page
xi. Verify that you can "Invite" and "Remove" (you cannot remove yourself here) members.
4. Logged as the "Workspace Chat Invited":
i. Go to the "Workspace Chat" > Report Details page
ii. Verify that the "Invite" button does not show.
iii. Go to "Members" page
iv. Verify that you cannot "Invite" and "Remove" members.
vii. Logged as the "Workspace Room Invited" > Go to the "workspace-room" > Report Details page
viii. Verify that the "Invite" button does show and you can invite members to the chat.
Offline tests
N/A
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android.-.Native.mov
Android: mWeb Chrome
Android.-.mWeb.mov
iOS: Native
MacOS.-.iOS.Native.mov
iOS: mWeb Safari
MacOS.-.iOS.mWeb.mov
MacOS: Chrome / Safari
MacOS.-.Chorme.mov
MacOS: Desktop
MacOS.-.Desktop.mov