Reward: add error handling

Also adds Notice component
This commit is contained in:
Alex Liebowitz 2017-03-30 14:08:27 -04:00 committed by Jeremy Kauffman
parent 8299e229fd
commit 3749e0393a
4 changed files with 49 additions and 0 deletions

25
ui/js/component/notice.js Normal file
View file

@ -0,0 +1,25 @@
import React from 'react';
import lbry from '../lbry.js';
import {Link} from '../component/link.js';
import {FileActions} from '../component/file-actions.js';
import {Thumbnail, TruncatedText, CreditAmount} from '../component/common.js';
export const Notice = React.createClass({
propTypes: {
isError: React.PropTypes.bool,
},
getDefaultProps: function() {
return {
isError: false,
};
},
render: function() {
return (
<section className={'notice' + (this.props.isError ? ' notice--error' : '')}>
{this.props.children}
</section>
);
},
});
export default Notice;

View file

@ -1,6 +1,7 @@
import React from 'react';
import lbryio from '../lbryio.js';
import {Link} from '../component/link.js';
import Notice from '../component/notice.js';
import {CreditAmount} from '../component/common.js';
const {shell} = require('electron');
@ -39,11 +40,13 @@ const LinkGithubReward = React.createClass({
this.setState({
confirming: false,
error: null,
});
}, (error) => {
console.log('failed with error:', error);
this.setState({
confirming: false,
error: error,
});
});
});
@ -51,6 +54,7 @@ const LinkGithubReward = React.createClass({
getInitialState: function() {
return {
confirming: false,
error: null,
};
},
render: function() {
@ -61,6 +65,11 @@ const LinkGithubReward = React.createClass({
<p>This will open a browser window where you can authorize GitHub to link your account to LBRY. This will record your email (no spam) and star the LBRY repo.</p>
<p>Once you're finished, you may confirm you've linked the account to receive your reward.</p>
</section>
{this.state.error
? <Notice isError>
{this.state.error.message}
</Notice>
: null}
<Link button="primary" label={this.state.confirming ? 'Confirming...' : 'Confirm'}
onClick={this.handleConfirmClicked} />

View file

@ -14,3 +14,4 @@
@import "page/_developer.scss";
@import "page/_watch.scss";
@import "page/_reward.scss";
@import "component/_notice.scss";

View file

@ -0,0 +1,14 @@
@import "../global";
.notice {
padding: 10px 20px;
border: 1px solid #000;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
border-radius: 5px;
}
.notice--error {
color: #b94a48;
background-color: #f2dede;
border-color: #eed3d7;
}