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

Update Avatar Patterns for LHN #20512

Merged
merged 48 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
6bc4f8c
initial commit - remove text pill, remove old room icons, use workspa…
grgia Jun 8, 2023
fbae916
Add getWorkspaceIcon()
grgia Jun 8, 2023
55e4f06
update all LHN icons
grgia Jun 9, 2023
d8c282f
use function for domain name
grgia Jun 9, 2023
108e25b
prettier
grgia Jun 9, 2023
723cc5e
Merge branch 'main' into georgia-updateAvatars
grgia Jun 9, 2023
2aa3d69
Merge branch 'main' into georgia-updateAvatars
grgia Jun 10, 2023
d21a541
remove extra []
grgia Jun 12, 2023
daa7b86
Merge branch 'main' into georgia-updateAvatars
grgia Jun 12, 2023
979295b
Fixes failing Jest Test.
grgia Jun 12, 2023
c583769
Make Expense Report Icon 32x32
grgia Jun 12, 2023
adafe55
Pass correct size to search bar as well
grgia Jun 12, 2023
9257817
Merge branch 'main' into georgia-updateAvatars
grgia Jun 13, 2023
248501b
Merge branch 'main' into georgia-updateAvatars
grgia Jun 14, 2023
c16c9fe
Rename midSmallNormal to SmallNormal (avatar size)
grgia Jun 15, 2023
e5053e4
Merge branch 'main' into georgia-updateAvatars
grgia Jun 15, 2023
d432973
Merge branch 'main' into georgia-updateAvatars
grgia Jun 16, 2023
3447f78
use accountID instead of email
grgia Jun 16, 2023
855ac33
Merge branch 'main' into georgia-updateAvatars
grgia Jun 19, 2023
6b68f1f
Merge branch 'main' into georgia-updateAvatars
grgia Jun 19, 2023
30cf0ed
fix expenseRequests avatars
grgia Jun 20, 2023
8b7aa13
prettier
grgia Jun 20, 2023
b3d58b3
Merge branch 'main' into georgia-updateAvatars
grgia Jun 22, 2023
b4da163
use SVG concierge icon
grgia Jun 22, 2023
31d32ae
remove concierge check since we check for this in userUtils.getAvatar()
grgia Jun 22, 2023
fba346d
First pass of fixing tooltips
grgia Jun 22, 2023
29160af
Merge branch 'main' into georgia-updateAvatars
grgia Jun 26, 2023
a50bf3e
pass in icon to UserDetailsTooltip
grgia Jun 26, 2023
02912b4
prettier
grgia Jun 26, 2023
6be06e8
Merge branch 'main' into georgia-updateAvatars
grgia Jun 29, 2023
307ee99
default id to -1
grgia Jun 29, 2023
f092af1
Some ids are stored as strings and others as numbers
grgia Jun 29, 2023
14eedaa
id is number
grgia Jun 29, 2023
2768970
use int for oldestFourAccountIDs being used for icons
grgia Jun 29, 2023
383bc5f
prettier
grgia Jul 3, 2023
fbf0fb0
Merge branch 'main' into georgia-updateAvatars
grgia Jul 3, 2023
39da410
Merge branch 'main' into georgia-updateAvatars
grgia Jul 3, 2023
f0c59e3
Merge branch 'main' into georgia-updateAvatars
grgia Jul 5, 2023
cf1d00d
use displayName
grgia Jul 5, 2023
3e238bb
use displayName everywhere and update comment
grgia Jul 5, 2023
dd0c769
default null id to -1
grgia Jul 5, 2023
b31d69a
Add task icon support for DM tasks and Workspace Tasks
grgia Jul 5, 2023
b10c3d5
prettier
grgia Jul 5, 2023
4c874fe
Merge branch 'main' into georgia-updateAvatars
grgia Jul 6, 2023
992b6bb
Fix expenseRequest avatar after merge
grgia Jul 6, 2023
f8de096
Fix console error
grgia Jul 6, 2023
8398156
prettier
grgia Jul 6, 2023
3776931
Merge branch 'main' into georgia-updateAvatars
grgia Jul 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions src/components/LHNOptionsList/OptionRowLHN.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import SubscriptAvatar from '../SubscriptAvatar';
import CONST from '../../CONST';
import themeColors from '../../styles/themes/default';
import SidebarUtils from '../../libs/SidebarUtils';
import TextPill from '../TextPill';
import OfflineWithFeedback from '../OfflineWithFeedback';
import PressableWithSecondaryInteraction from '../PressableWithSecondaryInteraction';
import * as ReportActionContextMenu from '../../pages/home/report/ContextMenu/ReportActionContextMenu';
Expand Down Expand Up @@ -65,7 +64,6 @@ const OptionRowLHN = (props) => {
const textStyle = props.isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText;
const textUnreadStyle = optionItem.isUnread ? [textStyle, styles.sidebarLinkTextBold] : [textStyle];
const displayNameStyle = StyleUtils.combineStyles([styles.optionDisplayName, styles.optionDisplayNameCompact, styles.pre, ...textUnreadStyle], props.style);
const textPillStyle = props.isFocused ? [styles.ml1, StyleUtils.getBackgroundColorWithOpacityStyle(themeColors.icon, 0.5)] : [styles.ml1];
const alternateTextStyle = StyleUtils.combineStyles(
props.viewMode === CONST.OPTION_MODE.COMPACT
? [textStyle, styles.optionAlternateText, styles.pre, styles.textLabelSupporting, styles.optionAlternateTextCompact, styles.ml2]
Expand Down Expand Up @@ -149,8 +147,8 @@ const OptionRowLHN = (props) => {
backgroundColor={props.isFocused ? themeColors.activeComponentBG : themeColors.sidebar}
mainAvatar={optionItem.icons[0]}
secondaryAvatar={optionItem.icons[1]}
mainTooltip={optionItem.ownerEmail}
secondaryTooltip={optionItem.subtitle}
Comment on lines -175 to -176
Copy link
Contributor

Choose a reason for hiding this comment

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

We agreed to disable tooltip for all subscript avatars at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it was refactored to use UserDetailsTooltip, see SubscriptAvatar.js

mainTooltip={optionItem.icons[0].name}
secondaryTooltip={optionItem.icons[1].name}
size={props.viewMode === CONST.OPTION_MODE.COMPACT ? CONST.AVATAR_SIZE.SMALL : CONST.AVATAR_SIZE.DEFAULT}
/>
) : (
Expand Down Expand Up @@ -179,13 +177,6 @@ const OptionRowLHN = (props) => {
optionItem.isChatRoom || optionItem.isPolicyExpenseChat || optionItem.isTaskReport || optionItem.isThread || optionItem.isMoneyRequestReport
}
/>
{optionItem.isChatRoom && !optionItem.isThread && (
<TextPill
style={textPillStyle}
accessibilityLabel={props.translate('accessibilityHints.workspaceName')}
text={optionItem.subtitle}
/>
)}
</View>
{optionItem.alternateText ? (
<Text
Expand Down
12 changes: 6 additions & 6 deletions src/components/MultipleAvatars.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const defaultProps = {

const MultipleAvatars = (props) => {
let avatarContainerStyles = props.size === CONST.AVATAR_SIZE.SMALL ? [styles.emptyAvatarSmall, styles.emptyAvatarMarginSmall] : [styles.emptyAvatar, styles.emptyAvatarMargin];
const singleAvatarStyles = props.size === CONST.AVATAR_SIZE.SMALL ? styles.singleAvatarSmall : styles.singleAvatar;
const singleAvatarStyle = props.size === CONST.AVATAR_SIZE.SMALL ? styles.singleAvatarSmall : styles.singleAvatar;
const secondAvatarStyles = [props.size === CONST.AVATAR_SIZE.SMALL ? styles.secondAvatarSmall : styles.secondAvatar, ...props.secondAvatarStyle];
const tooltipTexts = props.shouldShowTooltip ? _.pluck(props.icons, 'name') : [];

Expand Down Expand Up @@ -172,37 +172,37 @@ const MultipleAvatars = (props) => {
)}
</>
) : (
<View style={singleAvatarStyles}>
<View style={[singleAvatarStyle, props.icons[0].type === CONST.ICON_TYPE_WORKSPACE ? StyleUtils.getAvatarBorderRadius(props.size, props.icons[0].type) : {}]}>
<Tooltip text={tooltipTexts[0]}>
{/* View is necessary for tooltip to show for multiple avatars in LHN */}
<View>
<Avatar
source={props.icons[0].source || props.fallbackIcon}
fill={themeColors.iconSuccessFill}
size={props.isFocusMode ? CONST.AVATAR_SIZE.MID_SUBSCRIPT : CONST.AVATAR_SIZE.SMALLER}
imageStyles={[singleAvatarStyles]}
imageStyles={[singleAvatarStyle]}
name={props.icons[0].name}
type={props.icons[0].type}
/>
</View>
</Tooltip>
<View style={secondAvatarStyles}>
<View style={[[...secondAvatarStyles, props.icons[1].type === CONST.ICON_TYPE_WORKSPACE ? StyleUtils.getAvatarBorderRadius(props.size, props.icons[1].type) : {}]]}>
{props.icons.length === 2 ? (
<Tooltip text={tooltipTexts[1]}>
<View>
<Avatar
source={props.icons[1].source || props.fallbackIcon}
fill={themeColors.iconSuccessFill}
size={props.isFocusMode ? CONST.AVATAR_SIZE.MID_SUBSCRIPT : CONST.AVATAR_SIZE.SMALLER}
imageStyles={[singleAvatarStyles]}
imageStyles={[singleAvatarStyle]}
name={props.icons[1].name}
type={props.icons[1].type}
/>
</View>
</Tooltip>
) : (
<Tooltip text={tooltipTexts.slice(1).join(', ')}>
<View style={[singleAvatarStyles, styles.alignItemsCenter, styles.justifyContentCenter]}>
<View style={[singleAvatarStyle, styles.alignItemsCenter, styles.justifyContentCenter]}>
<Text
selectable={false}
style={props.size === CONST.AVATAR_SIZE.SMALL ? styles.avatarInnerTextSmall : styles.avatarInnerText}
Expand Down
38 changes: 0 additions & 38 deletions src/components/TextPill.js

This file was deleted.

126 changes: 75 additions & 51 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,26 @@ function isThread(report) {
return Boolean(report && report.parentReportID && report.parentReportActionID && report.type === CONST.REPORT.TYPE.CHAT);
}

/**
* Returns true if report is a DM/Group DM chat.
*
* @param {Object} report
* @returns {Boolean}
*/
function isDM(report) {
return Boolean(!getChatType(report));
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to wrap Boolean here. ! itself returns boolean value

}

/**
* If the report is a thread and has a chat type set, it is a workspace chat.
marcaaron marked this conversation as resolved.
Show resolved Hide resolved
*
* @param {Object} report
* @returns {Boolean}
*/
function isWorkspaceThread(report) {
return Boolean(isThread(report) && !isDM(report));
}

/**
* Returns true if reportAction has a child.
*
Expand Down Expand Up @@ -726,6 +746,23 @@ function getIconsForParticipants(participants, personalDetails) {
return avatars;
}

/**
* Given a policy name, return the associated workspace icon.
*
* @param {Object} report
* @returns {Object}
*/
function getWorkspaceIcon(report) {
const workspaceName = getPolicyName(report);
const policyExpenseChatAvatarSource = lodashGet(allPolicies, [`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'avatar']) || getDefaultWorkspaceAvatar(workspaceName);
const workspaceIcon = {
source: policyExpenseChatAvatarSource,
type: CONST.ICON_TYPE_WORKSPACE,
name: workspaceName,
};
return workspaceIcon;
}

/**
* Returns the appropriate icons for the given chat report using the stored personalDetails.
* The Avatar sources can be URLs or Icon components according to the chat type.
Expand All @@ -742,17 +779,13 @@ function getIcons(report, personalDetails, defaultIcon = null, isPayer = false)
type: CONST.ICON_TYPE_AVATAR,
name: '',
};

if (_.isEmpty(report)) {
result.source = defaultIcon || Expensicons.FallbackAvatar;
return [result];
}
if (isConciergeChatReport(report)) {
result.source = CONST.CONCIERGE_ICON_URL;
return [result];
}
if (isArchivedRoom(report)) {
result.source = Expensicons.DeletedRoomAvatar;
result.name = CONST.EMAIL.CONCIERGE;
return [result];
}
if (isThread(report)) {
Expand All @@ -765,62 +798,49 @@ function getIcons(report, personalDetails, defaultIcon = null, isPayer = false)
type: CONST.ICON_TYPE_AVATAR,
};

if (isWorkspaceThread(report)) {
const workspaceIcon = getWorkspaceIcon(report);
return [actorIcon, workspaceIcon];
}
return [actorIcon];
}
if (isDomainRoom(report)) {
result.source = Expensicons.DomainRoomAvatar;
return [result];
}
if (isAdminRoom(report)) {
result.source = Expensicons.AdminRoomAvatar;
return [result];
}
if (isAnnounceRoom(report)) {
result.source = Expensicons.AnnounceRoomAvatar;
return [result];
const domainName = Str.extractEmailDomain(report.ownerEmail);
const policyExpenseChatAvatarSource = lodashGet(allPolicies, [`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'avatar']) || getDefaultWorkspaceAvatar(domainName);
const domainIcon = {
source: policyExpenseChatAvatarSource,
type: CONST.ICON_TYPE_WORKSPACE,
name: domainName,
};
return [domainIcon];
grgia marked this conversation as resolved.
Show resolved Hide resolved
}
if (isChatRoom(report)) {
result.source = Expensicons.ActiveRoomAvatar;
return [result];
if (isAdminRoom(report) || isAnnounceRoom(report) || isChatRoom(report) || isArchivedRoom(report)) {
const workspaceIcon = getWorkspaceIcon(report);
return [workspaceIcon];
}
if (isPolicyExpenseChat(report) || isExpenseReport(report)) {
const workspaceName = lodashGet(allPolicies, [`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'name']);

const policyExpenseChatAvatarSource = lodashGet(allPolicies, [`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'avatar']) || getDefaultWorkspaceAvatar(workspaceName);

// Return the workspace avatar if the user is the owner of the policy expense chat
if (report.isOwnPolicyExpenseChat && !isExpenseReport(report)) {
result.source = policyExpenseChatAvatarSource;
result.type = CONST.ICON_TYPE_WORKSPACE;
result.name = workspaceName;
return [result];
}

const adminIcon = {
const workspaceIcon = getWorkspaceIcon(report);
const memberIcon = {
source: UserUtils.getAvatar(lodashGet(personalDetails, [report.ownerEmail, 'avatar']), report.ownerEmail),
name: report.ownerEmail,
type: CONST.ICON_TYPE_AVATAR,
};
return isExpenseReport(report) ? [memberIcon, workspaceIcon] : [workspaceIcon, memberIcon];
}
if (isIOUReport(report)) {
const managerIcon = {
source: UserUtils.getAvatar(lodashGet(personalDetails, [report.managerEmail, 'avatar']), report.managerEmail),
name: report.managerEmail,
type: CONST.ICON_TYPE_AVATAR,
};

const workspaceIcon = {
source: policyExpenseChatAvatarSource,
type: CONST.ICON_TYPE_WORKSPACE,
name: workspaceName,
const ownerIcon = {
source: UserUtils.getAvatar(lodashGet(personalDetails, [report.ownerEmail, 'avatar']), report.ownerEmail),
name: report.ownerEmail,
type: CONST.ICON_TYPE_AVATAR,
};

// If the user is an admin, return avatar source of the other participant of the report
// (their workspace chat) and the avatar source of the workspace
return [adminIcon, workspaceIcon];
}
if (isIOUReport(report)) {
const email = isPayer ? report.managerEmail : report.ownerEmail;
return [
{
source: UserUtils.getAvatar(lodashGet(personalDetails, [email, 'avatar']), email),
name: email,
type: CONST.ICON_TYPE_AVATAR,
},
];
return isPayer ? [managerIcon, ownerIcon] : [ownerIcon, managerIcon];
}

return getIconsForParticipants(report.participants, personalDetails);
Expand Down Expand Up @@ -2115,7 +2135,7 @@ function getWhisperDisplayNames(participants) {
}

/**
* Show subscript on IOU or expense report
* Show subscript on workspace chats and workspace threads and expense requests
grgia marked this conversation as resolved.
Show resolved Hide resolved
* @param {Object} report
* @returns {Boolean}
*/
Expand All @@ -2124,11 +2144,15 @@ function shouldReportShowSubscript(report) {
return false;
}

if (isPolicyExpenseChat(report) && !isThread(report) && !isTaskReport(report) && !report.isOwnPolicyExpenseChat) {
if (isPolicyExpenseChat(report) && !isThread(report) && !isTaskReport(report)) {
return true;
}

return isExpenseReport(report);
if (isWorkspaceThread(report)) {
return true;
}

return false;
}

/**
Expand Down
12 changes: 0 additions & 12 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3101,18 +3101,6 @@ const styles = {
zIndex: 2,
},

textPill: {
backgroundColor: themeColors.border,
borderRadius: 10,
overflow: 'hidden',
paddingVertical: 2,
flexShrink: 0,
maxWidth: variables.badgeMaxWidth,
fontSize: variables.fontSizeSmall,
...whiteSpace.pre,
...spacing.ph2,
},

dropZoneTopInvisibleOverlay: {
position: 'absolute',
width: '100%',
Expand Down