lbry-desktop/src/renderer/page/report.js

97 lines
2.6 KiB
JavaScript
Raw Normal View History

import React from 'react';
2018-03-26 23:32:43 +02:00
import Button from 'component/button';
import { FormRow } from 'component/common/form';
import { doShowSnackBar } from 'redux/actions/app';
import lbry from '../lbry.js';
2016-11-22 21:19:08 +01:00
2017-06-15 02:37:42 +02:00
class ReportPage extends React.Component {
2017-05-17 10:10:25 +02:00
constructor(props) {
super(props);
this.state = {
submitting: false,
message: '',
2017-05-17 10:10:25 +02:00
};
}
submitMessage() {
2017-06-15 02:37:42 +02:00
const message = this.state.message;
if (message) {
this.setState({
2017-06-06 23:19:12 +02:00
submitting: true,
});
2017-06-15 02:37:42 +02:00
lbry.report_bug({ message }).then(() => {
this.setState({
submitting: false,
});
2017-06-15 02:37:42 +02:00
// Display global notice
const action = doShowSnackBar({
message: __('Message received! Thanks for helping.'),
2017-06-15 02:37:42 +02:00
isError: false,
});
window.app.store.dispatch(action);
});
2017-06-15 02:37:42 +02:00
this.setState({ message: '' });
}
2017-05-17 10:10:25 +02:00
}
2017-06-15 02:37:42 +02:00
onMessageChange(event) {
this.setState({
2017-06-15 02:37:42 +02:00
message: event.target.value,
2017-06-06 23:19:12 +02:00
});
2017-05-17 10:10:25 +02:00
}
render() {
return (
<main className="main--single-column">
2016-08-08 00:45:26 +02:00
<section className="card">
2017-05-22 00:34:12 +02:00
<div className="card__content">
<h3>{__('Report an Issue')}</h3>
2017-06-06 23:19:12 +02:00
<p>
{__(
'Please describe the problem you experienced and any information you think might be useful to us. Links to screenshots are great!'
2017-06-06 23:19:12 +02:00
)}
</p>
2017-05-22 00:34:12 +02:00
<div className="form-row">
2017-06-06 23:19:12 +02:00
<FormRow
type="textarea"
rows="10"
name="message"
2017-06-15 02:37:42 +02:00
value={this.state.message}
onChange={event => {
this.onMessageChange(event);
}}
placeholder={__('Description of your issue')}
2017-06-06 23:19:12 +02:00
/>
2017-05-22 00:34:12 +02:00
</div>
<div className="form-row form-row-submit">
2017-06-06 23:19:12 +02:00
<button
onClick={event => {
this.submitMessage(event);
}}
className={`button-block button-primary ${this.state.submitting ? 'disabled' : ''}`}
2017-06-06 23:19:12 +02:00
>
{this.state.submitting ? __('Submitting...') : __('Submit Report')}
2017-06-06 23:19:12 +02:00
</button>
2017-05-22 00:34:12 +02:00
</div>
2016-08-27 00:06:22 +02:00
</div>
</section>
2016-08-08 00:45:26 +02:00
<section className="card">
2017-05-22 00:34:12 +02:00
<div className="card__content">
<h3>{__('Developer?')}</h3>
{__('You can also')}{' '}
2018-03-26 23:32:43 +02:00
<Button
2017-06-06 23:19:12 +02:00
href="https://github.com/lbryio/lbry/issues"
label={__('submit an issue on GitHub')}
2017-06-06 23:19:12 +02:00
/>.
2017-05-22 00:34:12 +02:00
</div>
</section>
</main>
);
}
2017-05-17 10:10:25 +02:00
}
2016-11-22 21:19:08 +01:00
export default ReportPage;