Skip to content

Commit

Permalink
Use first name instead of full name in rewards uphold
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed May 26, 2020
1 parent 83ac688 commit e90090d
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 16 deletions.
1 change: 1 addition & 0 deletions browser/ui/webui/brave_webui_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ void CustomizeWebUIHTMLSource(const std::string &name,
{ "grantFinishTokenUGP", IDS_BRAVE_UI_GRANT_FINISH_TOKEN_UGP },
{ "grantFinishPointUGP", IDS_BRAVE_UI_GRANT_FINISH_POINT_UGP },
{ "grants", IDS_BRAVE_UI_GRANTS },
{ "greetingsVerified", IDS_BRAVE_UI_GREETINGS_VERIFIED },
{ "import", IDS_BRAVE_UI_IMPORT },
{ "includeInAuto", IDS_BRAVE_UI_INCLUDE_IN_AUTO },
{ "learnMore", IDS_BRAVE_UI_LEARN_MORE },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,5 +588,15 @@
"pointGrants": {
"message": "Point Grants",
"description": "BAT Points Grant Text"
},
"greetingsVerified": {
"message": "Hello, $name$!",
"description": "Greetings for external wallet popup",
"placeholders": {
"name": {
"content": "$1",
"example": "John"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const getUIMessages = (): Record<string, string> => {
'grantGeneralErrorText',
'grantGeneralErrorTitle',
'grants',
'greetingsVerified',
'includeInAuto',
'insufficientFunds',
'insufficientFundsNotification',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export class RewardsPanel extends React.Component<Props, State> {
onVerifyClick={onVerifyClick}
onDisconnectClick={this.onDisconnectClick}
goToUphold={this.goToUphold}
userName={utils.getUserName(externalWallet)}
greetings={utils.getGreetings(externalWallet)}
actions={this.getActions()}
>
<WalletPanelDisabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ export class Panel extends React.Component<Props, State> {
onVerifyClick={onVerifyClick}
onDisconnectClick={this.onDisconnectClick}
goToUphold={this.goToUphold}
userName={utils.getUserName(externalWallet)}
greetings={utils.getGreetings(externalWallet)}
onlyAnonWallet={this.props.onlyAnonWallet}
{...notification}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ export const getWalletStatus = (externalWallet?: RewardsExtension.ExternalWallet
}
}

export const getUserName = (externalWallet?: RewardsExtension.ExternalWallet) => {
if (!externalWallet) {
export const getGreetings = (externalWallet?: RewardsExtension.ExternalWallet) => {
if (!externalWallet || !externalWallet.userName) {
return ''
}

return externalWallet.userName
return getMessage('greetingsVerified', [externalWallet.userName])
}

export const handleUpholdLink = (link: string, externalWallet?: RewardsExtension.ExternalWallet) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,13 +442,13 @@ class PageWallet extends React.Component<Props, State> {
window.open(externalWallet.accountUrl, '_self')
}

getUserName = () => {
getGreetings = () => {
const { externalWallet } = this.props.rewardsData
if (!externalWallet) {
if (!externalWallet || !externalWallet.userName) {
return ''
}

return externalWallet.userName
return getLocale('greetingsVerified', { name: externalWallet.userName })
}

onDisconnectClick = () => {
Expand Down Expand Up @@ -779,7 +779,7 @@ class PageWallet extends React.Component<Props, State> {
onVerifyClick={onVerifyClick}
onDisconnectClick={this.onDisconnectClick}
goToUphold={this.goToUphold}
userName={this.getUserName()}
greetings={this.getGreetings()}
onlyAnonWallet={onlyAnonWallet}
>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
export interface Props {
children: React.ReactNode
onClose: () => void
userName: string
greetings: string
id?: string
verified?: boolean
}
Expand All @@ -38,7 +38,7 @@ export default class WalletPopup extends React.PureComponent<Props, {}> {
const {
children,
onClose,
userName,
greetings,
id,
verified
} = this.props
Expand All @@ -50,7 +50,7 @@ export default class WalletPopup extends React.PureComponent<Props, {}> {
<StyledIcon>
<UpholdColorIcon />
</StyledIcon>
{userName}
{greetings}
{
verified
? <StyledStatus>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export interface Props {
onVerifyClick?: () => void
onDisconnectClick?: () => void
goToUphold?: () => void
userName?: string
greetings?: string
onlyAnonWallet?: boolean
}

Expand Down Expand Up @@ -402,14 +402,14 @@ export default class WalletWrapper extends React.PureComponent<Props, State> {
}

getVerificationDetails = () => {
const { goToUphold, userName, onDisconnectClick, onVerifyClick, walletState } = this.props
const { goToUphold, greetings, onDisconnectClick, onVerifyClick, walletState } = this.props
const verified = walletState === 'verified'
const connected = walletState === 'connected'

return (
<WalletPopup
onClose={this.toggleVerificationDetails}
userName={userName || ''}
greetings={greetings || ''}
verified={verified}
>
{
Expand Down
1 change: 1 addition & 0 deletions components/resources/brave_components_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@
<message name="IDS_BRAVE_UI_GRANT_DISCLAIMER" desc="">{{currency}} not used by the expiration date will be automatically returned to the Brave User Growth Pool.</message>
<message name="IDS_BRAVE_UI_GRANT_EXPIRE" desc="">Grant Expiration Date</message>
<message name="IDS_BRAVE_UI_GRANTS" desc="">Grants</message>
<message name="IDS_BRAVE_UI_GREETINGS_VERIFIED" desc="">Hello, {{name}}!</message>
<message name="IDS_BRAVE_UI_IMPORT" desc="">import</message>
<message name="IDS_BRAVE_UI_INCLUDE_IN_AUTO" desc="">Include in Auto-Contribute</message>
<message name="IDS_BRAVE_UI_LEARN_MORE" desc="">Learn More</message>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void UpholdUser::OnGet(
return;
}

const auto* name = dictionary->FindStringKey("name");
const auto* name = dictionary->FindStringKey("firstName");
if (name) {
user.name = *name;
}
Expand Down

0 comments on commit e90090d

Please sign in to comment.