-
Notifications
You must be signed in to change notification settings - Fork 3.7k
refactor: Explain feature icon to match brand guidelines and update link press handling #83169
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
365aab9
6590c3f
3beef1f
a1ee238
29d092b
9c4a325
ad5529e
81576f7
99f9c6f
56a1711
3cd1ddf
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,14 +1,20 @@ | ||
| import React from 'react'; | ||
| import type {GestureResponderEvent} from 'react-native'; | ||
| import {View} from 'react-native'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import Icon from '@components/Icon'; | ||
| import RenderHTML from '@components/RenderHTML'; | ||
| import TextBlock from '@components/TextBlock'; | ||
| import TextLinkBlock from '@components/TextLinkBlock'; | ||
| import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; | ||
| import useEnvironment from '@hooks/useEnvironment'; | ||
| import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {openLink} from '@libs/actions/Link'; | ||
| import {explain} from '@libs/actions/Report'; | ||
| import {hasReasoning} from '@libs/ReportActionsUtils'; | ||
| import CONST from '@src/CONST'; | ||
| import variables from '@styles/variables'; | ||
| import type {Report, ReportAction} from '@src/types/onyx'; | ||
| import ReportActionItemBasicMessage from './ReportActionItemBasicMessage'; | ||
|
|
||
|
|
@@ -31,31 +37,49 @@ type ReportActionItemMessageWithExplainProps = { | |
| * if the action has reasoning. | ||
| */ | ||
| function ReportActionItemMessageWithExplain({message, action, childReport, originalReport}: ReportActionItemMessageWithExplainProps) { | ||
| const theme = useTheme(); | ||
| const styles = useThemeStyles(); | ||
| const {translate} = useLocalize(); | ||
| const personalDetail = useCurrentUserPersonalDetails(); | ||
| const icons = useMemoizedLazyExpensifyIcons(['Sparkles']); | ||
| const {environmentURL} = useEnvironment(); | ||
|
|
||
| const actionHasReasoning = hasReasoning(action); | ||
| const computedMessage = actionHasReasoning ? `${message}${translate('iou.AskToExplain')}` : message; | ||
|
|
||
| const handleLinkPress = (event: GestureResponderEvent | KeyboardEvent, href: string) => { | ||
| // Handle the special "Explain" link | ||
| if (href.endsWith(CONST.CONCIERGE_EXPLAIN_LINK_PATH)) { | ||
| explain(childReport, originalReport, action, translate, personalDetail.accountID, personalDetail?.timezone); | ||
| return; | ||
| } | ||
|
|
||
| // For all other links, use the default link handler | ||
| openLink(href, environmentURL); | ||
| }; | ||
| if (!actionHasReasoning) { | ||
| return ( | ||
| <ReportActionItemBasicMessage> | ||
| <RenderHTML | ||
| html={`<comment><muted-text>${message}</muted-text></comment>`} | ||
| onLinkPress={(event, href) => { | ||
| openLink(href, environmentURL); | ||
| }} | ||
| /> | ||
| </ReportActionItemBasicMessage> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <ReportActionItemBasicMessage> | ||
| <RenderHTML | ||
| html={`<comment><muted-text>${computedMessage}</muted-text></comment>`} | ||
| isSelectable={false} | ||
| onLinkPress={handleLinkPress} | ||
| /> | ||
| <View style={[styles.flexRow, styles.alignItemsCenter, styles.flexWrap]}> | ||
| <TextBlock | ||
| textStyles={[styles.chatItemMessage, styles.colorMuted]} | ||
| text={`${message}. `} | ||
| /> | ||
|
Comment on lines
+65
to
+68
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.
In the Useful? React with 👍 / 👎.
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. WDYT about this comment @samranahm ?
This comment was marked as outdated.
Sorry, something went wrong.
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. @FitseTLT I noticed that
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. |
||
| <View style={[styles.flexRow, styles.alignItemsCenter]}> | ||
| <TextLinkBlock | ||
| onPress={() => explain(childReport, originalReport, action, translate, personalDetail.accountID, personalDetail?.timezone)} | ||
| style={[styles.chatItemMessage, styles.link, styles.mrHalf]} | ||
| text={translate('common.explain')} | ||
| /> | ||
| <Icon | ||
| src={icons.Sparkles} | ||
| width={variables.iconSizeExtraSmall} | ||
| height={variables.iconSizeExtraSmall} | ||
| fill={theme.link} | ||
| /> | ||
| </View> | ||
| </View> | ||
| </ReportActionItemBasicMessage> | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,6 +143,10 @@ export default { | |
| marginRight: 0, | ||
| }, | ||
|
|
||
| mrHalf: { | ||
| marginRight: 2, | ||
| }, | ||
|
|
||
| mr1: { | ||
| marginRight: 4, | ||
| }, | ||
|
|
||
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.