Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Adds transition overlay
Browse files Browse the repository at this point in the history
Resolves #11389
Resolves #11340
Resolves #11333

Auditors:

Test Plan:
  • Loading branch information
NejcZdovc committed Oct 10, 2017
1 parent 433e69f commit 44800cd
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 15 deletions.
11 changes: 8 additions & 3 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,22 @@ const notifications = {
},
onLaunch: (state) => {
if (!getSetting(settings.PAYMENTS_ENABLED)) {
return
return state
}

// One time conversion of wallet
const isNewInstall = state.get('firstRunTimestamp') === state.getIn(['migrations', 'batMercuryTimestamp'])
const hasUpgradedWallet = state.getIn(['migrations', 'batMercuryTimestamp']) !== state.getIn(['migrations', 'btc2BatTimestamp'])
if (!isNewInstall && !hasUpgradedWallet) {
module.exports.transitionWalletToBat(state)
} else {
state = state.setIn(['migrations', 'btc2BatTransitionDone'], true)
}

if (hasFunds(state)) {
// Don't bother processing the rest, which are only notifications.
if (!getSetting(settings.PAYMENTS_NOTIFICATIONS)) {
return
return state
}

// Show one-time BAT conversion message:
Expand All @@ -183,6 +185,8 @@ const notifications = {
notifications.showBraveWalletUpdated()
}
}

return state
},
onInterval: (state) => {
if (getSetting(settings.PAYMENTS_ENABLED)) {
Expand Down Expand Up @@ -2002,7 +2006,7 @@ const onInitRead = (state, parsedData) => {
getBalance(state)

// Show relevant browser notifications on launch
notifications.onLaunch(state)
state = notifications.onLaunch(state)

return state
}
Expand Down Expand Up @@ -2270,6 +2274,7 @@ const transitionWalletToBat = (state) => {
newClient = true
appActions.onLedgerCallback(result, random.randomInt({ min: miliseconds.minute, max: 10 * miliseconds.minute }))
appActions.onBitcoinToBatTransitioned()
notifications.showBraveWalletUpdated()
}
})
} catch (ex) {
Expand Down
1 change: 1 addition & 0 deletions app/browser/reducers/ledgerReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ const ledgerReducer = (state, action, immutableAction) => {
case appConstants.APP_ON_BTC_TO_BAT_TRANSITIONED:
{
state = state.setIn(['migrations', 'btc2BatTimestamp'], new Date().getTime())
state = state.setIn(['migrations', 'btc2BatTransitionDone'], true)
break
}
case appConstants.APP_ON_LEDGER_QR_GENERATED:
Expand Down
2 changes: 2 additions & 0 deletions app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ const updateAboutDetails = (tab, tabValue) => {
const ledgerInfo = ledgerState.getInfoProps(appState)
const synopsis = ledgerState.getAboutData(appState)
const wizardData = ledgerState.geWizardData(appState)
const migration = appState.get('migrations')
const preferencesData = appState.getIn(['about', 'preferences'])
const appSettings = appState.get('settings')
let allSiteSettings = appState.get('siteSettings')
Expand Down Expand Up @@ -198,6 +199,7 @@ const updateAboutDetails = (tab, tabValue) => {
.merge(synopsis)
.merge(preferencesData)
.set('wizardData', wizardData)
.set('migration', migration)
tab.send(messages.LEDGER_UPDATED, ledgerData.toJS())
tab.send(messages.SETTINGS_UPDATED, appSettings.toJS())
tab.send(messages.SITE_SETTINGS_UPDATED, allSiteSettings.toJS())
Expand Down
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ lastContribution=Last contribution:
lastPass=LastPass®
ledgerBackupContent=Below, you will find the anonymized recovery key that is required if you ever lose access to this computer.<br><strong>Make sure you keep this key private, or else your wallet will be compromised.</strong>
ledgerBackupTitle=Backup your Brave wallet
leaderLoaderText1=We are now converting your Brave Wallet from Bitcoin to BAT (Basic Attention Token).
leaderLoaderText2=This can take a few minutes
ledgerPaymentsShown=Brave Payments
ledgerRecoveryContent=Your previous wallet will now be used. Your new wallet will be discarded.
ledgerRecoveryFailedMessage=Please re-enter keys or try different keys.
Expand Down
103 changes: 95 additions & 8 deletions app/renderer/components/preferences/payment/enabledContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const moment = require('moment')
const {batToCurrencyString, formatCurrentBalance, formattedDateFromTimestamp, walletStatus} = require('../../../../common/lib/ledgerUtil')
const {l10nErrorText} = require('../../../../common/lib/httpUtil')
const {changeSetting} = require('../../../lib/settingsUtil')
const getSetting = require('../../../../../js/settings').getSetting
const settings = require('../../../../../js/constants/settings')

// components
const ImmutableComponent = require('../../immutableComponent')
Expand All @@ -21,15 +23,12 @@ const LedgerTable = require('./ledgerTable')
// style
const globalStyles = require('../../styles/global')
const {paymentStylesVariables} = require('../../styles/payment')
const {loaderAnimation} = require('../../styles/animations')
const cx = require('../../../../../js/lib/classSet')

// Actions
const appActions = require('../../../../../js/actions/appActions')

// other
const getSetting = require('../../../../../js/settings').getSetting
const settings = require('../../../../../js/constants/settings')

// TODO: report when funds are too low
// TODO: support non-USD currency
class EnabledContent extends ImmutableComponent {
Expand Down Expand Up @@ -171,9 +170,23 @@ class EnabledContent extends ImmutableComponent {
render () {
const ledgerData = this.props.ledgerData
const walletStatusText = walletStatus(ledgerData)

return <section>
<div className={css(styles.walletBar)} data-test-id='walletBar'>
const inTranstion = !(ledgerData.getIn(['migration', 'btc2BatTransitionDone']))

return <section className={css(styles.enabledContent)}>
<div className={css(styles.enabledContent__loader, inTranstion && styles.enabledContent__loader_show)}>
<p className={css(styles.loader__text)}>
<p data-l10n-id='leaderLoaderText1' />
<p data-l10n-id='leaderLoaderText2' />
</p>
<div className={css(styles.leader__wrap)}>
<div>
<div className={css(styles.loader__line, styles.loader__line_1, !inTranstion && styles.loader__line_off)} />
<div className={css(styles.loader__line, styles.loader__line_2, !inTranstion && styles.loader__line_off)} />
<div className={css(styles.loader__line, styles.loader__line_3, !inTranstion && styles.loader__line_off)} />
</div>
</div>
</div>
<div className={css(styles.enabledContent__walletBar)} data-test-id='walletBar'>
<div className={css(gridStyles.row1col1, styles.walletBar__title)} data-l10n-id='monthlyBudget' />
<div className={css(gridStyles.row1col2, styles.walletBar__title)} data-l10n-id='accountBalance' />
<div className={css(gridStyles.row1col3)} />
Expand Down Expand Up @@ -275,7 +288,7 @@ const gridStyles = StyleSheet.create({
})

const styles = StyleSheet.create({
walletBar: {
enabledContent__walletBar: {
display: 'grid',
gridTemplateColumns: '1fr 1fr 1fr',
background: globalStyles.color.lightGray,
Expand Down Expand Up @@ -310,6 +323,80 @@ const styles = StyleSheet.create({
':hover': {
textDecoration: 'none !important'
}
},

enabledContent: {
position: 'relative',
zIndex: 2
},

enabledContent__loader: {
background: '#fafafa',
zIndex: 3,
position: 'absolute',
left: 0,
top: 0,
width: '100%',
height: '100%',
margin: 0,
opacity: 0,
transform: 'translateX(-1000%)',
transition: 'opacity .4s ease-out, transform .1s .4s ease'
},

enabledContent__loader_show: {
opacity: 1,
transform: 'translateX(0)',
transition: 'opacity .4s ease-out'
},

loader__text: {
textAlign: 'center',
padding: '50px 0 20px',
display: 'block',
color: '#444'
},

leader__wrap: {
width: '45px',
left: 0,
right: 0,
margin: '50px auto 0'
},

loader__line: {
display: 'inline-block',
width: '15px',
height: '15px',
borderRadius: '15px'
},

loader__line_1: {
backgroundColor: '#FF5000',
animationName: [loaderAnimation],
animationDuration: '.6s',
animationDelay: '.1s',
animationIterationCount: 'infinite'
},

loader__line_2: {
backgroundColor: '#9E1F63',
animationName: [loaderAnimation],
animationDuration: '.6s',
animationDelay: '.2s',
animationIterationCount: 'infinite'
},

loader__line_3: {
backgroundColor: '#662D91',
animationName: [loaderAnimation],
animationDuration: '.6s',
animationDelay: '.3s',
animationIterationCount: 'infinite'
},

loader__line_off: {
animationName: 'none'
}
})

Expand Down
9 changes: 6 additions & 3 deletions app/renderer/components/preferences/paymentsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ class PaymentsTab extends ImmutableComponent {

render () {
const enabled = this.props.ledgerData.get('created')
const inTranstion = !(this.props.ledgerData.getIn(['migration', 'btc2BatTransitionDone']))
const enableSettings = enabled && !inTranstion

return <div className={cx({
paymentsContainer: true,
[css(styles.paymentsContainer)]: true
Expand Down Expand Up @@ -260,11 +263,11 @@ class PaymentsTab extends ImmutableComponent {
<a className={css(
styles.switchWrap__mainIcons,
styles.mainIcons__settingsIcon,
!enabled && styles.mainIcons__settingsIconDisabled
!enableSettings && styles.mainIcons__settingsIconDisabled
)}
data-test-id={!enabled ? 'advancedSettingsButtonLoading' : 'advancedSettingsButton'}
data-test-id={!enableSettings ? 'advancedSettingsButtonLoading' : 'advancedSettingsButton'}
data-l10n-id='advancedSettingsIcon'
onClick={enabled ? this.props.showOverlay.bind(this, 'advancedSettings') : () => {}}
onClick={enableSettings ? this.props.showOverlay.bind(this, 'advancedSettings') : () => {}}
/>
</div>
</div>
Expand Down
15 changes: 14 additions & 1 deletion app/renderer/components/styles/animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,21 @@ const widthIncreaseKeyframes = (start, end) => ({
}
})

const loaderAnimation = {
'0': {
transform: 'translate(0,0)'
},
'50%': {
transform: 'translate(0,15px)'
},
'100%': {
transform: 'translate(0,0)'
}
}

module.exports = {
spinKeyframes,
opacityIncreaseKeyframes,
widthIncreaseKeyframes
widthIncreaseKeyframes,
loaderAnimation
}

0 comments on commit 44800cd

Please sign in to comment.