-
Notifications
You must be signed in to change notification settings - Fork 2.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
Cloudpresser/user details tooltip #20276
Changes from all commits
614b283
f856ce5
e3f2fc1
8c6a4b7
198aa5b
34f12e9
e6eb717
f7bde40
9840b18
5722575
4fa3e52
4535ee0
48f5af8
48557bb
1d9a457
1e94377
aaa593b
709a6b3
efd0580
6d2736c
77cb99c
d6fadfc
24aa674
7941eca
b0b1a05
da0dcd3
0f3c1f2
ff1a4ec
9ac3b90
a7c5077
0fed1bd
b656d43
cf3a4ad
8f85240
1c14280
3608e48
a285d7e
8eaf9bf
65a1103
07fd999
68c1ed0
e1dd0bf
1ba85f2
8bc46ce
3922f09
ccc7229
245a284
fca8b1e
a97bf9b
89e626a
c275f20
50ef668
56bb67b
a8455fb
b844737
3b52187
cb8c6ca
562244c
a0ea50d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React, {useCallback} from 'react'; | ||
import {View, Text} from 'react-native'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import Str from 'expensify-common/lib/str'; | ||
import lodashGet from 'lodash/get'; | ||
import _ from 'underscore'; | ||
import Avatar from '../Avatar'; | ||
import Tooltip from '../Tooltip'; | ||
import {propTypes, defaultProps} from './userDetailsTooltipPropTypes'; | ||
import styles from '../../styles/styles'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
|
||
function UserDetailsTooltip(props) { | ||
const userDetails = lodashGet(props.personalDetailsList, props.accountID, props.fallbackUserDetails); | ||
const renderTooltipContent = useCallback( | ||
() => ( | ||
<View style={[styles.alignItemsCenter, styles.ph2, styles.pv2]}> | ||
<View style={styles.emptyAvatar}> | ||
<Avatar | ||
containerStyles={[styles.actionAvatar]} | ||
source={userDetails.avatar} | ||
/> | ||
</View> | ||
|
||
<Text style={[styles.mt2, styles.textMicroBold, styles.textReactionSenders, styles.textAlignCenter]}> | ||
{String(userDetails.displayName).trim() ? userDetails.displayName : ''} | ||
</Text> | ||
|
||
<Text style={[styles.textMicro, styles.fontColorReactionLabel]}> | ||
{String(userDetails.login).trim() && !_.isEqual(userDetails.login, userDetails.displayName) ? Str.removeSMSDomain(userDetails.login) : ''} | ||
</Text> | ||
Comment on lines
+29
to
+31
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. The user with mobile number login case was handled incorrectly resulting in the regression showing the phone number twice with different formatting. Handled it by improving the checks! 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. We added the login handling here, but we didn't account for overflowing content on the tooltip with a very long email. This caused a regression here. |
||
</View> | ||
), | ||
[userDetails.avatar, userDetails.displayName, userDetails.login], | ||
); | ||
|
||
if (!userDetails.displayName && !userDetails.login) { | ||
return props.children; | ||
} | ||
|
||
return <Tooltip renderTooltipContent={renderTooltipContent}>{props.children}</Tooltip>; | ||
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.
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.
|
||
} | ||
|
||
UserDetailsTooltip.propTypes = propTypes; | ||
UserDetailsTooltip.defaultProps = defaultProps; | ||
UserDetailsTooltip.displayName = 'UserDetailsTooltip'; | ||
|
||
export default withOnyx({ | ||
personalDetailsList: { | ||
key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
}, | ||
})(UserDetailsTooltip); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import PropTypes from 'prop-types'; | ||
import personalDetailsPropType from '../../pages/personalDetailsPropType'; | ||
|
||
const propTypes = { | ||
/** User's Account ID */ | ||
accountID: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, | ||
/** Fallback User Details object used if no accountID */ | ||
fallbackUserDetails: PropTypes.shape({ | ||
/** Avatar URL */ | ||
avatar: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), | ||
/** Display Name */ | ||
displayName: PropTypes.string, | ||
/** Login */ | ||
login: PropTypes.string, | ||
}), | ||
/** Component that displays the tooltip */ | ||
children: PropTypes.node.isRequired, | ||
/** List of personalDetails (keyed by accountID) */ | ||
personalDetailsList: PropTypes.objectOf(personalDetailsPropType), | ||
}; | ||
|
||
const defaultProps = { | ||
accountID: '', | ||
fallbackUserDetails: {displayName: '', login: '', avatar: ''}, | ||
personalDetailsList: {}, | ||
}; | ||
|
||
export {propTypes, defaultProps}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -749,6 +749,7 @@ function getIcons(report, personalDetails, defaultIcon = null, isPayer = false) | |
} | ||
if (isConciergeChatReport(report)) { | ||
result.source = CONST.CONCIERGE_ICON_URL; | ||
result.name = CONST.EMAIL.CONCIERGE; | ||
return [result]; | ||
} | ||
if (isArchivedRoom(report)) { | ||
|
@@ -845,6 +846,16 @@ function getPersonalDetailsForLogin(login) { | |
); | ||
} | ||
|
||
/** | ||
* Gets the accountID for a login by looking in the ONYXKEYS.PERSONAL_DETAILS Onyx key (stored in the local variable, allPersonalDetails). If it doesn't exist in Onyx, | ||
* then an empty string is returned. | ||
* @param {String} login | ||
* @returns {String} | ||
*/ | ||
function getAccountIDForLogin(login) { | ||
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. @cloudpresser @puneetlath 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. Issue reported here: #20934 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. @esh-g If the the method no longer works after So it's not a regression from this PR. |
||
return lodashGet(allPersonalDetails, [login, 'accountID'], ''); | ||
} | ||
|
||
/** | ||
* Get the displayName for a single report participant. | ||
* | ||
|
@@ -873,7 +884,8 @@ function getDisplayNameForParticipant(login, shouldUseShortForm = false) { | |
function getDisplayNamesWithTooltips(participants, isMultipleParticipantReport) { | ||
return _.map(participants, (participant) => { | ||
const displayName = getDisplayNameForParticipant(participant.login, isMultipleParticipantReport); | ||
const tooltip = participant.login ? Str.removeSMSDomain(participant.login) : ''; | ||
cloudpresser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const avatar = UserUtils.getDefaultAvatar(participant.login); | ||
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. I think this caused a regression where we are unable to load a user's uploaded/custom avatar in some cases as identified on #20683 I believe I've got a fix so will push it up and request reviews from ya'll. 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. PR is here #20727 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. @bondydaa The root cause of that issue is that we are not passing the |
||
const accountID = participant.accountID; | ||
|
||
let pronouns = participant.pronouns; | ||
if (pronouns && pronouns.startsWith(CONST.PRONOUNS.PREFIX)) { | ||
|
@@ -883,7 +895,9 @@ function getDisplayNamesWithTooltips(participants, isMultipleParticipantReport) | |
|
||
return { | ||
displayName, | ||
tooltip, | ||
avatar, | ||
login: participant.login, | ||
accountID, | ||
pronouns, | ||
}; | ||
}); | ||
|
@@ -2153,7 +2167,9 @@ function getParentReport(report) { | |
} | ||
|
||
export { | ||
getAccountIDForLogin, | ||
getReportParticipantsTitle, | ||
getPersonalDetailsForLogin, | ||
cloudpresser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
isReportMessageAttachment, | ||
findLastAccessedReport, | ||
canEditReportAction, | ||
|
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.
We didn't properly migrate the
shouldShowTooltip
prop toUserDetailsTooltip
which was being applied indirectly to the oldTooltip
via tooltipTexts at line 72.