-
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
[OldDot Rules Migration] Individual expense rules #47409
Merged
marcaaron
merged 38 commits into
Expensify:main
from
software-mansion-labs:rules/individual-expense-rules
Aug 26, 2024
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
82be201
Add IndividualExpenseRulesSection
WojtekBoman 7078618
Merge branch 'rules/toggle' into rules/individual-expense-rules
WojtekBoman f973e79
Add links to categories and tags pages
WojtekBoman 5cf7c48
Add individual expense rules rhp screens templates
WojtekBoman 8e10e14
Merge branch 'rules/toggle' into rules/individual-expense-rules
WojtekBoman 85e89df
Add types for individual expense rules number forms
WojtekBoman 18cb8b6
Handle displaying amount form as text input
WojtekBoman c356109
Add types for individual expense rules actions
WojtekBoman c61f3ca
Handle setPolicyMaxExpenseAmountNoReceipt action
WojtekBoman 57d8e9c
Handle setting billable mode
WojtekBoman d786f8f
Rename DEFAULT_MAX_EXPENSE_AMOUNT_NO_RECEIPT const to DISABLED_MAX_EX…
WojtekBoman fe1e10f
Handle setting max expense amount
WojtekBoman 3e6f02e
Handle toggling eReceipts
WojtekBoman 7f8c373
Cleanup rules forms
WojtekBoman d52c8be
Add suffixCharacter prop to BaseTextInput
WojtekBoman cdde66b
Add setPolicyMaxExpenseAge and cleanup rules actions
WojtekBoman d9aad75
Handle setting maxExpenseAge
WojtekBoman dc57a47
Handle link to Tags page on RulesBillableDefaultPage
WojtekBoman f62182d
Add maxLength to RulesMaxExpenseAgePage
WojtekBoman 706eec6
Adjust paddings on Rules pages
WojtekBoman 8af85ba
Cleanup rules actions
WojtekBoman 60f743d
Remove unused imports
WojtekBoman 70baaf1
Add missing docs for policy actions
WojtekBoman d58b903
Refactor onSubmit in RulesMaxExpenseAgePage
WojtekBoman e919113
Rename SetPolicyEReceiptsEnabled to SetWorkspaceEReceiptsEnabled
WojtekBoman b9b94b0
Add IndividualExpenseRulesSectionSubtitle
WojtekBoman 6d7b7a1
Refactor destructuring route params on rules pages
WojtekBoman 71b51f2
Add rules pages fixes
WojtekBoman b646d12
Add IndividualExpenseRulesMenuItems
WojtekBoman 1fd5711
Merge branch 'main' into rules/individual-expense-rules
WojtekBoman a5fb07b
Remove submit button from RulesBillableDefaultPage
WojtekBoman 12cf26b
Fix eReceipts accessibility label
WojtekBoman 9ced023
Add es translations for Individual Expense Rules section
WojtekBoman fee02c9
Adjust AmountForm for es locale
WojtekBoman 1739e7c
Wrap section items in OfflineWithFeedback
WojtekBoman 897b590
Add rules draft forms to ONYXKEYS
WojtekBoman 6804e6e
Fix AmountForm when is display as TextInput
WojtekBoman 3750539
Fix individual expense rules es translations
WojtekBoman 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 |
---|---|---|
|
@@ -61,11 +61,14 @@ function BaseTextInput( | |
shouldInterceptSwipe = false, | ||
autoCorrect = true, | ||
prefixCharacter = '', | ||
suffixCharacter = '', | ||
inputID, | ||
isMarkdownEnabled = false, | ||
shouldShowClearButton = false, | ||
prefixContainerStyle = [], | ||
prefixStyle = [], | ||
suffixContainerStyle = [], | ||
suffixStyle = [], | ||
contentWidth, | ||
...inputProps | ||
}: BaseTextInputProps, | ||
|
@@ -83,7 +86,7 @@ function BaseTextInput( | |
// Disabling this line for saftiness as nullish coalescing works only if value is undefined or null | ||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
const initialValue = value || defaultValue || ''; | ||
const initialActiveLabel = !!forceActiveLabel || initialValue.length > 0 || !!prefixCharacter; | ||
const initialActiveLabel = !!forceActiveLabel || initialValue.length > 0 || !!prefixCharacter || !!suffixCharacter; | ||
|
||
const [isFocused, setIsFocused] = useState(false); | ||
const [passwordHidden, setPasswordHidden] = useState(inputProps.secureTextEntry); | ||
|
@@ -142,13 +145,13 @@ function BaseTextInput( | |
const deactivateLabel = useCallback(() => { | ||
const newValue = value ?? ''; | ||
|
||
if (!!forceActiveLabel || newValue.length !== 0 || prefixCharacter) { | ||
if (!!forceActiveLabel || newValue.length !== 0 || prefixCharacter || suffixCharacter) { | ||
return; | ||
} | ||
|
||
animateLabel(styleConst.INACTIVE_LABEL_TRANSLATE_Y, styleConst.INACTIVE_LABEL_SCALE); | ||
isLabelActive.current = false; | ||
}, [animateLabel, forceActiveLabel, prefixCharacter, value]); | ||
}, [animateLabel, forceActiveLabel, prefixCharacter, suffixCharacter, value]); | ||
|
||
const onFocus = (event: NativeSyntheticEvent<TextInputFocusEventData>) => { | ||
inputProps.onFocus?.(event); | ||
|
@@ -245,7 +248,7 @@ function BaseTextInput( | |
// Disabling this line for safeness as nullish coalescing works only if the value is undefined or null, and errorText can be an empty string | ||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
const inputHelpText = errorText || hint; | ||
const newPlaceholder = !!prefixCharacter || isFocused || !hasLabel || (hasLabel && forceActiveLabel) ? placeholder : undefined; | ||
const newPlaceholder = !!prefixCharacter || !!suffixCharacter || isFocused || !hasLabel || (hasLabel && forceActiveLabel) ? placeholder : undefined; | ||
const newTextInputContainerStyles: StyleProp<ViewStyle> = StyleSheet.flatten([ | ||
styles.textInputContainer, | ||
textInputContainerStyles, | ||
|
@@ -276,6 +279,7 @@ function BaseTextInput( | |
}, [inputStyle]); | ||
|
||
const inputPaddingLeft = !!prefixCharacter && StyleUtils.getPaddingLeft(StyleUtils.getCharacterPadding(prefixCharacter) + styles.pl1.paddingLeft); | ||
const inputPaddingRight = !!suffixCharacter && StyleUtils.getPaddingRight(StyleUtils.getCharacterPadding(suffixCharacter) + styles.pr1.paddingRight); | ||
|
||
return ( | ||
<> | ||
|
@@ -366,6 +370,7 @@ function BaseTextInput( | |
inputStyle, | ||
(!hasLabel || isMultiline) && styles.pv0, | ||
inputPaddingLeft, | ||
inputPaddingRight, | ||
inputProps.secureTextEntry && styles.secureInput, | ||
|
||
// Explicitly remove `lineHeight` from single line inputs so that long text doesn't disappear | ||
|
@@ -402,6 +407,17 @@ function BaseTextInput( | |
defaultValue={defaultValue} | ||
markdownStyle={markdownStyle} | ||
/> | ||
{!!suffixCharacter && ( | ||
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.textInputSuffixWrapper, suffixContainerStyle]}> | ||
<Text | ||
tabIndex={-1} | ||
style={[styles.textInputSuffix, !hasLabel && styles.pv0, styles.pointerEventsNone, suffixStyle]} | ||
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}} | ||
> | ||
{suffixCharacter} | ||
</Text> | ||
</View> | ||
)} | ||
{isFocused && !isReadOnly && shouldShowClearButton && !!value && <TextInputClearButton onPressButton={() => setValue('')} />} | ||
{inputProps.isLoading && ( | ||
<ActivityIndicator | ||
|
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
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. @pecanoro @marcaaron |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
type SetPolicyBillableMode = { | ||
defaultBillable: boolean; | ||
/** | ||
* Stringified JSON object with type of following structure: | ||
* disabledFields: { | ||
* defaultBillable: boolean; | ||
* }; | ||
*/ | ||
disabledFields: string; | ||
}; | ||
|
||
export default SetPolicyBillableMode; |
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,6 @@ | ||
type SetPolicyExpenseMaxAge = { | ||
policyID: string; | ||
maxExpenseAge: number; | ||
}; | ||
|
||
export default SetPolicyExpenseMaxAge; |
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,6 @@ | ||
type SetPolicyExpenseMaxAmount = { | ||
policyID: string; | ||
maxExpenseAmount: number; | ||
}; | ||
|
||
export default SetPolicyExpenseMaxAmount; |
6 changes: 6 additions & 0 deletions
6
src/libs/API/parameters/SetPolicyExpenseMaxAmountNoReceipt.ts
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,6 @@ | ||
type SetPolicyExpenseMaxAmountNoReceipt = { | ||
policyID: string; | ||
maxExpenseAmountNoReceipt: number; | ||
}; | ||
|
||
export default SetPolicyExpenseMaxAmountNoReceipt; |
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,5 @@ | ||
type SetWorkspaceEReceiptsEnabled = { | ||
eReceipts: boolean; | ||
}; | ||
|
||
export default SetWorkspaceEReceiptsEnabled; |
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.
I'll add descriptions for both in my PR