Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds wallet creation failed flow #689

Merged
merged 2 commits into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions browser/ui/webui/brave_webui_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ void CustomizeWebUIHTMLSource(const std::string &name, content::WebUIDataSource*
{ "walletActivity", IDS_BRAVE_UI_WALLET_ACTIVITY },
{ "walletAddress", IDS_BRAVE_UI_WALLET_ADDRESS },
{ "walletBalance", IDS_BRAVE_UI_WALLET_BALANCE },
{ "walletFailedButton", IDS_BRAVE_UI_WALLET_FAILED_BUTTON },
{ "walletFailedTitle", IDS_BRAVE_UI_WALLET_FAILED_TITLE },
{ "walletFailedText", IDS_BRAVE_UI_WALLET_FAILED_TEXT },
{ "welcome", IDS_BRAVE_UI_WELCOME },
{ "welcomeButtonTextOne", IDS_BRAVE_UI_WELCOME_BUTTON_TEXT_ONE},
{ "welcomeButtonTextTwo", IDS_BRAVE_UI_WELCOME_BUTTON_TEXT_TWO},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ export class Panel extends React.Component<Props, State> {
tipsEnabled={true}
includeInAuto={!publisher.excluded}
attentionScore={(publisher.percentage || 0).toString()}
donationAmounts={[]}
onToggleTips={this.doNothing}
donationAction={this.showDonateToSiteDetail}
onAmountChange={this.doNothing}
Expand Down
49 changes: 40 additions & 9 deletions components/brave_rewards/ui/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,74 @@ import { WelcomePage } from 'brave-ui/features/rewards'
interface Props extends Rewards.ComponentProps {
}

export class App extends React.Component<Props, {}> {
interface State {
creating: boolean
}

export class App extends React.Component<Props, State> {
constructor (props: Props) {
super(props)
this.state = {
creating: false
}
}

componentDidMount () {
if (!this.props.rewardsData.walletCreated) {
this.actions.checkWalletExistence()
}
}

componentDidUpdate (prevProps: Props, prevState: State) {
if (
this.state.creating &&
!prevProps.rewardsData.walletCreateFailed &&
this.props.rewardsData.walletCreateFailed
) {
this.setState({
creating: false
})
}
}

onCreateWalletClicked = () => {
this.actions.createWallet()
this.setState({
creating: true
})
}

get actions () {
return this.props.actions
}

render () {
const { rewardsData } = this.props
const { walletCreated, walletCreateFailed } = this.props.rewardsData

let props: {onReTry?: () => void} = {}

if (walletCreateFailed) {
props = {
onReTry: this.onCreateWalletClicked
}
}

return (
<div id='rewardsPage'>
{
!rewardsData.walletCreated && !rewardsData.walletCreateFailed
!walletCreated
? <WelcomePage
optInAction={this.onCreateWalletClicked}
creating={this.state.creating}
{...props}
/>
: null
}
{
rewardsData.walletCreated
walletCreated
? <SettingsPage />
: null
}
{
rewardsData.walletCreateFailed
? <div>Wallet Create Failed!</div>
: null
}
</div>
)
}
Expand Down
3 changes: 3 additions & 0 deletions components/brave_rewards/ui/reducers/wallet_reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const createWallet = (state: Rewards.State) => {
const walletReducer: Reducer<Rewards.State | undefined> = (state: Rewards.State, action) => {
switch (action.type) {
case types.CREATE_WALLET:
state = { ...state }
state.walletCreateFailed = false
state.walletCreated = false
chrome.send('brave_rewards.createWalletRequested', [])
break
case types.WALLET_CREATED:
Expand Down
3 changes: 3 additions & 0 deletions components/resources/brave_components_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@
<message name="IDS_BRAVE_UI_WALLET_ACTIVITY" desc="">Wallet Activity</message>
<message name="IDS_BRAVE_UI_WALLET_ADDRESS" desc="">Wallet Address</message>
<message name="IDS_BRAVE_UI_WALLET_BALANCE" desc="">wallet balance</message>
<message name="IDS_BRAVE_UI_WALLET_FAILED_BUTTON" desc="">Try again</message>
<message name="IDS_BRAVE_UI_WALLET_FAILED_TITLE" desc="">Wallet creation failed</message>
<message name="IDS_BRAVE_UI_WALLET_FAILED_TEXT" desc="">Please check your internet connection.</message>
<message name="IDS_BRAVE_UI_WELCOME" desc="">Welcome!</message>
<message name="IDS_BRAVE_UI_WELCOME_BUTTON_TEXT_ONE" desc="">Start Earning Now!</message>
<message name="IDS_BRAVE_UI_WELCOME_BUTTON_TEXT_TWO" desc="">Join Rewards</message>
Expand Down