-
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
#45951 & #45958: Implement <ApprovalWorkflowSection /> component and Enhance toLocaleOrdinal to support string ordinals #46562
Merged
tgolen
merged 29 commits into
Expensify:main
from
software-mansion-labs:Guccio163/45951_implementApprovalWorkflowSection
Aug 5, 2024
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
517bf4d
Update readme
blazejkustra 650eda9
wip
Guccio163 9e72afd
Merge branch 'Guccio163/45949-divide_workflows' of github.com:softwar…
Guccio163 c91b34a
section ready, subsections not working
Guccio163 dd28d1b
useMemo and ts fix
Guccio163 581997b
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 27cebe1
add navigation to approval edit
Guccio163 822b5c5
approverName and menuItem propagation problem
Guccio163 c83040a
Merge branch 'approval-workflows/toLocaleOrdinal' into Guccio163/4595…
Guccio163 ab4c82f
toLocaleOrdinal fix, linking to approval section
Guccio163 3df09af
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 7d6b856
Temp deleted, sections' props added
Guccio163 42c370f
undo react-native.d.ts change
Guccio163 d8291fd
undo package.json
Guccio163 9659c61
toLocale fix2, updates
Guccio163 741cd37
unclickable MenuItem fixed
Guccio163 ca527d1
approver naming fixed
Guccio163 f4ea901
Merge branch 'main' into Guccio163/45951_implementApprovalWorkflowSec…
blazejkustra acf2425
Merge branch 'main' into Guccio163/45951_implementApprovalWorkflowSec…
blazejkustra aa3d60c
Fix design issues
blazejkustra 6564afe
Update user-check icon
blazejkustra 22df581
Change the icon to the correct one
blazejkustra a639123
Merge branch 'main' into Guccio163/45951_implementApprovalWorkflowSec…
blazejkustra fc835a1
Move vertical line styles
blazejkustra 27e14eb
Merge branch 'main' into Guccio163/45951_implementApprovalWorkflowSec…
blazejkustra 04f7776
toLocaleString refactor
Guccio163 88d6894
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 5478c6e
safeguard approvers' keys
Guccio163 6fb0b6e
props annotations
Guccio163 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import React, {useCallback} from 'react'; | ||
import {View} from 'react-native'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useTheme from '@hooks/useTheme'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import useWindowDimensions from '@hooks/useWindowDimensions'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import ROUTES from '@src/ROUTES'; | ||
import type ApprovalWorkflow from '@src/types/onyx/ApprovalWorkflow'; | ||
import Icon from './Icon'; | ||
import * as Expensicons from './Icon/Expensicons'; | ||
import MenuItem from './MenuItem'; | ||
import PressableWithoutFeedback from './Pressable/PressableWithoutFeedback'; | ||
import Text from './Text'; | ||
|
||
type ApprovalWorkflowSectionProps = { | ||
/** Single workflow displayed in this component */ | ||
approvalWorkflow: ApprovalWorkflow; | ||
|
||
/** ID of the policy */ | ||
policyId?: string; | ||
}; | ||
|
||
function ApprovalWorkflowSection({approvalWorkflow, policyId}: ApprovalWorkflowSectionProps) { | ||
const styles = useThemeStyles(); | ||
const theme = useTheme(); | ||
const {translate, toLocaleOrdinal} = useLocalize(); | ||
const {isSmallScreenWidth} = useWindowDimensions(); | ||
const openApprovalsEdit = useCallback( | ||
() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_EDIT.getRoute(policyId ?? '', approvalWorkflow.approvers[0].email)), | ||
[approvalWorkflow.approvers, policyId], | ||
); | ||
const approverTitle = useCallback( | ||
(index: number) => | ||
approvalWorkflow.approvers.length > 1 ? `${toLocaleOrdinal(index + 1, true)} ${translate('workflowsPage.approver').toLowerCase()}` : `${translate('workflowsPage.approver')}`, | ||
[approvalWorkflow.approvers.length, toLocaleOrdinal, translate], | ||
); | ||
|
||
return ( | ||
<PressableWithoutFeedback | ||
accessibilityRole="button" | ||
style={[styles.border, isSmallScreenWidth ? styles.p3 : styles.p4, styles.flexRow, styles.justifyContentBetween, styles.mt6, styles.mbn3]} | ||
onPress={openApprovalsEdit} | ||
accessibilityLabel={translate('workflowsPage.addApprovalsTitle')} | ||
> | ||
<View style={[styles.flex1]}> | ||
{approvalWorkflow.isDefault && ( | ||
<View style={[styles.flexRow, styles.mb4, styles.alignItemsCenter, styles.pb1, styles.pt1]}> | ||
<Icon | ||
src={Expensicons.Lightbulb} | ||
fill={theme.icon} | ||
additionalStyles={styles.mr2} | ||
small | ||
/> | ||
<Text | ||
style={[styles.textLabelSupportingNormal]} | ||
suppressHighlighting | ||
> | ||
{translate('workflowsPage.addApprovalTip')} | ||
</Text> | ||
</View> | ||
)} | ||
<MenuItem | ||
title={translate('workflowsExpensesFromPage.title')} | ||
style={styles.p0} | ||
titleStyle={styles.textLabelSupportingNormal} | ||
descriptionTextStyle={styles.textNormalThemeText} | ||
description={approvalWorkflow.isDefault ? translate('workspace.common.everyone') : approvalWorkflow.members.map((m) => m.displayName).join(', ')} | ||
icon={Expensicons.Users} | ||
iconHeight={20} | ||
iconWidth={20} | ||
iconFill={theme.icon} | ||
onPress={openApprovalsEdit} | ||
shouldRemoveBackground | ||
/> | ||
|
||
{approvalWorkflow.approvers.map((approver, index) => ( | ||
// eslint-disable-next-line react/no-array-index-key | ||
<View key={`approver-${approver.email}-${index}`}> | ||
<View style={styles.workflowApprovalVerticalLine} /> | ||
<MenuItem | ||
title={approverTitle(index)} | ||
style={styles.p0} | ||
titleStyle={styles.textLabelSupportingNormal} | ||
descriptionTextStyle={styles.textNormalThemeText} | ||
description={approver.displayName} | ||
icon={Expensicons.UserCheck} | ||
iconHeight={20} | ||
iconWidth={20} | ||
iconFill={theme.icon} | ||
onPress={openApprovalsEdit} | ||
shouldRemoveBackground | ||
/> | ||
</View> | ||
))} | ||
</View> | ||
<Icon | ||
src={Expensicons.ArrowRight} | ||
fill={theme.icon} | ||
additionalStyles={[styles.alignSelfCenter]} | ||
/> | ||
</PressableWithoutFeedback> | ||
); | ||
} | ||
|
||
export default ApprovalWorkflowSection; |
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
Oops, something went wrong.
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.
Please add
/** */
style comments to each propThere 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.
Just added, please take a quick look if they're okay :)