-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
New Pronouns page #12301
Merged
Merged
New Pronouns page #12301
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d8f75f7
Set up new pronouns page route
Beamanator 02e2f0a
Add new Pronouns page
Beamanator b03a3bf
Merge branch 'main' of github.com:Expensify/App into beaman-newPronou…
Beamanator 208ff39
Update spanish translation
Beamanator c993656
Fix translation location
Beamanator 2520142
Add updatePronouns action
Beamanator ce95071
Merge branch 'main' of github.com:Expensify/App into beaman-newPronou…
Beamanator e77d92c
Navigate back to profile after updating pronouns
Beamanator de474c5
Update public pronouns translation
Beamanator c5ff85a
Remove extra whitespace
Beamanator 5594d95
Show pronoun list directly on page
Beamanator b916d21
Add ability to show option separator
Beamanator 93cf62c
Remove a few unneeded props
Beamanator a2185ce
Fix lint issues
Beamanator 5c0992d
Add pronoun prefix to key
Beamanator 6d4a173
Merge branch 'main' of github.com:Expensify/App into beaman-newPronou…
Beamanator bce588b
Add a few additional pronouns
Beamanator a266206
Replace zeZieZirHir pronouns
Beamanator cbff71d
Fix pronoun list scrolling
Beamanator 4b07208
Bye bye annoying import
Beamanator 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -302,6 +302,18 @@ export default { | |
offline: 'Offline', | ||
syncing: 'Syncing', | ||
}, | ||
pronounsPage: { | ||
pronouns: 'Pronouns', | ||
isShownOnProfile: 'Your pronouns are shown on your profile.', | ||
}, | ||
pronouns: { | ||
heHimHis: 'He/him', | ||
sheHerHers: 'She/her', | ||
theyThemTheirs: 'They/them', | ||
zeHirHirs: 'Ze/hir', | ||
selfSelect: 'Self-select', | ||
callMeByMyName: 'Call me by my name', | ||
}, | ||
addSecondaryLoginPage: { | ||
addPhoneNumber: 'Add phone number', | ||
addEmailAddress: 'Add email address', | ||
|
@@ -607,14 +619,6 @@ export default { | |
formLabel: 'View PDF', | ||
}, | ||
}, | ||
pronouns: { | ||
heHimHis: 'He/him', | ||
sheHerHers: 'She/her', | ||
theyThemTheirs: 'They/them', | ||
zeHirHirs: 'Ze/hir', | ||
selfSelect: 'Self-select', | ||
callMeByMyName: 'Call me by my name', | ||
}, | ||
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. Coming from #38969. |
||
messages: { | ||
errorMessageInvalidPhone: `Please enter a valid phone number without brackets or dashes. If you're outside the US please include your country code (e.g. ${CONST.EXAMPLE_PHONE_NUMBER}).`, | ||
}, | ||
|
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 |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import lodashGet from 'lodash/get'; | ||
import React, {Component} from 'react'; | ||
import {View} from 'react-native'; | ||
import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../../../components/withCurrentUserPersonalDetails'; | ||
import ScreenWrapper from '../../../components/ScreenWrapper'; | ||
import HeaderWithCloseButton from '../../../components/HeaderWithCloseButton'; | ||
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; | ||
import * as Localize from '../../../libs/Localize'; | ||
import ROUTES from '../../../ROUTES'; | ||
import Form from '../../../components/Form'; | ||
import ONYXKEYS from '../../../ONYXKEYS'; | ||
import CONST from '../../../CONST'; | ||
import * as ValidationUtils from '../../../libs/ValidationUtils'; | ||
import TextInput from '../../../components/TextInput'; | ||
import Text from '../../../components/Text'; | ||
import styles from '../../../styles/styles'; | ||
import Navigation from '../../../libs/Navigation/Navigation'; | ||
import * as PersonalDetails from '../../../libs/actions/PersonalDetails'; | ||
import compose from '../../../libs/compose'; | ||
import Picker from '../../../components/Picker'; | ||
|
||
const propTypes = { | ||
...withLocalizePropTypes, | ||
...withCurrentUserPersonalDetailsPropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
...withCurrentUserPersonalDetailsDefaultProps, | ||
}; | ||
|
||
class PronounsPage extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.validate = this.validate.bind(this); | ||
this.updatePronouns = this.updatePronouns.bind(this); | ||
this.setPronouns = this.setPronouns.bind(this); | ||
|
||
this.pronouns = props.currentUserPersonalDetails.pronouns; | ||
this.state = { | ||
hasSelfSelectedPronouns: !_.isEmpty(props.currentUserPersonalDetails.pronouns) && !props.currentUserPersonalDetails.pronouns.startsWith(CONST.PRONOUNS.PREFIX), | ||
}; | ||
} | ||
|
||
/** | ||
* @param {String} pronouns | ||
*/ | ||
setPronouns(pronouns) { | ||
const hasSelfSelectedPronouns = pronouns === CONST.PRONOUNS.SELF_SELECT; | ||
this.pronouns = hasSelfSelectedPronouns ? '' : pronouns; | ||
|
||
if (this.state.hasSelfSelectedPronouns === hasSelfSelectedPronouns) { | ||
return; | ||
} | ||
|
||
this.setState({hasSelfSelectedPronouns}); | ||
} | ||
|
||
/** | ||
* Submit form to update personal details | ||
* @param {Object} values | ||
* @param {String} values.pronouns | ||
* @param {String} values.selfSelectedPronoun | ||
*/ | ||
updatePronouns(values) { | ||
PersonalDetails.updatePronouns( | ||
this.state.hasSelfSelectedPronouns ? values.selfSelectedPronoun.trim() : values.pronouns.trim(), | ||
); | ||
} | ||
|
||
/** | ||
* @param {Object} values - An object containing the value of each inputID | ||
* @param {String} values.pronouns | ||
* @param {String} values.selfSelectedPronoun | ||
* @returns {Object} - An object containing the errors for each inputID | ||
*/ | ||
validate(values) { | ||
const errors = {}; | ||
|
||
const [hasPronounError] = ValidationUtils.doesFailCharacterLimitAfterTrim( | ||
CONST.FORM_CHARACTER_LIMIT, | ||
[values.pronouns], | ||
); | ||
|
||
if (hasPronounError) { | ||
errors.pronouns = Localize.translateLocal('personalDetails.error.characterLimit', {limit: CONST.FORM_CHARACTER_LIMIT}); | ||
} | ||
|
||
return errors; | ||
} | ||
|
||
render() { | ||
const pronounsList = _.map(this.props.translate('pronouns'), (value, key) => ({ | ||
label: value, | ||
value: `${CONST.PRONOUNS.PREFIX}${key}`, | ||
})); | ||
const pronounsPickerValue = this.state.hasSelfSelectedPronouns ? CONST.PRONOUNS.SELF_SELECT : this.pronouns; | ||
|
||
return ( | ||
<ScreenWrapper> | ||
<HeaderWithCloseButton | ||
title={this.props.translate('pronounsPage.pronouns')} | ||
shouldShowBackButton | ||
onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_PROFILE)} | ||
onCloseButtonPress={() => Navigation.dismissModal(true)} | ||
/> | ||
<Form | ||
style={[styles.flexGrow1, styles.ph5]} | ||
formID={ONYXKEYS.FORMS.PRONOUNS_FORM} | ||
validate={this.validate} | ||
onSubmit={this.updatePronouns} | ||
submitButtonText={this.props.translate('common.save')} | ||
enabledWhenOffline | ||
> | ||
<Text style={[styles.mb6]}> | ||
{this.props.translate('displayNamePage.isShownOnProfile')} | ||
</Text> | ||
<View> | ||
<Picker | ||
inputID="pronouns" | ||
label={this.props.translate('profilePage.preferredPronouns')} | ||
items={pronounsList} | ||
placeholder={{ | ||
value: '', | ||
label: this.props.translate('profilePage.selectYourPronouns'), | ||
}} | ||
defaultValue={pronounsPickerValue} | ||
onValueChange={this.setPronouns} | ||
/> | ||
{this.state.hasSelfSelectedPronouns && ( | ||
<View style={styles.mt2}> | ||
<TextInput | ||
inputID="selfSelectedPronoun" | ||
defaultValue={this.pronouns} | ||
placeholder={this.props.translate('profilePage.selfSelectYourPronoun')} | ||
/> | ||
</View> | ||
)} | ||
</View> | ||
</Form> | ||
</ScreenWrapper> | ||
) | ||
} | ||
} | ||
|
||
PronounsPage.propTypes = propTypes; | ||
PronounsPage.defaultProps = defaultProps; | ||
|
||
export default compose( | ||
withLocalize, | ||
withCurrentUserPersonalDetails, | ||
)(PronounsPage); |
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.
Note: Removing this for now, as we'll come back to "self-select" / pronoun customization 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.
Convo here: https://expensify.slack.com/archives/C01GTK53T8Q/p1668116448072369?thread_ts=1666881832.702589&cid=C01GTK53T8Q