-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add default/delete popover and supporting methods #4437
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
115 commits
Select commit
Hold shift + click to select a range
4d323c9
Add default/delete popover and supporting methods
stitesExpensify 8e2ae55
Add popover and merge master
stitesExpensify 3600ee6
Add ability to delete account and add scaffold for default
stitesExpensify b41716b
Correctly set password
stitesExpensify 182a825
Move everything into a view to style easier
stitesExpensify 0846fb8
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify b05c214
Merge commit 'refs/pull/4456/head' of github.com:Expensify/App into s…
stitesExpensify 2874ede
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify 6fbaf8d
Add new method for setting default wallet
stitesExpensify 101d765
Send the whole payment method rather than just the id
stitesExpensify a2331bf
Update password component to call either default or delete
stitesExpensify 6bc3cf3
Add ability to delete bank accounts
stitesExpensify a09a55a
Add ability to delete cards
stitesExpensify ca180ae
Add autofocus and hide input since it's a password
stitesExpensify 386a97c
Move password popover to its own component
stitesExpensify 43b5d12
Move password popover to its own component
stitesExpensify 5bd6855
Convert the rest of the file to work with the new password popover
stitesExpensify d176916
Translate enter password text
stitesExpensify 70b9383
Make enter work when entering password
stitesExpensify bef952c
fix onSubmit call
stitesExpensify 658d2e9
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify cb1c713
Style
stitesExpensify 150770d
Add default badge
stitesExpensify ac8f1eb
Style and defaults
stitesExpensify 11f9278
Fix the card key
stitesExpensify 0c01854
Update onyx when we finish setting the default
stitesExpensify aa0c6e9
Add growl
stitesExpensify 55ff7fd
Check jsonCode and add failure growl
stitesExpensify 959ae41
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify d27815a
Remove password requirement for deleting payments
stitesExpensify 4d1c703
Remove password rewquirement from deleteBankAccount
stitesExpensify 712a49e
Fix credit card import
stitesExpensify a31a10f
Fix password form styles
stitesExpensify a607f9d
Style
stitesExpensify 3c45efe
Remove test log
stitesExpensify c7ace3b
Call correct API method and rename action function
stitesExpensify 9a6dbde
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify 296d6cb
Remove duplicate deleteBankAccount
stitesExpensify 4921fa6
Remove duplicate export
stitesExpensify 5362000
Get cards/banks as an object so that we can delete them easily
stitesExpensify eddab69
keep types consistent
stitesExpensify d5da408
Remove fund from onyx when we delete it
stitesExpensify db4036f
Delete bank account from onyx after we delete it
stitesExpensify 12cc3f3
Don't require ownerEmail, it's an optional param
stitesExpensify fc013a4
Only delete from onyx if the call was successful
stitesExpensify e85eaf2
Fix deleting paypal.me by creating a new method
stitesExpensify 2fad483
Remove unused imports
stitesExpensify e3c7a9e
Add error message for set default failure
stitesExpensify dfdf73e
Add error case for deleting a debit card
stitesExpensify 4fba80c
Catch failure to delete bank account
stitesExpensify 5fbefc7
Auto focus password input
stitesExpensify 9c3dffc
Create new confirm popover component
stitesExpensify bae80dd
Add confirmation popover for deleting accounts
stitesExpensify aa00105
update styles
stitesExpensify 9cc2d27
add success growls for deleting accounts
stitesExpensify bc09dcd
Add success growl for deleting paypal.me
stitesExpensify 41309f1
Switch from buttons to touchableOpacity
stitesExpensify bbd5ed2
Use header instead of text
stitesExpensify d9634e6
Fix styles to be consistent
stitesExpensify 90e2278
More styling
stitesExpensify 640fc5a
Only set the width if we are on desktop
stitesExpensify 0638aa9
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify 4eaf091
Fix linting errors
stitesExpensify ffffae9
Style
stitesExpensify cebe9b5
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify 22a6462
Replace text with ExpensifyText
stitesExpensify ed53387
Import growl and fix style
stitesExpensify 8079896
Remove old consts
stitesExpensify f42a78d
Replace text with expensifyText
stitesExpensify 78dc009
Fix translate methods
stitesExpensify e46ec76
Fix translate methods
stitesExpensify 082b2d6
Fix imports
stitesExpensify 0e6bc72
Fix translation import
stitesExpensify 475e3df
Merge and solve lots of conflicts caused by moving to its own util m…
stitesExpensify 1429865
Fix merge failures
stitesExpensify f3479d5
Use constants
stitesExpensify 0f1232b
Fix styles for confirm dialog and all popover spacing
stitesExpensify 31fd8b8
Fix styles
stitesExpensify 696af51
Use expensifyText instead of header
stitesExpensify 993c4d3
Updates style per design's requests
stitesExpensify 2d09525
Replace useless style with existing one
stitesExpensify 009c354
Swap ExpensifyText to Text as it has been renamed
stitesExpensify c1b3cb6
Swap ExpensifyText to Text as it has been renamed
stitesExpensify b41cb4f
Fix small screen menu choices
stitesExpensify b9384fd
Change styles to align menuItem on small screens
stitesExpensify d1118fb
Add spanish translation
stitesExpensify c7a2b07
Use constants
stitesExpensify fb1eefb
Use constants instead of strings
stitesExpensify 103c85f
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify 5a2ff14
Use commandName instead of the method
stitesExpensify ce0e21c
Add docs
stitesExpensify 975cc3a
use const
stitesExpensify 07adb74
Also use const for paypal
stitesExpensify 74bd95e
Add translations
stitesExpensify 5fc97a1
Use translate instead of translateLocal and use props instead of the …
stitesExpensify ebe5473
Translate paypal deletion message
stitesExpensify 68a99bb
Use set instead of merge
stitesExpensify 6af27cb
Don't put the callback in the state, it is no longer necessary
stitesExpensify b01d165
Remove unnecessary default prop
stitesExpensify d007257
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify 06e53d4
Fix typo
stitesExpensify 4784b52
Translation
stitesExpensify 79f0520
Merge and change style to have a more general name
stitesExpensify e0d49f0
Fix spelling and make success messages show success growls
stitesExpensify 9631375
Actually translate rather than showing the string, and make the growl…
stitesExpensify 93047b4
Don't switch pages when clicking paypal.me and add description
stitesExpensify 4d96d41
Do not allow users to attempt to make paypal their default
stitesExpensify f4462e0
Use proper icons for small viewport
stitesExpensify d0f5ccd
Remove unused import
stitesExpensify f106106
Merge branch 'main' of github.com:Expensify/App into stites-setDefaul…
stitesExpensify 8f197d0
Remove unnecessary constructor
stitesExpensify 779d0b8
Change text input to follow our style (and make it pretty)
stitesExpensify 9a991e8
Left justify text
stitesExpensify 27ce205
Add margin below text and left justify
stitesExpensify e11c3d3
Hide default behind a beta
stitesExpensify 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,116 @@ | ||
| import React from 'react'; | ||
| import {View, TouchableOpacity} from 'react-native'; | ||
| import PropTypes from 'prop-types'; | ||
| import styles from '../styles/styles'; | ||
| import Popover from './Popover'; | ||
| import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions'; | ||
| import withLocalize, {withLocalizePropTypes} from './withLocalize'; | ||
| import compose from '../libs/compose'; | ||
| import Text from './Text'; | ||
|
|
||
| const propTypes = { | ||
| /** Title of the modal */ | ||
| title: PropTypes.string.isRequired, | ||
|
|
||
| /** A callback to call when the form has been submitted */ | ||
| onConfirm: PropTypes.func.isRequired, | ||
|
|
||
| /** A callback to call when the form has been closed */ | ||
| onCancel: PropTypes.func, | ||
|
|
||
| /** Modal visibility */ | ||
| isVisible: PropTypes.bool.isRequired, | ||
|
|
||
| /** Confirm button text */ | ||
| confirmText: PropTypes.string, | ||
|
|
||
| /** Cancel button text */ | ||
| cancelText: PropTypes.string, | ||
|
|
||
| /** Is the action destructive */ | ||
| danger: PropTypes.bool, | ||
|
|
||
| /** Whether we should show the cancel button */ | ||
| shouldShowCancelButton: PropTypes.bool, | ||
|
|
||
| /** Where the popover should be positioned */ | ||
| anchorPosition: PropTypes.shape({ | ||
| top: PropTypes.number, | ||
| left: PropTypes.number, | ||
| }).isRequired, | ||
|
|
||
| ...withLocalizePropTypes, | ||
|
|
||
| ...windowDimensionsPropTypes, | ||
| }; | ||
|
|
||
| const defaultProps = { | ||
| confirmText: '', | ||
| cancelText: '', | ||
| danger: false, | ||
| onCancel: () => {}, | ||
| shouldShowCancelButton: true, | ||
| }; | ||
|
|
||
| const ConfirmPopover = props => ( | ||
| <Popover | ||
| onSubmit={props.onConfirm} | ||
| onClose={props.onCancel} | ||
| isVisible={props.isVisible} | ||
| anchorPosition={props.anchorPosition} | ||
| > | ||
| <View | ||
| style={[ | ||
| styles.m5, | ||
| styles.alignItemsCenter, | ||
| !props.isSmallScreenWidth ? styles.sidebarPopover : '', | ||
| ]} | ||
| > | ||
| <Text | ||
| style={[ | ||
| styles.mb5, | ||
| ]} | ||
| > | ||
| {props.title} | ||
| </Text> | ||
| <TouchableOpacity | ||
| style={[ | ||
| styles.button, | ||
| styles.mt2, | ||
| styles.w100, | ||
| props.danger ? styles.buttonDanger : styles.buttonSuccess, | ||
| styles.alignSelfCenter, | ||
| ]} | ||
| onPress={props.onConfirm} | ||
| > | ||
| <Text style={[styles.buttonText, props.danger && styles.textWhite]}> | ||
| {props.confirmText || props.translate('common.yes')} | ||
| </Text> | ||
| </TouchableOpacity> | ||
| {props.shouldShowCancelButton | ||
| && ( | ||
| <TouchableOpacity | ||
| style={[ | ||
| styles.button, | ||
| styles.mt4, | ||
| styles.w100, | ||
| styles.alignSelfCenter, | ||
| ]} | ||
| onPress={props.onCancel} | ||
| > | ||
| <Text style={[styles.buttonText]}> | ||
| {props.cancelText || props.translate('common.no')} | ||
| </Text> | ||
| </TouchableOpacity> | ||
| )} | ||
| </View> | ||
| </Popover> | ||
| ); | ||
|
|
||
| ConfirmPopover.propTypes = propTypes; | ||
| ConfirmPopover.defaultProps = defaultProps; | ||
| ConfirmPopover.displayName = 'ConfirmPopover'; | ||
| export default compose( | ||
| withWindowDimensions, | ||
| withLocalize, | ||
| )(ConfirmPopover); | ||
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,119 @@ | ||
| import {TouchableOpacity, View} from 'react-native'; | ||
| import React, {Component} from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import styles from '../styles/styles'; | ||
| import Text from './Text'; | ||
| import Popover from './Popover'; | ||
| import withLocalize, {withLocalizePropTypes} from './withLocalize'; | ||
| import compose from '../libs/compose'; | ||
| import withWindowDimensions from './withWindowDimensions'; | ||
| import TextInput from './TextInput'; | ||
|
|
||
| const propTypes = { | ||
| /** Is the popover currently showing? */ | ||
| isVisible: PropTypes.bool.isRequired, | ||
|
|
||
| /** Function that gets called when the user closes the modal */ | ||
| onClose: PropTypes.func.isRequired, | ||
|
|
||
| /** Where the popover should be placed */ | ||
| anchorPosition: PropTypes.shape({ | ||
| top: PropTypes.number, | ||
| left: PropTypes.number, | ||
| }).isRequired, | ||
|
|
||
| /** Function that gets called when the user clicks the delete / make default button */ | ||
| onSubmit: PropTypes.func, | ||
|
|
||
| /** The text that should be displayed in the submit button */ | ||
| submitButtonText: PropTypes.string, | ||
|
|
||
| ...withLocalizePropTypes, | ||
| }; | ||
|
|
||
| const defaultProps = { | ||
| onSubmit: () => {}, | ||
| submitButtonText: '', | ||
| }; | ||
|
|
||
| class PasswordPopover extends Component { | ||
| constructor(props) { | ||
| super(props); | ||
|
|
||
| this.passwordInput = undefined; | ||
|
|
||
| this.focusInput = this.focusInput.bind(this); | ||
|
|
||
| this.state = { | ||
| password: '', | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Focus the password input | ||
| */ | ||
| focusInput() { | ||
| if (!this.passwordInput) { | ||
| return; | ||
| } | ||
| this.passwordInput.focus(); | ||
| } | ||
|
|
||
| render() { | ||
| return ( | ||
| <Popover | ||
| isVisible={this.props.isVisible} | ||
| onClose={this.props.onClose} | ||
| anchorPosition={this.props.anchorPosition} | ||
| onModalShow={this.focusInput} | ||
| > | ||
| <View | ||
| style={[ | ||
| styles.m5, | ||
| !this.props.isSmallScreenWidth ? styles.sidebarPopover : '', | ||
| ]} | ||
| > | ||
| <Text | ||
| style={[ | ||
| styles.mb3, | ||
| ]} | ||
| > | ||
| {this.props.translate('passwordForm.pleaseFillPassword')} | ||
| </Text> | ||
| <TextInput | ||
| label={this.props.translate('common.password')} | ||
| ref={el => this.passwordInput = el} | ||
| secureTextEntry | ||
| autoCompleteType="password" | ||
| textContentType="password" | ||
| value={this.state.currentPassword} | ||
| onChangeText={password => this.setState({password})} | ||
| returnKeyType="done" | ||
| onSubmitEditing={() => this.props.onSubmit(this.state.password)} | ||
| style={styles.mt3} | ||
| autoFocus | ||
| /> | ||
| <TouchableOpacity | ||
| onPress={() => this.props.onSubmit(this.state.password)} | ||
| style={[ | ||
| styles.button, | ||
| styles.mt3, | ||
| styles.w100, | ||
| ]} | ||
| > | ||
| <Text style={[styles.buttonText]}> | ||
| {this.props.submitButtonText} | ||
| </Text> | ||
| </TouchableOpacity> | ||
| </View> | ||
| </Popover> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| PasswordPopover.propTypes = propTypes; | ||
| PasswordPopover.defaultProps = defaultProps; | ||
| export default compose( | ||
| withWindowDimensions, | ||
| withLocalize, | ||
| )(PasswordPopover); |
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.