From 723c21cc8d11baac55e05f88448e7b34496f42a0 Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Fri, 8 Nov 2019 12:03:07 -0500 Subject: [PATCH 1/9] BAT Points updates for rewards settings --- .../android_page/actions/rewards_actions.ts | 6 ++++++ .../resources/android_page/components/adsBox.tsx | 5 ++++- .../resources/android_page/components/app.tsx | 2 ++ .../android_page/components/pageWallet.tsx | 5 +++-- .../android_page/components/settingsPage.tsx | 6 ++++-- .../resources/android_page/components/tipsBox.tsx | 5 +++-- .../android_page/constants/rewards_types.ts | 4 +++- .../android_page/reducers/rewards_reducer.ts | 15 +++++++++++++++ 8 files changed, 40 insertions(+), 8 deletions(-) diff --git a/components/brave_rewards/resources/android_page/actions/rewards_actions.ts b/components/brave_rewards/resources/android_page/actions/rewards_actions.ts index b7367eb07ac5..c21c947a0447 100644 --- a/components/brave_rewards/resources/android_page/actions/rewards_actions.ts +++ b/components/brave_rewards/resources/android_page/actions/rewards_actions.ts @@ -172,3 +172,9 @@ export const onBalance = (status: number, balance: Rewards.Balance) => action(ty status, balance }) + +export const onlyAnonWallet = () => action(types.ONLY_ANON_WALLET) + +export const onOnlyAnonWallet = (only: boolean) => action(types.ON_ONLY_ANON_WALLET, { + only +}) diff --git a/components/brave_rewards/resources/android_page/components/adsBox.tsx b/components/brave_rewards/resources/android_page/components/adsBox.tsx index 73a67ad2ecbb..d24a704b6564 100644 --- a/components/brave_rewards/resources/android_page/components/adsBox.tsx +++ b/components/brave_rewards/resources/android_page/components/adsBox.tsx @@ -83,6 +83,7 @@ class AdsBox extends React.Component { balance, safetyNetFailed } = this.props.rewardsData + const { onlyAnonWallet } = this.props.rewardsData.ui if (adsData) { adsEnabled = adsData.adsEnabled @@ -121,13 +122,14 @@ class AdsBox extends React.Component { {getLocale('adsCurrentEarnings')}}> @@ -143,6 +145,7 @@ class AdsBox extends React.Component { {getLocale('adsNotificationsReceived')}}> diff --git a/components/brave_rewards/resources/android_page/components/app.tsx b/components/brave_rewards/resources/android_page/components/app.tsx index 6f53c0fddf3f..d6cba74b455b 100644 --- a/components/brave_rewards/resources/android_page/components/app.tsx +++ b/components/brave_rewards/resources/android_page/components/app.tsx @@ -41,6 +41,8 @@ export class App extends React.Component { this.props.actions.onAdsSettingSave('adsEnabledMigrated', adsEnabled) } } + + this.actions.onlyAnonWallet() } componentDidUpdate (prevProps: Props, prevState: State) { diff --git a/components/brave_rewards/resources/android_page/components/pageWallet.tsx b/components/brave_rewards/resources/android_page/components/pageWallet.tsx index d445b5d58f2e..207db9f84666 100644 --- a/components/brave_rewards/resources/android_page/components/pageWallet.tsx +++ b/components/brave_rewards/resources/android_page/components/pageWallet.tsx @@ -112,7 +112,7 @@ class PageWallet extends React.Component { ui, pendingContributionTotal } = this.props.rewardsData - const { emptyWallet } = ui + const { emptyWallet, onlyAnonWallet } = ui const { total } = balance const pendingTotal = parseFloat((pendingContributionTotal || 0).toFixed(1)) @@ -133,10 +133,11 @@ class PageWallet extends React.Component { actions={[]} compact={true} isMobile={true} - showCopy={true} + showCopy={false} showSecActions={false} grants={this.getGrants()} alert={this.walletAlerts()} + onlyAnonWallet={onlyAnonWallet} > { enabledMain diff --git a/components/brave_rewards/resources/android_page/components/settingsPage.tsx b/components/brave_rewards/resources/android_page/components/settingsPage.tsx index e7040f5cab4c..3a9a43b58f0e 100644 --- a/components/brave_rewards/resources/android_page/components/settingsPage.tsx +++ b/components/brave_rewards/resources/android_page/components/settingsPage.tsx @@ -125,7 +125,7 @@ class SettingsPage extends React.Component { } getGrantClaims = () => { - const { grants } = this.props.rewardsData + const { grants, ui } = this.props.rewardsData if (!grants) { return null @@ -140,7 +140,7 @@ class SettingsPage extends React.Component { return (
- +
) })} @@ -154,6 +154,7 @@ class SettingsPage extends React.Component { render () { const { enabledMain, balance } = this.props.rewardsData + const { onlyAnonWallet } = this.props.rewardsData.ui const { total } = balance const convertedBalance = utils.convertBalance((total || 0).toString(), balance.rates) @@ -187,6 +188,7 @@ class SettingsPage extends React.Component { onClick={this.onToggleWallet} balance={total.toFixed(1).toString()} id={'mobile-wallet'} + onlyAnonWallet={onlyAnonWallet} converted={`${convertedBalance} USD`} /> diff --git a/components/brave_rewards/resources/android_page/components/tipsBox.tsx b/components/brave_rewards/resources/android_page/components/tipsBox.tsx index 9713bc7ddd1f..33ee312b7fe7 100644 --- a/components/brave_rewards/resources/android_page/components/tipsBox.tsx +++ b/components/brave_rewards/resources/android_page/components/tipsBox.tsx @@ -177,7 +177,7 @@ class TipBox extends React.Component { ui, tipsList } = this.props.rewardsData - const { walletImported } = ui + const { walletImported, onlyAnonWallet } = ui const showDisabled = firstLoad !== false || !enabledMain const tipRows = this.getTipsRows() const topRows = tipRows.slice(0, 5) @@ -207,13 +207,14 @@ class TipBox extends React.Component { : null } - + {getLocale('donationVisitSome')} diff --git a/components/brave_rewards/resources/android_page/constants/rewards_types.ts b/components/brave_rewards/resources/android_page/constants/rewards_types.ts index fab59421596e..afb0a689fe9c 100644 --- a/components/brave_rewards/resources/android_page/constants/rewards_types.ts +++ b/components/brave_rewards/resources/android_page/constants/rewards_types.ts @@ -53,5 +53,7 @@ export const enum types { GET_EXCLUDED_SITES = '@@rewards/GET_EXCLUDED_SITES', ON_EXCLUDED_LIST = '@@rewards/ON_EXCLUDED_LIST', GET_BALANCE = '@@rewards/GET_BALANCE', - ON_BALANCE = '@@rewards/ON_BALANCE' + ON_BALANCE = '@@rewards/ON_BALANCE', + ONLY_ANON_WALLET = '@@rewards/ONLY_ANON_WALLET', + ON_ONLY_ANON_WALLET = '@@rewards/ON_ONLY_ANON_WALLET' } diff --git a/components/brave_rewards/resources/android_page/reducers/rewards_reducer.ts b/components/brave_rewards/resources/android_page/reducers/rewards_reducer.ts index cc72d996e3b1..15152baa4626 100644 --- a/components/brave_rewards/resources/android_page/reducers/rewards_reducer.ts +++ b/components/brave_rewards/resources/android_page/reducers/rewards_reducer.ts @@ -145,6 +145,21 @@ const rewardsReducer: Reducer = (state: Rewards.State chrome.send('brave_rewards.getRewardsMainEnabled', []) break } + case types.ONLY_ANON_WALLET: { + chrome.send('brave_rewards.onlyAnonWallet') + break + } + case types.ON_ONLY_ANON_WALLET: { + const ui = state.ui + + ui.onlyAnonWallet = !!action.payload.only + + state = { + ...state, + ui + } + break + } } return state From 7b670dd213bd756a24a1e4f5abd15b6273509626 Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Wed, 13 Nov 2019 14:51:42 -0500 Subject: [PATCH 2/9] Refactor BAT points --- .../resources/android_page/components/pageWallet.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/brave_rewards/resources/android_page/components/pageWallet.tsx b/components/brave_rewards/resources/android_page/components/pageWallet.tsx index 207db9f84666..8d05646ce98a 100644 --- a/components/brave_rewards/resources/android_page/components/pageWallet.tsx +++ b/components/brave_rewards/resources/android_page/components/pageWallet.tsx @@ -116,6 +116,11 @@ class PageWallet extends React.Component { const { total } = balance const pendingTotal = parseFloat((pendingContributionTotal || 0).toFixed(1)) + let showCopy = false + if (!onlyAnonWallet) { + showCopy = true + } + if (!visible) { return null } @@ -133,7 +138,7 @@ class PageWallet extends React.Component { actions={[]} compact={true} isMobile={true} - showCopy={false} + showCopy={showCopy} showSecActions={false} grants={this.getGrants()} alert={this.walletAlerts()} From dcf33297dbc85f1fe01916a649eaca4d815d03b7 Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Fri, 8 Nov 2019 12:07:47 -0500 Subject: [PATCH 3/9] Fixed html strings for JP locale --- .../resources/android_page/brave_rewards_page.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/brave_rewards/resources/android_page/brave_rewards_page.tsx b/components/brave_rewards/resources/android_page/brave_rewards_page.tsx index b9e608298bfa..8c0174cd8c83 100644 --- a/components/brave_rewards/resources/android_page/brave_rewards_page.tsx +++ b/components/brave_rewards/resources/android_page/brave_rewards_page.tsx @@ -167,6 +167,10 @@ window.cr.define('brave_rewards', function () { getActions().getWalletProperties() } + function onlyAnonWallet (only: boolean) { + getActions().onOnlyAnonWallet(only) + } + return { initialize, walletCreated, @@ -196,7 +200,8 @@ window.cr.define('brave_rewards', function () { excludedList, excludedSiteChanged, balance, - reconcileComplete + reconcileComplete, + onlyAnonWallet } }) From 53a2245aeae811430d74b2357f5a9c81d47c62db Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Fri, 8 Nov 2019 13:54:05 -0500 Subject: [PATCH 4/9] Fixing BAP in contribute panel --- .../resources/android_page/components/contributeBox.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/brave_rewards/resources/android_page/components/contributeBox.tsx b/components/brave_rewards/resources/android_page/components/contributeBox.tsx index bd0499902530..2d5a2a4d7f2e 100644 --- a/components/brave_rewards/resources/android_page/components/contributeBox.tsx +++ b/components/brave_rewards/resources/android_page/components/contributeBox.tsx @@ -110,6 +110,7 @@ class ContributeBox extends React.Component { contributionMonthly, enabledMain } = this.props.rewardsData + const { onlyAnonWallet } = this.props.rewardsData.ui if (!enabledMain) { return null @@ -120,6 +121,7 @@ class ContributeBox extends React.Component { { excludedList, balance } = this.props.rewardsData + const { onlyAnonWallet } = this.props.rewardsData.ui const prefix = this.state.allSitesShown ? 'Hide all' : 'Show all' const monthlyList: MonthlyChoice[] = utils.generateContributionMonthly(walletInfo.choices, balance.rates) const contributeRows = this.getContributeRows(autoContributeList) @@ -215,6 +218,7 @@ class ContributeBox extends React.Component { Date: Fri, 8 Nov 2019 13:59:07 -0500 Subject: [PATCH 5/9] Grant/donate bap fixes --- .../brave_rewards/resources/android_page/components/grant.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/brave_rewards/resources/android_page/components/grant.tsx b/components/brave_rewards/resources/android_page/components/grant.tsx index 387ad4d424ad..a84c685144fa 100644 --- a/components/brave_rewards/resources/android_page/components/grant.tsx +++ b/components/brave_rewards/resources/android_page/components/grant.tsx @@ -29,6 +29,7 @@ interface State { interface Props extends Rewards.ComponentProps { grant: Rewards.Grant + onlyAnonWallet?: boolean } type GrantWrapperContentProps = { @@ -114,6 +115,7 @@ class Grant extends React.Component { render () { const { grant } = this.props + const { onlyAnonWallet } = this.props if (!grant) { return null @@ -163,6 +165,7 @@ class Grant extends React.Component { onClose={this.onSuccess} amount={tokens} date={date} + onlyAnonWallet={onlyAnonWallet} {...getGrantCompleteContentProps(type)} /> From 5ce4bc9d7f9fbb7cc5bd99646f609a29ad76e826 Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Mon, 11 Nov 2019 15:07:25 -0500 Subject: [PATCH 6/9] Fixing BAP in summary view --- .../resources/android_page/components/pageWallet.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/components/brave_rewards/resources/android_page/components/pageWallet.tsx b/components/brave_rewards/resources/android_page/components/pageWallet.tsx index 8d05646ce98a..ef704fe00660 100644 --- a/components/brave_rewards/resources/android_page/components/pageWallet.tsx +++ b/components/brave_rewards/resources/android_page/components/pageWallet.tsx @@ -150,6 +150,7 @@ class PageWallet extends React.Component { ? : From be3673d1273689a0f0d36a331545a3c25fb321ab Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Tue, 12 Nov 2019 10:03:21 -0500 Subject: [PATCH 7/9] Added strings to localize --- .../resources/android_page/components/adsBox.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/brave_rewards/resources/android_page/components/adsBox.tsx b/components/brave_rewards/resources/android_page/components/adsBox.tsx index d24a704b6564..82e4de0dc82f 100644 --- a/components/brave_rewards/resources/android_page/components/adsBox.tsx +++ b/components/brave_rewards/resources/android_page/components/adsBox.tsx @@ -118,11 +118,13 @@ class AdsBox extends React.Component { boxPropsExtra.extraDescriptionChild = } + const tokenString = getLocale(onlyAnonWallet ? 'points' : 'tokens') + return ( From 985eb3379619102051828ae8a833b0cfd713c0ce Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Tue, 12 Nov 2019 10:11:11 -0500 Subject: [PATCH 8/9] Use BAT Points in mobile components --- .../resources/ui/components/mobile/selectMobile/index.tsx | 4 ++-- .../resources/ui/components/mobile/walletInfoHeader/index.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/brave_rewards/resources/ui/components/mobile/selectMobile/index.tsx b/components/brave_rewards/resources/ui/components/mobile/selectMobile/index.tsx index cc3eb3cc87b6..ca7b92c4e142 100644 --- a/components/brave_rewards/resources/ui/components/mobile/selectMobile/index.tsx +++ b/components/brave_rewards/resources/ui/components/mobile/selectMobile/index.tsx @@ -64,7 +64,7 @@ export default class SelectMobile extends React.PureComponent { return null } - const batFormatString = onlyAnonWallet ? 'bap' : 'bat' + const batFormatString = onlyAnonWallet ? getLocale('batPoints') : getLocale('bat') return ( <> @@ -74,7 +74,7 @@ export default class SelectMobile extends React.PureComponent { key={`k-${amount.value}`} value={amount.dataValue} > - {amount.value} {getLocale(batFormatString)} ({amount.converted} USD) + {amount.value} {batFormatString} ({amount.converted} USD) ) })} diff --git a/components/brave_rewards/resources/ui/components/mobile/walletInfoHeader/index.tsx b/components/brave_rewards/resources/ui/components/mobile/walletInfoHeader/index.tsx index f77380e7af51..1aafa118791b 100644 --- a/components/brave_rewards/resources/ui/components/mobile/walletInfoHeader/index.tsx +++ b/components/brave_rewards/resources/ui/components/mobile/walletInfoHeader/index.tsx @@ -26,7 +26,7 @@ export default class WalletInfoHeader extends React.PureComponent { render () { const { id, balance, converted, onlyAnonWallet, onClick } = this.props - const batFormatString = onlyAnonWallet ? 'bap' : 'bat' + const batFormatString = onlyAnonWallet ? getLocale('batPoints') : getLocale('bat') return ( { {getLocale('yourWallet')} - {balance} {getLocale(batFormatString)} + {balance} {batFormatString} { converted From 6e0b0dc857c8abcb0688ca47d96f11b4b19f04a0 Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Tue, 12 Nov 2019 11:29:06 -0500 Subject: [PATCH 9/9] Increasing balance header spacing --- .../resources/ui/components/mobile/walletInfoHeader/style.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/brave_rewards/resources/ui/components/mobile/walletInfoHeader/style.ts b/components/brave_rewards/resources/ui/components/mobile/walletInfoHeader/style.ts index 8342c9b79289..91831713f6e6 100644 --- a/components/brave_rewards/resources/ui/components/mobile/walletInfoHeader/style.ts +++ b/components/brave_rewards/resources/ui/components/mobile/walletInfoHeader/style.ts @@ -45,7 +45,7 @@ export const StyledBalanceTokens = styled<{}, 'div'>('div')` letter-spacing: -0.4px; color: #fff; font-weight: 300; - margin-top: 10px; + margin-top: 25px; ` export const StyledBalanceConverted = styled<{}, 'div'>('div')`