-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Show Product tooltip for Workspace participant on create expense #56041
Open
parasharrajat
wants to merge
9
commits into
Expensify:main
Choose a base branch
from
parasharrajat:parasharrajat/tooltip
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+179
−89
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3ea44f9
Show tooltip for Workspace participant on create expense
parasharrajat 9023f08
Update messages and condition to show the tooltip
parasharrajat 770f4b4
HideToolip on press
parasharrajat 1ab8670
type fixes
parasharrajat e548bf3
revert the extra change
parasharrajat 5ed00f1
Merge branch 'main' of github.com:Expensify/App into parasharrajat/to…
parasharrajat 4a4a517
Merge branch 'main' of github.com:Expensify/App into parasharrajat/to…
parasharrajat ba81016
Rename tooltip
parasharrajat a6d2eea
Rename
parasharrajat 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -4,14 +4,17 @@ import {View} from 'react-native'; | |
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 variables from '@styles/variables'; | ||
import CONST from '@src/CONST'; | ||
import type {Icon} from '@src/types/onyx/OnyxCommon'; | ||
import BaseListItem from './BaseListItem'; | ||
|
@@ -37,6 +40,7 @@ function InviteMemberListItem<TItem extends ListItem>({ | |
onFocus, | ||
shouldSyncFocus, | ||
shouldHighlightSelectedItem, | ||
shouldShowEducationalTooltip = false, | ||
}: InviteMemberListItemProps<TItem>) { | ||
const styles = useThemeStyles(); | ||
const theme = useTheme(); | ||
|
@@ -49,6 +53,11 @@ function InviteMemberListItem<TItem extends ListItem>({ | |
|
||
const shouldShowCheckBox = canSelectMultiple && !item.isDisabled; | ||
|
||
const {renderProductTrainingTooltip, shouldShowProductTrainingTooltip, hideProductTrainingTooltip} = useProductTrainingContext( | ||
CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.WORKSPACE_EXPENSE_SUBMIT, | ||
shouldShowEducationalTooltip, | ||
); | ||
|
||
const handleCheckboxPress = useCallback(() => { | ||
if (onCheckboxPress) { | ||
onCheckboxPress(item); | ||
|
@@ -58,92 +67,108 @@ function InviteMemberListItem<TItem extends ListItem>({ | |
}, [item, onCheckboxPress, onSelectRow]); | ||
|
||
return ( | ||
<BaseListItem | ||
pressableStyle={[[shouldHighlightSelectedItem && item.isSelected && styles.activeComponentBG]]} | ||
item={item} | ||
wrapperStyle={[styles.flex1, styles.justifyContentBetween, styles.sidebarLinkInner, styles.userSelectNone, styles.peopleRow]} | ||
isFocused={isFocused} | ||
isDisabled={isDisabled} | ||
showTooltip={showTooltip} | ||
canSelectMultiple={canSelectMultiple} | ||
onSelectRow={onSelectRow} | ||
onDismissError={onDismissError} | ||
rightHandSideComponent={rightHandSideComponent} | ||
errors={item.errors} | ||
pendingAction={item.pendingAction} | ||
FooterComponent={ | ||
item.invitedSecondaryLogin ? ( | ||
<Text style={[styles.ml9, styles.ph5, styles.pb3, styles.textLabelSupporting]}> | ||
{translate('workspace.people.invitedBySecondaryLogin', {secondaryLogin: item.invitedSecondaryLogin})} | ||
</Text> | ||
) : undefined | ||
} | ||
keyForList={item.keyForList} | ||
onFocus={onFocus} | ||
shouldSyncFocus={shouldSyncFocus} | ||
shouldDisplayRBR={!shouldShowCheckBox} | ||
<EducationalTooltip | ||
shouldRender={shouldShowProductTrainingTooltip} | ||
anchorAlignment={{ | ||
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP, | ||
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, | ||
}} | ||
shiftHorizontal={variables.workspaceLHNtooltipShiftHorizontal} | ||
shiftVertical={variables.composerTooltipShiftVertical} | ||
wrapperStyle={styles.productTrainingTooltipWrapper} | ||
renderTooltipContent={renderProductTrainingTooltip} | ||
onTooltipPress={hideProductTrainingTooltip} | ||
> | ||
{(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, | ||
]} | ||
/> | ||
</View> | ||
{!!item.alternateText && ( | ||
<TextWithTooltip | ||
shouldShowTooltip={showTooltip} | ||
text={Str.removeSMSDomain(item.alternateText ?? '')} | ||
style={[styles.textLabelSupporting, styles.lh16, styles.pre]} | ||
/> | ||
)} | ||
</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> | ||
<View> | ||
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. Hi @parasharrajat is it necessary to wrap existing into a 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. Yes, otherwise tooltip does not render. |
||
<BaseListItem | ||
pressableStyle={[[shouldHighlightSelectedItem && item.isSelected && styles.activeComponentBG]]} | ||
item={item} | ||
wrapperStyle={[styles.flex1, styles.justifyContentBetween, styles.sidebarLinkInner, styles.userSelectNone, styles.peopleRow]} | ||
isFocused={isFocused} | ||
isDisabled={isDisabled} | ||
showTooltip={showTooltip} | ||
canSelectMultiple={canSelectMultiple} | ||
onSelectRow={onSelectRow} | ||
onDismissError={onDismissError} | ||
rightHandSideComponent={rightHandSideComponent} | ||
errors={item.errors} | ||
pendingAction={item.pendingAction} | ||
FooterComponent={ | ||
item.invitedSecondaryLogin ? ( | ||
<Text style={[styles.ml9, styles.ph5, styles.pb3, styles.textLabelSupporting]}> | ||
{translate('workspace.people.invitedBySecondaryLogin', {secondaryLogin: item.invitedSecondaryLogin})} | ||
</Text> | ||
) : undefined | ||
} | ||
keyForList={item.keyForList} | ||
onFocus={onFocus} | ||
shouldSyncFocus={shouldSyncFocus} | ||
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, | ||
]} | ||
/> | ||
</View> | ||
{!!item.alternateText && ( | ||
<TextWithTooltip | ||
shouldShowTooltip={showTooltip} | ||
text={Str.removeSMSDomain(item.alternateText ?? '')} | ||
style={[styles.textLabelSupporting, styles.lh16, styles.pre]} | ||
/> | ||
)} | ||
</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> | ||
)} | ||
</> | ||
)} | ||
</> | ||
)} | ||
</BaseListItem> | ||
</BaseListItem> | ||
</View> | ||
</EducationalTooltip> | ||
); | ||
} | ||
|
||
|
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.
should we name it as
getShouldShowEducationalTooltip
? Atm, when I read the code, sometimesshouldShowEducationalTooltip
is a func, sometimes it's a boolean.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.
Not necessarily needed. I can rename it if needed but we can't use two verbs
get
orshould
together.