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

Commit

Permalink
Merge pull request #5496 from brave/feature/better-ledger-balance-errors
Browse files Browse the repository at this point in the history
Improved errors when loading ledger balance
  • Loading branch information
bbondy authored Nov 9, 2016
2 parents 08f1860 + e81aa58 commit 9a30631
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/extensions/brave/about-preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<link rel="localization" href="locales/{locale}/preferences.properties">
<link rel="localization" href="locales/{locale}/common.properties">
<link rel="localization" href="locales/{locale}/bravery.properties">
<link rel="localization" href="locales/{locale}/error.properties">
<link rel="localization" href="locales/{locale}/errorMessages.properties">
</head>
<body>
<div id="appContainer"/>
Expand Down
2 changes: 1 addition & 1 deletion app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ paymentsSidebarText2=All transaction IP addresses are anonymized with technology
paymentsSidebarText3=Brave Bitcoin Wallets are provided through a partnership with:
paymentsSidebarText4=Your contributions in the form of credit cards and bank cards are handled by:
accountBalance=account balance
accountBalanceConnectionError=error, can't retrieve data
accountBalanceConnectionError=An error occurred while loading your balance.
accountBalanceLoading=loading…
monthlyBudget=monthly budget
status=status
Expand Down
20 changes: 17 additions & 3 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const settings = require('../constants/settings')
const coinbaseCountries = require('../constants/coinbaseCountries')
const {passwordManagers, extensionIds} = require('../constants/passwordManagers')
const {startsWithOption, newTabMode, bookmarksToolbarMode} = require('../../app/common/constants/settingsEnums')
const {l10nErrorText} = require('../../app/common/lib/httpUtil')

const WidevineInfo = require('../../app/renderer/components/widevineInfo')
const aboutActions = require('./aboutActions')
Expand Down Expand Up @@ -1124,6 +1125,16 @@ class PaymentsTab extends ImmutableComponent {
return <div className='nextReconcileDate' data-l10n-args={JSON.stringify(l10nDataArgs)} data-l10n-id='statusNextReconcileDate' />
}

get ledgerDataErrorText () {
const ledgerError = this.props.ledgerData.get('error')
if (!ledgerError) {
return null
}
// 'error' here is a chromium webRequest error as returned by request.js
const errorCode = ledgerError.get('error').get('errorCode')
return l10nErrorText(errorCode)
}

btcToCurrencyString (btc) {
const balance = Number(btc || 0)
const currency = this.props.ledgerData.get('currency') || 'USD'
Expand Down Expand Up @@ -1183,16 +1194,19 @@ class PaymentsTab extends ImmutableComponent {
<td>
{
this.props.ledgerData.get('error') && this.props.ledgerData.get('error').get('caller') === 'getWalletProperties'
? <span data-l10n-id='accountBalanceConnectionError' />
: <span>
? <div>
<div data-l10n-id='accountBalanceConnectionError' />
<div className='accountBalanceError' data-l10n-id={this.ledgerDataErrorText} />
</div>
: <div>
<SettingsList>
<SettingItem>
{this.fundsAmount}
{this.walletButton}
{this.paymentHistoryButton}
</SettingItem>
</SettingsList>
</span>
</div>
}
</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion less/about/preferences.less
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ div.nextPaymentSubmission {
line-height: 24px;
box-sizing: border-box;
}
.nextReconcileDate {
.accountBalanceError, .nextReconcileDate {
font-size: 14px;
margin: 10px 0;
}
Expand Down

0 comments on commit 9a30631

Please sign in to comment.