-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix: Add accounting connection logo in Categories when connected to integration. #68410
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1d78c3f
fix: Add accounting connection logo in Categories when connected to i…
Krishna2323 37dc472
add ImportedFromAccountingSoftware.tsx.
Krishna2323 79043cb
fix categories page rendering.
Krishna2323 c0b269a
Merge branch 'Expensify:main' into krishna2323/issue/67901
Krishna2323 20c6f5c
create TextLinkBlock component for aligning the icon.
Krishna2323 9031142
fix icon alignment on native devices.
Krishna2323 6934f01
fix ESLint.
Krishna2323 df5f2ea
fix icon floating issue.
Krishna2323 d0aa899
fix spacing.
Krishna2323 8405b82
remove environmentURL prop from TextLinkBlock.
Krishna2323 c85c955
fix ESLint.
Krishna2323 ead3cb9
Merge branch 'Expensify:main' into krishna2323/issue/67901
Krishna2323 baab803
fix ESLint.
Krishna2323 6e55339
add style for dInline.
Krishna2323 f16408f
Merge branch 'Expensify:main' into krishna2323/issue/67901
Krishna2323 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import useEnvironment from '@hooks/useEnvironment'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useStyleUtils from '@hooks/useStyleUtils'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {getIntegrationIcon} from '@libs/ReportUtils'; | ||
| import variables from '@styles/variables'; | ||
| import CONST from '@src/CONST'; | ||
| import ROUTES from '@src/ROUTES'; | ||
| import type {ConnectionName} from '@src/types/onyx/Policy'; | ||
| import Icon from './Icon'; | ||
| import Text from './Text'; | ||
| import TextBlock from './TextBlock'; | ||
| import TextLinkBlock from './TextLinkBlock'; | ||
|
|
||
| type ImportedFromAccountingSoftwareProps = { | ||
| /** The policy ID to link to */ | ||
| policyID: string; | ||
|
|
||
| /** The name of the current connection */ | ||
| currentConnectionName: string; | ||
|
|
||
| /** The connected integration */ | ||
| connectedIntegration: ConnectionName | undefined; | ||
|
|
||
| /** The translated text for the "imported from" message */ | ||
| translatedText: string; | ||
| }; | ||
|
|
||
| function ImportedFromAccountingSoftware({policyID, currentConnectionName, translatedText, connectedIntegration}: ImportedFromAccountingSoftwareProps) { | ||
| const styles = useThemeStyles(); | ||
| const StyleUtils = useStyleUtils(); | ||
| const {translate} = useLocalize(); | ||
| const {environmentURL} = useEnvironment(); | ||
| const icon = getIntegrationIcon(connectedIntegration); | ||
|
|
||
| return ( | ||
| <View style={[styles.alignItemsCenter, styles.flexRow, styles.flexWrap]}> | ||
| <TextBlock | ||
| textStyles={[styles.textNormal, styles.colorMuted]} | ||
| text={`${translatedText} `} | ||
| /> | ||
| <TextLinkBlock | ||
| style={[styles.textNormal, styles.link]} | ||
| href={`${environmentURL}/${ROUTES.POLICY_ACCOUNTING.getRoute(policyID)}`} | ||
| text={`${currentConnectionName} ${translate('workspace.accounting.settings')}`} | ||
| prefixIcon={ | ||
| icon ? ( | ||
| <Icon | ||
| src={icon} | ||
| height={variables.iconSizeMedium} | ||
| width={variables.iconSizeMedium} | ||
| additionalStyles={[StyleUtils.getAvatarBorderStyle(CONST.AVATAR_SIZE.SMALLER, ''), styles.appBG]} | ||
| /> | ||
| ) : undefined | ||
| } | ||
| /> | ||
| <Text style={[styles.textNormal, styles.colorMuted]}>.</Text> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| ImportedFromAccountingSoftware.displayName = 'ImportedFromAccountingSoftware'; | ||
|
|
||
| export default ImportedFromAccountingSoftware; |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /** | ||
| * TextLinkBlock component splits a given text into individual words and displays | ||
| * each word within a TextLink component so the link text wraps naturally. | ||
| */ | ||
| import React, {memo, useMemo} from 'react'; | ||
| import type {StyleProp, TextStyle} from 'react-native'; | ||
| import {View} from 'react-native'; | ||
| import useEnvironment from '@hooks/useEnvironment'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {openLink as openLinkUtil} from '@userActions/Link'; | ||
| import CONST from '@src/CONST'; | ||
| import {PressableWithoutFeedback} from './Pressable'; | ||
| import Text from './Text'; | ||
| import TextLink from './TextLink'; | ||
| import type {LinkProps, PressProps} from './TextLink'; | ||
|
|
||
| type TextLinkBlockProps = (LinkProps | PressProps) & { | ||
| /** Styles to apply to each word */ | ||
| style?: StyleProp<TextStyle>; | ||
|
|
||
| /** The full text to be split into words */ | ||
| text: string; | ||
|
|
||
| /** The full text to be split into words */ | ||
| prefixIcon?: React.JSX.Element; | ||
| }; | ||
|
|
||
| function TextLinkBlock({text, style, prefixIcon, ...rest}: TextLinkBlockProps) { | ||
| const words = useMemo(() => text.match(/(\S+\s*)/g) ?? [], [text]); | ||
|
|
||
| const {environmentURL} = useEnvironment(); | ||
| const styles = useThemeStyles(); | ||
|
|
||
| const openLink = () => { | ||
| if (!rest.href) { | ||
| return; | ||
| } | ||
| openLinkUtil(rest.href, environmentURL); | ||
| }; | ||
|
|
||
| return ( | ||
| <PressableWithoutFeedback | ||
| role={CONST.ROLE.BUTTON} | ||
| style={styles.dContents} | ||
| onPress={openLink} | ||
| accessible | ||
| accessibilityLabel={rest.href ?? CONST.ROLE.BUTTON} | ||
| > | ||
| {words.map((word, index) => ( | ||
| <View | ||
| // eslint-disable-next-line react/no-array-index-key | ||
| key={`${word}-${index}`} | ||
| style={[styles.dInlineFlex, styles.alignItemsCenter, styles.flexRow]} | ||
| > | ||
| {prefixIcon && index === 0 && prefixIcon} | ||
| {!!prefixIcon && index === 0 && <Text> </Text>} | ||
| <TextLink | ||
| style={style} | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| {...rest} | ||
| > | ||
| {word} | ||
| </TextLink> | ||
| </View> | ||
| ))} | ||
| </PressableWithoutFeedback> | ||
| ); | ||
| } | ||
|
|
||
| TextLinkBlock.displayName = 'TextLinkBlock'; | ||
|
|
||
| export default memo(TextLinkBlock); | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Let's make the icon as a link as well.