-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add manager mctest tooltips to create expense flow #56759
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
Changes from all commits
d00e200
48e1b1b
542c3cb
70aa35a
f06c76c
85cfe40
251ce24
d406483
df45451
e3e53aa
ff9e9d9
3103933
b1a180e
d300a34
e27157d
684569d
bc1cc21
6602c34
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 |
|---|---|---|
| @@ -1,18 +1,24 @@ | ||
| import {Str} from 'expensify-common'; | ||
| import React, {useCallback} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import {useOnyx} from 'react-native-onyx'; | ||
| import {FallbackAvatar} from '@components/Icon/Expensicons'; | ||
| import MultipleAvatars from '@components/MultipleAvatars'; | ||
| import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; | ||
| import {useProductTrainingContext} from '@components/ProductTrainingContext'; | ||
| import SelectCircle from '@components/SelectCircle'; | ||
| import SubscriptAvatar from '@components/SubscriptAvatar'; | ||
| import Text from '@components/Text'; | ||
| import TextWithTooltip from '@components/TextWithTooltip'; | ||
| import EducationalTooltip from '@components/Tooltip/EducationalTooltip'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useStyleUtils from '@hooks/useStyleUtils'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {getIsUserSubmittedExpenseOrScannedReceipt, isSelectedManagerMcTest} from '@libs/OptionsListUtils'; | ||
| import Permissions from '@libs/Permissions'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type {Icon} from '@src/types/onyx/OnyxCommon'; | ||
| import BaseListItem from './BaseListItem'; | ||
| import type {InviteMemberListItemProps, ListItem} from './types'; | ||
|
|
@@ -42,6 +48,11 @@ function InviteMemberListItem<TItem extends ListItem>({ | |
| const theme = useTheme(); | ||
| const StyleUtils = useStyleUtils(); | ||
| const {translate} = useLocalize(); | ||
| const [betas] = useOnyx(ONYXKEYS.BETAS); | ||
| const {renderProductTrainingTooltip, shouldShowProductTrainingTooltip} = useProductTrainingContext( | ||
| CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP_MANAGER, | ||
| !getIsUserSubmittedExpenseOrScannedReceipt() && Permissions.canUseManagerMcTest(betas) && isSelectedManagerMcTest(item.login), | ||
| ); | ||
|
|
||
| const focusedBackgroundColor = styles.sidebarLinkActive.backgroundColor; | ||
| const subscriptAvatarBorderColor = isFocused ? focusedBackgroundColor : theme.sidebar; | ||
|
|
@@ -84,64 +95,75 @@ function InviteMemberListItem<TItem extends ListItem>({ | |
| shouldDisplayRBR={!shouldShowCheckBox} | ||
| > | ||
| {(hovered?: boolean) => ( | ||
| <> | ||
| {!!item.icons && | ||
| (item.shouldShowSubscript ? ( | ||
| <SubscriptAvatar | ||
| mainAvatar={item.icons.at(0) ?? fallbackIcon} | ||
| secondaryAvatar={item.icons.at(1)} | ||
| showTooltip={showTooltip} | ||
| backgroundColor={hovered && !isFocused ? hoveredBackgroundColor : subscriptAvatarBorderColor} | ||
| /> | ||
| ) : ( | ||
| <MultipleAvatars | ||
| icons={item.icons} | ||
| shouldShowTooltip={showTooltip} | ||
| secondAvatarStyle={[ | ||
| StyleUtils.getBackgroundAndBorderStyle(theme.sidebar), | ||
| isFocused ? StyleUtils.getBackgroundAndBorderStyle(focusedBackgroundColor) : undefined, | ||
| hovered && !isFocused ? StyleUtils.getBackgroundAndBorderStyle(hoveredBackgroundColor) : undefined, | ||
| ]} | ||
| /> | ||
| ))} | ||
| <View style={[styles.flex1, styles.flexColumn, styles.justifyContentCenter, styles.alignItemsStretch, styles.optionRow]}> | ||
| <View style={[styles.flexRow, styles.alignItemsCenter]}> | ||
| <TextWithTooltip | ||
| shouldShowTooltip={showTooltip} | ||
| text={Str.removeSMSDomain(item.text ?? '')} | ||
| style={[ | ||
| styles.optionDisplayName, | ||
| isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText, | ||
| item.isBold !== false && styles.sidebarLinkTextBold, | ||
| styles.pre, | ||
| item.alternateText ? styles.mb1 : null, | ||
| ]} | ||
| /> | ||
| <EducationalTooltip | ||
|
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. NAB: Becasue InviteMemberListItem is used in many places, for more safe, Let's add a condition to make sure that the education tooltips only display on create expense flow
Contributor
Author
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. Same here |
||
| shouldRender={shouldShowProductTrainingTooltip} | ||
| renderTooltipContent={renderProductTrainingTooltip} | ||
| anchorAlignment={{ | ||
| horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, | ||
| vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP, | ||
| }} | ||
| shouldHideOnNavigate | ||
| wrapperStyle={styles.productTrainingTooltipWrapper} | ||
| > | ||
| <View style={[styles.flexRow, styles.alignItemsCenter, styles.flex1]}> | ||
| {!!item.icons && | ||
| (item.shouldShowSubscript ? ( | ||
| <SubscriptAvatar | ||
| mainAvatar={item.icons.at(0) ?? fallbackIcon} | ||
| secondaryAvatar={item.icons.at(1)} | ||
| showTooltip={showTooltip} | ||
| backgroundColor={hovered && !isFocused ? hoveredBackgroundColor : subscriptAvatarBorderColor} | ||
| /> | ||
| ) : ( | ||
| <MultipleAvatars | ||
| icons={item.icons} | ||
| shouldShowTooltip={showTooltip} | ||
| secondAvatarStyle={[ | ||
| StyleUtils.getBackgroundAndBorderStyle(theme.sidebar), | ||
| isFocused ? StyleUtils.getBackgroundAndBorderStyle(focusedBackgroundColor) : undefined, | ||
| hovered && !isFocused ? StyleUtils.getBackgroundAndBorderStyle(hoveredBackgroundColor) : undefined, | ||
| ]} | ||
| /> | ||
| ))} | ||
| <View style={[styles.flex1, styles.flexColumn, styles.justifyContentCenter, styles.alignItemsStretch, styles.optionRow]}> | ||
| <View style={[styles.flexRow, styles.alignItemsCenter]}> | ||
| <TextWithTooltip | ||
| shouldShowTooltip={showTooltip} | ||
| text={Str.removeSMSDomain(item.text ?? '')} | ||
| style={[ | ||
| styles.optionDisplayName, | ||
| isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText, | ||
| item.isBold !== false && styles.sidebarLinkTextBold, | ||
| styles.pre, | ||
| item.alternateText ? styles.mb1 : null, | ||
| ]} | ||
| /> | ||
| </View> | ||
| {!!item.alternateText && ( | ||
| <TextWithTooltip | ||
| shouldShowTooltip={showTooltip} | ||
| text={Str.removeSMSDomain(item.alternateText ?? '')} | ||
| style={[styles.textLabelSupporting, styles.lh16, styles.pre]} | ||
| /> | ||
| )} | ||
| </View> | ||
| {!!item.alternateText && ( | ||
| <TextWithTooltip | ||
| shouldShowTooltip={showTooltip} | ||
| text={Str.removeSMSDomain(item.alternateText ?? '')} | ||
| style={[styles.textLabelSupporting, styles.lh16, styles.pre]} | ||
| /> | ||
| {!!item.rightElement && item.rightElement} | ||
| {!!shouldShowCheckBox && ( | ||
| <PressableWithFeedback | ||
| onPress={handleCheckboxPress} | ||
| disabled={isDisabled} | ||
| role={CONST.ROLE.BUTTON} | ||
| accessibilityLabel={item.text ?? ''} | ||
| style={[styles.ml2, styles.optionSelectCircle]} | ||
| > | ||
| <SelectCircle | ||
| isChecked={item.isSelected ?? false} | ||
| selectCircleStyles={styles.ml0} | ||
| /> | ||
| </PressableWithFeedback> | ||
| )} | ||
| </View> | ||
| {!!item.rightElement && item.rightElement} | ||
| {!!shouldShowCheckBox && ( | ||
| <PressableWithFeedback | ||
| onPress={handleCheckboxPress} | ||
| disabled={isDisabled} | ||
| role={CONST.ROLE.BUTTON} | ||
| accessibilityLabel={item.text ?? ''} | ||
| style={[styles.ml2, styles.optionSelectCircle]} | ||
| > | ||
| <SelectCircle | ||
| isChecked={item.isSelected ?? false} | ||
| selectCircleStyles={styles.ml0} | ||
| /> | ||
| </PressableWithFeedback> | ||
| )} | ||
| </> | ||
| </EducationalTooltip> | ||
| )} | ||
| </BaseListItem> | ||
| ); | ||
|
|
||
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.
NAB: But let's add a condition for more safe
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.
I am not sure if this is needed its already handled by
shouldShowProductTrainingTooltipso if we add this condition we would basically made the same condition which we are passing touseProductTrainingContext