Skip to content

Commit 3b4df80

Browse files
authored
Merge pull request #9566 from brave/rewards-move-ios-qr-code
Move iOS recovery code into Backup and Restore modal
2 parents 89e3bc7 + 8eadbfa commit 3b4df80

File tree

10 files changed

+42
-119
lines changed

10 files changed

+42
-119
lines changed

.storybook/locale.ts

+2
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ let locale: Record<string, string> = {
220220
rewardsRestoreText3: 'Restoring with a recovery key will replace your current wallet. So make sure you empty or back up your current wallet before restoring.',
221221
rewardsRestoreText4: 'Enter your recovery key or',
222222
rewardsSummary: 'Rewards Summary',
223+
rewardsViewQRCodeText1: 'View QR Code',
224+
rewardsViewQRCodeText2: 'for iOS Rewards users transferring BAT.',
223225
rewardsWhy: 'Why Brave Rewards…',
224226
rewardsWidgetBraveRewards: 'Brave Rewards',
225227
rewardsWidgetBat: 'BAT',

browser/ui/webui/brave_webui_source.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,6 @@ void CustomizeWebUIHTMLSource(const std::string &name,
477477
{ "adsSubdivisionTargetingDisabled", IDS_BRAVE_REWARDS_LOCAL_ADS_SUBDIVISION_TARGETING_DISABLED }, // NOLINT
478478
{ "adsTitle", IDS_BRAVE_REWARDS_LOCAL_ADS_TITLE },
479479

480-
{ "qrBoxText", IDS_BRAVE_REWARDS_LOCAL_QR_BOX_TEXT },
481-
{ "qrBoxButton", IDS_BRAVE_REWARDS_LOCAL_QR_BOX_BUTTON },
482-
483480
{ "bat", IDS_BRAVE_UI_BAT_REWARDS_TEXT },
484481
{ "contributionTitle", IDS_BRAVE_REWARDS_LOCAL_CONTR_TITLE },
485482
{ "contributionDesc", IDS_BRAVE_REWARDS_LOCAL_CONTR_DESC },
@@ -788,6 +785,8 @@ void CustomizeWebUIHTMLSource(const std::string &name,
788785
{ "rewardsPanelText3", IDS_BRAVE_UI_REWARDS_PANEL_TEXT3 },
789786
{ "rewardsPanelText4", IDS_BRAVE_UI_REWARDS_PANEL_TEXT4 },
790787
{ "rewardsPanelTextVerify", IDS_BRAVE_UI_REWARDS_PANEL_VERIFY },
788+
{ "rewardsViewQRCodeText1", IDS_BRAVE_UI_REWARDS_VIEW_QR_CODE_TEXT1 },
789+
{ "rewardsViewQRCodeText2", IDS_BRAVE_UI_REWARDS_VIEW_QR_CODE_TEXT2 },
791790
{ "rewardsRestoreText1", IDS_BRAVE_UI_REWARDS_RESTORE_TEXT1 },
792791
{ "rewardsRestoreText2", IDS_BRAVE_UI_REWARDS_RESTORE_TEXT2 },
793792
{ "rewardsRestoreText3", IDS_BRAVE_UI_REWARDS_RESTORE_TEXT3 },

components/brave_rewards/resources/page/components/pageWallet.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,8 @@ class PageWallet extends React.Component<Props, State> {
792792
ui,
793793
pendingContributionTotal,
794794
recoveryKey,
795-
externalWallet
795+
externalWallet,
796+
paymentId
796797
} = this.props.rewardsData
797798
const { total } = balance
798799
const { emptyWallet, modalBackup } = ui
@@ -801,6 +802,10 @@ class PageWallet extends React.Component<Props, State> {
801802
const walletType = externalWallet ? externalWallet.type : undefined
802803
const walletProvider = utils.getWalletProviderName(externalWallet)
803804

805+
if (!paymentId) {
806+
this.props.actions.getPaymentId()
807+
}
808+
804809
return (
805810
<>
806811
<WalletWrapper
@@ -833,6 +838,7 @@ class PageWallet extends React.Component<Props, State> {
833838
{
834839
modalBackup
835840
? <ModalBackupRestore
841+
paymentId={paymentId}
836842
activeTabId={this.state.activeTabId}
837843
backupKey={recoveryKey}
838844
showBackupNotice={this.showBackupNotice()}

components/brave_rewards/resources/page/components/qrBox.tsx

-83
This file was deleted.

components/brave_rewards/resources/page/components/settingsPage.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import AdsBox from './adsBox'
1919
import ContributeBox from './contributeBox'
2020
import TipBox from './tipsBox'
2121
import MonthlyContributionBox from './monthlyContributionBox'
22-
import QRBox from './qrBox'
2322
import { SettingsOptInForm, RewardsTourModal, RewardsTourPromo } from '../../shared/components/onboarding'
2423
import { TourPromoWrapper } from './style'
2524

@@ -405,7 +404,6 @@ class SettingsPage extends React.Component<Props, State> {
405404
onTOSClick={this.openTOS}
406405
onPrivacyClick={this.openPrivacyPolicy}
407406
/>
408-
<QRBox />
409407
<AdsBox />
410408
<ContributeBox />
411409
<MonthlyContributionBox />

components/brave_rewards/resources/page/components/style.tsx

-26
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,7 @@
11
/* This Source Code Form is subject to the terms of the Mozilla Public
22
* License. v. 2.0. If a copy of the MPL was not distributed with this file.
33
* You can obtain one at http://mozilla.org/MPL/2.0/. */
4-
import * as React from 'react'
54
import styled from 'styled-components'
6-
import Card, { CardProps } from 'brave-ui/components/layout/card'
7-
8-
export const QRBoxWrapper = styled('div')<{}>`
9-
width: 100%;
10-
margin: 0 0 24px;
11-
`
12-
13-
const CustomCard: React.FC<CardProps> = (props) =>
14-
<Card emphasis={'60'} {...props} />
15-
16-
export const QRBoxStyle = styled(CustomCard)`
17-
font-size: 14px;
18-
display: flex;
19-
justify-content: space-between;
20-
align-items: center;
21-
width: 100%;
22-
box-shadow: 0 0;
23-
`
24-
25-
export const QRText = styled('div')<{}>`
26-
font-size: 15px;
27-
color: ${p => p.theme.color.text};
28-
padding: 0 10px 0 0;
29-
line-height: 1.5;
30-
`
315

326
export const TourPromoWrapper = styled('div')<{}>`
337
margin-top: 30px;

components/brave_rewards/resources/ui/components/modalBackupRestore/index.tsx

+27-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
} from './style'
2323
import { TextArea, Modal, Button } from 'brave-ui/components'
2424
import { getLocale } from 'brave-ui/helpers'
25-
import { Alert, Tab } from '../'
25+
import { Alert, ModalQRCode, Tab } from '../'
2626
import ControlWrapper from 'brave-ui/components/formControls/controlWrapper'
2727

2828
export interface Props {
@@ -43,11 +43,13 @@ export interface Props {
4343
funds?: string
4444
onReset: () => void
4545
internalFunds: number
46+
paymentId: string
4647
}
4748

4849
interface State {
4950
recoveryKey: string
5051
errorShown: boolean
52+
showQRCodeModal: boolean
5153
}
5254

5355
/*
@@ -60,7 +62,8 @@ export default class ModalBackupRestore extends React.PureComponent<Props, State
6062
super(props)
6163
this.state = {
6264
recoveryKey: '',
63-
errorShown: false
65+
errorShown: false,
66+
showQRCodeModal: false
6467
}
6568
}
6669

@@ -95,6 +98,12 @@ export default class ModalBackupRestore extends React.PureComponent<Props, State
9598
})
9699
}
97100

101+
toggleQRCodeModal = () => {
102+
this.setState({
103+
showQRCodeModal: !this.state.showQRCodeModal
104+
})
105+
}
106+
98107
onRestore = (key?: string) => {
99108
key = typeof key === 'string' ? key : this.state.recoveryKey
100109
this.props.onRestore(key)
@@ -285,6 +294,13 @@ export default class ModalBackupRestore extends React.PureComponent<Props, State
285294
{getLocale('rewardsRestoreText3')}
286295
</StyledText>
287296
</StyledTextWrapper>
297+
<StyledTextWrapper>
298+
<StyledText>
299+
<StyledLink onClick={this.toggleQRCodeModal}>
300+
{getLocale('rewardsViewQRCodeText1')}
301+
</StyledLink> {getLocale('rewardsViewQRCodeText2')}
302+
</StyledText>
303+
</StyledTextWrapper>
288304
<StyledActionsWrapper>
289305
<ActionButton
290306
level={'secondary'}
@@ -367,6 +383,7 @@ export default class ModalBackupRestore extends React.PureComponent<Props, State
367383
activeTabId,
368384
onClose,
369385
onTabChange,
386+
paymentId,
370387
testId
371388
} = this.props
372389

@@ -392,6 +409,14 @@ export default class ModalBackupRestore extends React.PureComponent<Props, State
392409
{
393410
this.getTabContent(activeTabId)
394411
}
412+
{
413+
this.state.showQRCodeModal
414+
? <ModalQRCode
415+
paymentId={paymentId}
416+
onClose={this.toggleQRCodeModal}
417+
/>
418+
: null
419+
}
395420
</Modal>
396421
)
397422
}

components/brave_rewards/resources/ui/stories/modal.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ storiesOf('Rewards/Modal', module)
4545
return (
4646
<div style={{ maxWidth: '900px', background: '#fff', padding: '30px' }}>
4747
<ModalBackupRestore
48+
paymentId={'f2e6494e-fb21-44d1-90e9-b5408799acd8'}
4849
funds={'55 BAT'}
4950
activeTabId={store.state.activeTabId}
5051
showBackupNotice={boolean('Show backup notice?', false)}

components/brave_rewards/resources/ui/stories/settings/pageWallet.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ class PageWallet extends React.Component<Props, State> {
265265
{
266266
this.state.modalBackup
267267
? <ModalBackupRestore
268+
paymentId={'f2e6494e-fb21-44d1-90e9-b5408799acd8'}
268269
activeTabId={this.state.activeTabId}
269270
backupKey={'crouch hint glow recall round angry weasel luggage save hood census near still power vague balcony camp law now certain wagon affair butter choice '}
270271
showBackupNotice={false}

components/resources/brave_components_strings.grd

+2-2
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,6 @@
415415
<message name="IDS_BRAVE_REWARDS_LOCAL_ADS_SUBDIVISION_TARGETING_AUTO_DETECT" desc="">Auto-detect</message>
416416
<message name="IDS_BRAVE_REWARDS_LOCAL_ADS_SUBDIVISION_TARGETING_DISABLE" desc="">Disable</message>
417417
<message name="IDS_BRAVE_REWARDS_LOCAL_ADS_SUBDIVISION_TARGETING_DISABLED" desc="">Disabled</message>
418-
<message name="IDS_BRAVE_REWARDS_LOCAL_QR_BOX_TEXT" desc="">QR Code for iOS Rewards users transferring BAT</message>
419-
<message name="IDS_BRAVE_REWARDS_LOCAL_QR_BOX_BUTTON" desc="">QR Code</message>
420418
<message name="IDS_BRAVE_REWARDS_LOCAL_SERVER_DISCONNECT_FAILED" desc="">Sorry, there was an error when trying to disconnect your <ph name="PROVIDER">$1</ph> account. Please try again in a little while.</message>
421419
<message name="IDS_BRAVE_UI_BAT_REWARDS_TEXT" desc="">BAT</message>
422420
<message name="IDS_BRAVE_REWARDS_LOCAL_DEVICE_OFFLINE" desc="">The device is offline, please try again later.</message>
@@ -861,6 +859,8 @@
861859
<message name="IDS_BRAVE_UI_REWARDS_PANEL_TEXT2" desc="">Your Brave wallet is powered by <ph name="PROVIDER">$1<ex>Uphold</ex></ph>.</message>
862860
<message name="IDS_BRAVE_UI_REWARDS_PANEL_TEXT3" desc="">Brave Rewards is built on the Basic Attention Token. Learn more about BAT</message>
863861
<message name="IDS_BRAVE_UI_REWARDS_PANEL_TEXT4" desc="">here</message>
862+
<message name="IDS_BRAVE_UI_REWARDS_VIEW_QR_CODE_TEXT1" desc="">View QR Code</message>
863+
<message name="IDS_BRAVE_UI_REWARDS_VIEW_QR_CODE_TEXT2" desc="">for iOS Rewards users transferring BAT.</message>
864864
<message name="IDS_BRAVE_UI_REWARDS_RESTORE_TEXT1" desc="">Restore your Wallet</message>
865865
<message name="IDS_BRAVE_UI_REWARDS_RESTORE_TEXT2" desc="">Use your recovery key to restore your wallet.</message>
866866
<message name="IDS_BRAVE_UI_REWARDS_RESTORE_TEXT3" desc="">Restoring with a recovery key will replace your current wallet. So make sure you empty or back up your current wallet before restoring.</message>

0 commit comments

Comments
 (0)