-
Notifications
You must be signed in to change notification settings - Fork 4k
feat: allow users to change user created workspace room avatar #72446
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
Merged
Beamanator
merged 18 commits into
Expensify:main
from
samranahm:revert-72436-revert-66883-65210/edit-room-avatar
Oct 31, 2025
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
51353d1
Revert "[CP Staging] Revert "feat: allow users to change room avatar""
samranahm 7a4a421
fix: prevent anonymous (not logged-in) users from editing room avatar
samranahm 015993b
fix: default WorkspaceAvatar to use first letter instead of Workspace…
samranahm 90a6bc1
fix: pass policyName to display correct default Workspace avatar in W…
samranahm d584102
Merge remote-tracking branch 'upstream/main' into revert-72436-revert…
samranahm eebb50f
Merge branch 'Expensify:main' into revert-72436-revert-66883-65210/ed…
samranahm 67ee603
fix: change command name to UpdateRoomAvatar
samranahm 08c697b
Merge branch 'Expensify:main' into revert-72436-revert-66883-65210/ed…
samranahm e5cf954
update can edit room avatar permissions
samranahm be630fd
lint
samranahm 864cde7
Merge branch 'main' into revert-72436-revert-66883-65210/edit-room-av…
samranahm 4c5c737
fix merge conflict
samranahm 25e40b1
feat: add room avatar updated log message in all locals
samranahm 9167f5e
add getRoomAvatarUpdatedMessage util to get the message accordingly
samranahm 4fc58be
build optimistic room avatar updated report action
samranahm 82325e8
use getRoomAvatarUpdatedMessage to get alternate text and last messag…
samranahm 24a56d4
update canEditRoomAvatar to check current user in participants
samranahm 332d571
clear pending action from failure data
samranahm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,33 @@ | ||
| import React, {memo} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import useStyleUtils from '@hooks/useStyleUtils'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {clearAvatarErrors, getCurrentUserAccountID, updatePolicyRoomAvatar} from '@libs/actions/Report'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import {isUserCreatedPolicyRoom} from '@libs/ReportUtils'; | ||
| import {isDefaultAvatar} from '@libs/UserUtils'; | ||
| import CONST from '@src/CONST'; | ||
| import ROUTES from '@src/ROUTES'; | ||
| import type {Policy, Report} from '@src/types/onyx'; | ||
| import type {Icon} from '@src/types/onyx/OnyxCommon'; | ||
| import Avatar from './Avatar'; | ||
| import AvatarWithImagePicker from './AvatarWithImagePicker'; | ||
| import * as Expensicons from './Icon/Expensicons'; | ||
| import PressableWithoutFocus from './Pressable/PressableWithoutFocus'; | ||
| import Text from './Text'; | ||
|
|
||
| type RoomHeaderAvatarsProps = { | ||
| icons: Icon[]; | ||
| reportID: string; | ||
| report: Report; | ||
| policy: OnyxEntry<Policy>; | ||
| participants: number[]; | ||
| }; | ||
|
|
||
| function RoomHeaderAvatars({icons, reportID}: RoomHeaderAvatarsProps) { | ||
| function RoomHeaderAvatars({icons, report, policy, participants}: RoomHeaderAvatarsProps) { | ||
| const navigateToAvatarPage = (icon: Icon) => { | ||
| if (icon.type === CONST.ICON_TYPE_WORKSPACE && icon.id) { | ||
| Navigation.navigate(ROUTES.REPORT_AVATAR.getRoute(reportID, icon.id.toString())); | ||
| Navigation.navigate(ROUTES.REPORT_AVATAR.getRoute(report?.reportID, icon.id.toString())); | ||
| return; | ||
| } | ||
|
|
||
|
|
@@ -30,6 +38,8 @@ function RoomHeaderAvatars({icons, reportID}: RoomHeaderAvatarsProps) { | |
|
|
||
| const styles = useThemeStyles(); | ||
| const StyleUtils = useStyleUtils(); | ||
| const currentUserAccountID = getCurrentUserAccountID(); | ||
| const canEditRoomAvatar = isUserCreatedPolicyRoom(report) && participants.includes(currentUserAccountID) && !!policy && policy.role !== CONST.POLICY.ROLE.AUDITOR; | ||
|
|
||
| if (!icons.length) { | ||
| return null; | ||
|
|
@@ -42,6 +52,31 @@ function RoomHeaderAvatars({icons, reportID}: RoomHeaderAvatarsProps) { | |
| return; | ||
| } | ||
|
|
||
| if (canEditRoomAvatar) { | ||
| return ( | ||
| <AvatarWithImagePicker | ||
| source={icon.source || report.avatarUrl} | ||
| avatarID={icon.id} | ||
| isUsingDefaultAvatar={!report.avatarUrl || isDefaultAvatar(icon.source)} | ||
| size={CONST.AVATAR_SIZE.X_LARGE} | ||
| avatarStyle={[styles.avatarXLarge, styles.alignSelfCenter]} | ||
| onViewPhotoPress={() => Navigation.navigate(ROUTES.REPORT_AVATAR.getRoute(report.reportID))} | ||
| onImageRemoved={() => updatePolicyRoomAvatar(report.reportID)} | ||
| onImageSelected={(file) => updatePolicyRoomAvatar(report.reportID, file)} | ||
| editIcon={Expensicons.Camera} | ||
| editIconStyle={styles.smallEditIconAccount} | ||
| pendingAction={report.pendingFields?.avatar} | ||
| errors={report.errorFields?.avatar ?? null} | ||
| errorRowStyles={styles.mt6} | ||
| onErrorClose={() => clearAvatarErrors(report.reportID)} | ||
| style={[styles.w100, styles.mb3, styles.alignItemsStart, styles.sectionMenuItemTopDescription]} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding More details in this proposal: #76647 (comment) |
||
| type={icon.type} | ||
| editorMaskImage={Expensicons.ImageCropSquareMask} | ||
| name={icon.name} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <PressableWithoutFocus | ||
| style={styles.noOutline} | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import type {CustomRNImageManipulatorResult} from '@libs/cropOrRotateImage/types'; | ||
|
|
||
| type UpdateRoomAvatarParams = { | ||
| reportID: string; | ||
| file: File | CustomRNImageManipulatorResult | undefined; | ||
| reportActionID: string; | ||
| }; | ||
|
|
||
| export default UpdateRoomAvatarParams; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why this is needed?
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.
@eh2077 When we upload the avatar offline and refresh the page we get workspace default icon and that default icon should be workspace name's first letter but it's fallBack workspace building icon. So we are passing workspace name to get correct workspace icon.