Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 13 additions & 8 deletions src/components/AvatarWithDisplayName.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import reportPropTypes from '../pages/reportPropTypes';
import participantPropTypes from './participantPropTypes';
import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import UserDetailsTooltip from './UserDetailsTooltip';
import styles from '../styles/styles';
import themeColors from '../styles/themes/default';
import SubscriptAvatar from './SubscriptAvatar';
Expand Down Expand Up @@ -71,13 +72,17 @@ function AvatarWithDisplayName(props) {
size={props.size}
/>
) : (
<Avatar
size={props.size}
source={icons[0].source}
type={icons[0].type}
name={icons[0].name}
containerStyles={avatarContainerStyle}
/>
<UserDetailsTooltip accountID={props.report.ownerAccountID}>
<View>
<Avatar
size={props.size}
source={icons[0].source}
type={icons[0].type}
name={icons[0].name}
containerStyles={avatarContainerStyle}
/>
</View>
</UserDetailsTooltip>
)}
<View style={[styles.flex1, styles.flexColumn, styles.ml3]}>
<DisplayNames
Expand All @@ -86,7 +91,7 @@ function AvatarWithDisplayName(props) {
tooltipEnabled
numberOfLines={1}
textStyles={[props.isAnonymous ? styles.headerAnonymousFooter : styles.headerText, styles.pre]}
shouldUseFullTitle={isExpenseReport || props.isAnonymous}
shouldUseFullTitle={props.isAnonymous}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change also doesn't look related to this PR. Change commented above and this change will result in following change in UI.

Before:
Screenshot 2023-06-07 at 13 03 53

After:
Screenshot 2023-06-07 at 13 04 05

I don't mind the change in UI as it looks consistent with other headers. But I am not sure why was it created that way by @yuwenmemon in #18148. May be some design specification.

@yuwenmemon Do you think it is okay to make this change here?
cc: @youssef-lr

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@sobitneupane Exactly. I did this to make it more consistent.

@allroundexperts allroundexperts Jun 8, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@youssef-lr @yuwenmemon This is blocked on your reply here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's intentional to only display the full name based on those two conditions so I'd say let's remove that change from this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@sobitneupane Removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@sobitneupane How so? Can you share screenshots of web vs native?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Screenshot 2023-06-21 at 18 14 01 Screenshot 2023-06-21 at 18 14 32

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed @sobitneupane!

@sobitneupane sobitneupane Jun 26, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's intentional to only display the full name based on those two conditions so I'd say let's remove that change from this PR.

@allroundexperts As suggested by @youssef-lr I think the better idea is to remove this change from this PR. I cannot get how this change is related to the issue we are trying to solve.

Or, if we want to make this change in this PR. Let's first get approval from the team. Started a discussion here.

/>
{!_.isEmpty(subtitle) && (
<Text
Expand Down
14 changes: 11 additions & 3 deletions src/components/DisplayNames/index.native.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import React from 'react';
import React, {Fragment} from 'react';
import _ from 'underscore';
import {propTypes, defaultProps} from './displayNamesPropTypes';
import Text from '../Text';
import styles from '../../styles/styles';

// As we don't have to show tooltips of the Native platform so we simply render the full display names list.
function DisplayNames(props) {
return (
<Text
accessibilityLabel={props.accessibilityLabel}
style={props.textStyles}
numberOfLines={props.numberOfLines}
>
{props.fullTitle}
{props.shouldUseFullTitle
? props.fullTitle
: _.map(props.displayNamesWithTooltips, ({displayName}, index) => (
<Fragment key={index}>
<Text style={[...props.textStyles, styles.pre]}>{displayName}</Text>
{index < props.displayNamesWithTooltips.length - 1 && <Text style={props.textStyles}>,&nbsp;</Text>}
</Fragment>
))}
</Text>
);
}
Expand Down
39 changes: 27 additions & 12 deletions src/components/MoneyRequestHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {View} from 'react-native';
import PropTypes from 'prop-types';
import lodashGet from 'lodash/get';
import HeaderWithBackButton from './HeaderWithBackButton';
import UserDetailsTooltip from './UserDetailsTooltip';
import iouReportPropTypes from '../pages/iouReportPropTypes';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import * as ReportUtils from '../libs/ReportUtils';
Expand Down Expand Up @@ -115,19 +116,33 @@ function MoneyRequestHeader(props) {
<Text style={[styles.textLabelSupporting, styles.lh16]}>{props.translate('common.to')}</Text>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.justifyContentBetween, styles.pv3]}>
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.justifyContentBetween]}>
<Avatar
source={payeeAvatar}
type={isExpenseReport ? CONST.ICON_TYPE_WORKSPACE : CONST.ICON_TYPE_AVATAR}
name={payeeName}
size={CONST.AVATAR_SIZE.DEFAULT}
/>
<UserDetailsTooltip
accountID={isExpenseReport ? '' : moneyRequestReport.managerID}
fallbackUserDetails={{
avatar: payeeAvatar,
displayName: ReportUtils.getPolicyName(moneyRequestReport, props.policies),
}}
>
<View>
<Avatar
source={payeeAvatar}
type={isExpenseReport ? CONST.ICON_TYPE_WORKSPACE : CONST.ICON_TYPE_AVATAR}
name={payeeName}
size={CONST.AVATAR_SIZE.DEFAULT}
/>
</View>
</UserDetailsTooltip>
<View style={[styles.flex1, styles.flexColumn, styles.ml3]}>
<Text
style={[styles.headerText, styles.pre]}
numberOfLines={1}
>
{payeeName}
</Text>
<View style={[styles.alignItemsStart]}>
<UserDetailsTooltip accountID={isExpenseReport ? '' : moneyRequestReport.managerID}>
<Text
style={[styles.headerText, styles.pre]}
numberOfLines={1}
>
{payeeName}
</Text>
</UserDetailsTooltip>
</View>
{isExpenseReport && (
<Text
style={[styles.textLabelSupporting, styles.lh16, styles.pre]}
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/UnreadIndicatorsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,11 @@ describe('Unread Indicators', () => {
expect(displayNameTexts).toHaveLength(2);
const firstReportOption = displayNameTexts[0];
expect(lodashGet(firstReportOption, ['props', 'style', 0, 'fontWeight'])).toBe(fontWeightBold);
expect(lodashGet(firstReportOption, ['props', 'children'])).toBe('C User');
expect(firstReportOption).toHaveTextContent('C User');

const secondReportOption = displayNameTexts[1];
expect(lodashGet(secondReportOption, ['props', 'style', 0, 'fontWeight'])).toBe(fontWeightBold);
expect(lodashGet(secondReportOption, ['props', 'children'])).toBe('B User');
expect(secondReportOption).toHaveTextContent('B User');

// Tap the new report option and navigate back to the sidebar again via the back button
return navigateToSidebarOption(0);
Expand All @@ -372,9 +372,9 @@ describe('Unread Indicators', () => {
const displayNameTexts = screen.queryAllByLabelText(hintText);
expect(displayNameTexts).toHaveLength(2);
expect(lodashGet(displayNameTexts[0], ['props', 'style', 0, 'fontWeight'])).toBe(undefined);
expect(lodashGet(displayNameTexts[0], ['props', 'children'])).toBe('C User');
expect(displayNameTexts[0]).toHaveTextContent('C User');
expect(lodashGet(displayNameTexts[1], ['props', 'style', 0, 'fontWeight'])).toBe(fontWeightBold);
expect(lodashGet(displayNameTexts[1], ['props', 'children'])).toBe('B User');
expect(displayNameTexts[1]).toHaveTextContent('B User');
}));

xit('Manually marking a chat message as unread shows the new line indicator and updates the LHN', () =>
Expand Down
13 changes: 6 additions & 7 deletions tests/unit/SidebarFilterTest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {cleanup, screen} from '@testing-library/react-native';
import Onyx from 'react-native-onyx';
import lodashGet from 'lodash/get';
import * as LHNTestUtils from '../utils/LHNTestUtils';
import waitForPromisesToResolve from '../utils/waitForPromisesToResolve';
import CONST from '../../src/CONST';
Expand Down Expand Up @@ -331,7 +330,7 @@ describe('Sidebar', () => {
const navigatesToChatHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
expect(screen.queryAllByAccessibilityHint(navigatesToChatHintText)).toHaveLength(1);
expect(displayNames).toHaveLength(1);
expect(lodashGet(displayNames, [0, 'props', 'children'])).toBe('Three, Four');
expect(displayNames[0]).toHaveTextContent('Three, Four');
} else {
// Both reports visible
const navigatesToChatHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
Expand Down Expand Up @@ -371,8 +370,8 @@ describe('Sidebar', () => {
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNames = screen.queryAllByLabelText(hintText);
expect(displayNames).toHaveLength(2);
expect(lodashGet(displayNames, [0, 'props', 'children'])).toBe('One, Two');
expect(lodashGet(displayNames, [1, 'props', 'children'])).toBe('Three, Four');
expect(displayNames[0]).toHaveTextContent('One, Two');
expect(displayNames[1]).toHaveTextContent('Three, Four');
})

// When report3 becomes unread
Expand Down Expand Up @@ -440,8 +439,8 @@ describe('Sidebar', () => {
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNames = screen.queryAllByLabelText(hintText);
expect(displayNames).toHaveLength(2);
expect(lodashGet(displayNames, [0, 'props', 'children'])).toBe('Three, Four');
expect(lodashGet(displayNames, [1, 'props', 'children'])).toBe('One, Two');
expect(displayNames[0]).toHaveTextContent('Three, Four');
expect(displayNames[1]).toHaveTextContent('One, Two');
})
);
});
Expand Down Expand Up @@ -652,7 +651,7 @@ describe('Sidebar', () => {
const navigatesToChatHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
expect(screen.queryAllByAccessibilityHint(navigatesToChatHintText)).toHaveLength(1);
expect(displayNames).toHaveLength(1);
expect(lodashGet(displayNames, [0, 'props', 'children'])).toBe('Three, Four');
expect(displayNames[0]).toHaveTextContent('Three, Four');
} else {
// Both reports visible
const navigatesToChatHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
Expand Down
Loading