lbry-desktop/src/renderer/page/help/view.jsx

299 lines
9.3 KiB
React
Raw Normal View History

// @TODO: Customize advice based on OS
// @flow
import * as icons from 'constants/icons';
import * as React from 'react';
import { shell } from 'electron';
2018-04-18 06:03:01 +02:00
import { Lbry } from 'lbry-redux';
import Native from 'native';
2018-03-26 23:32:43 +02:00
import Button from 'component/button';
import BusyIndicator from 'component/common/busy-indicator';
import Page from 'component/page';
type DeamonSettings = {
2018-06-10 01:19:04 +02:00
data_dir: string | any,
};
type Props = {
deamonSettings: DeamonSettings,
accessToken: string,
fetchAccessToken: () => void,
doAuth: () => void,
user: any,
};
2018-06-10 01:19:04 +02:00
type VersionInfo = {
os_system: string,
os_release: string,
platform: string,
lbrynet_version: string,
};
type State = {
2018-06-10 01:19:04 +02:00
versionInfo: VersionInfo | any,
lbryId: String | any,
2018-06-10 01:19:04 +02:00
uiVersion: ?string,
upgradeAvailable: ?boolean,
accessTokenHidden: ?boolean,
};
class HelpPage extends React.PureComponent<Props, State> {
constructor(props: Props) {
2017-05-17 10:10:25 +02:00
super(props);
this.state = {
versionInfo: null,
lbryId: null,
2017-05-31 18:22:50 +02:00
uiVersion: null,
2017-06-06 23:19:12 +02:00
upgradeAvailable: null,
2017-07-21 08:23:39 +02:00
accessTokenHidden: true,
};
2018-03-26 23:32:43 +02:00
(this: any).showAccessToken = this.showAccessToken.bind(this);
(this: any).openLogFile = this.openLogFile.bind(this);
2017-05-17 10:10:25 +02:00
}
2018-03-26 23:32:43 +02:00
componentDidMount() {
Native.getAppVersionInfo().then(({ localVersion, upgradeAvailable }) => {
this.setState({
uiVersion: localVersion,
upgradeAvailable,
});
});
2018-04-18 06:03:01 +02:00
Lbry.version().then(info => {
2017-05-25 20:29:28 +02:00
this.setState({
2017-06-06 23:19:12 +02:00
versionInfo: info,
});
});
Lbry.status().then(info => {
this.setState({
2018-08-13 18:53:31 +02:00
lbryId: info.installation_id,
});
});
2017-07-21 08:23:39 +02:00
if (!this.props.accessToken) this.props.fetchAccessToken();
}
showAccessToken() {
this.setState({
accessTokenHidden: false,
});
2017-05-17 10:10:25 +02:00
}
openLogFile(userHomeDirectory: string) {
const logFileName = 'lbrynet.log';
const os = this.state.versionInfo.os_system;
if (os === 'Darwin' || os === 'Linux') {
shell.openItem(`${userHomeDirectory}/${logFileName}`);
} else {
shell.openItem(`${userHomeDirectory}\\${logFileName}`);
}
}
2017-05-17 10:10:25 +02:00
render() {
2018-04-18 06:03:01 +02:00
let ver;
let osName;
let platform;
let newVerLink;
2017-05-22 00:34:12 +02:00
const { accessToken, doAuth, user, deamonSettings } = this.props;
const { data_dir: dataDirectory } = deamonSettings;
2017-05-22 00:34:12 +02:00
if (this.state.versionInfo) {
ver = this.state.versionInfo;
2018-04-18 06:03:01 +02:00
if (ver.os_system === 'Darwin') {
osName = parseInt(ver.os_release.match(/^\d+/), 10) < 16 ? 'Mac OS X' : 'Mac OS';
2017-06-06 23:19:12 +02:00
platform = `${osName} ${ver.os_release}`;
newVerLink = 'https://lbry.io/get/lbry.dmg';
2018-04-18 06:03:01 +02:00
} else if (ver.os_system === 'Linux') {
platform = `Linux (${ver.platform})`;
newVerLink = 'https://lbry.io/get/lbry.deb';
} else {
platform = `Windows (${ver.platform})`;
newVerLink = 'https://lbry.io/get/lbry.msi';
2016-08-27 00:06:22 +02:00
}
} else {
ver = null;
}
2016-08-27 00:06:22 +02:00
2016-04-20 12:28:13 +02:00
return (
2018-03-26 23:32:43 +02:00
<Page>
<section className="card card--section">
<header className="card__header">
<h2 className="card__title">{__('Read the FAQ')}</h2>
<p className="card__subtitle">{__('Our FAQ answers many common questions.')}</p>
</header>
2018-03-26 23:32:43 +02:00
<div className="card__content">
<div className="card__actions">
<Button
href="https://lbry.io/faq"
label={__('Read the FAQ')}
icon={icons.HELP}
button="primary"
/>
</div>
2017-05-04 05:44:08 +02:00
</div>
2016-08-08 00:45:26 +02:00
</section>
2018-03-26 23:32:43 +02:00
<section className="card card--section">
<header className="card__header">
<h2 className="card__title">{__('Get Live Help')}</h2>
<p className="card__subtitle">
{__('Live help is available most hours in the')} <strong>#help</strong>{' '}
{__('channel of our Discord chat room.')}
</p>
</header>
<div className="card__content">
<div className="card__actions">
<Button
button="primary"
label={__('Join Our Chat')}
2019-01-22 21:36:28 +01:00
icon={icons.CHAT}
href="https://chat.lbry.io"
/>
</div>
2017-05-04 05:44:08 +02:00
</div>
2016-08-08 00:45:26 +02:00
</section>
2018-03-26 23:32:43 +02:00
<section className="card card--section">
<header className="card__header">
<h2 className="card__title">{__('View your Log')}</h2>
<p className="card__subtitle">
{__('Did something go wrong? Have a look in your log file, or send it to')}{' '}
<Button button="link" label={__('support')} href="https://lbry.io/faq/support" />.
</p>
</header>
<div className="card__content">
<div className="card__actions">
<Button
button="primary"
label={__('Open Log')}
onClick={() => this.openLogFile(dataDirectory)}
/>
<Button
button="primary"
label={__('Open Log Folder')}
onClick={() => shell.openItem(dataDirectory)}
/>
</div>
</div>
</section>
2018-03-26 23:32:43 +02:00
<section className="card card--section">
<header className="card__header">
<h2 className="card__title">{__('Report a Bug or Suggest a New Feature')}</h2>
<p className="card__subtitle">
{__('Did you find something wrong? Think LBRY could add something useful and cool?')}{' '}
<Button button="link" label={__('Learn more')} href="https://lbry.io/faq/support" />.
</p>
</header>
<div className="card__content">
<div className="card__actions">
<Button
navigate="/report"
label={__('Submit a Bug Report/Feature Request')}
icon={icons.REPORT}
button="primary"
/>
</div>
<div className="card__meta">{__('Thanks! LBRY is made by its users.')}</div>
2017-05-04 05:44:08 +02:00
</div>
2016-04-20 12:28:13 +02:00
</section>
2017-07-21 08:23:39 +02:00
2018-03-26 23:32:43 +02:00
<section className="card card--section">
<header className="card__header">
<h2 className="card__title">{__('About')}</h2>
2018-03-26 23:32:43 +02:00
{this.state.upgradeAvailable !== null && this.state.upgradeAvailable ? (
<p className="card__subtitle">
{__('A newer version of LBRY is available.')}{' '}
<Button button="link" href={newVerLink} label={__('Download now!')} />
</p>
) : (
<p className="card__subtitle">{__('Your LBRY app is up to date.')}</p>
)}
</header>
<div className="card__content">
{this.state.uiVersion && ver ? (
2019-02-13 17:27:20 +01:00
<table className="table table--stretch">
<tbody>
<tr>
<td>{__('App')}</td>
<td>{this.state.uiVersion}</td>
</tr>
<tr>
<td>{__('Daemon (lbrynet)')}</td>
<td>{ver.lbrynet_version}</td>
</tr>
<tr>
<td>{__('Connected Email')}</td>
<td>
{user && user.primary_email ? (
<React.Fragment>
{user.primary_email}{' '}
<Button
button="link"
href={`https://lbry.io/list/edit/${accessToken}`}
label={__('Update mailing preferences')}
/>
</React.Fragment>
) : (
<React.Fragment>
<span className="empty">{__('none')} </span>
<Button button="link" onClick={() => doAuth()} label={__('set email')} />
</React.Fragment>
)}
</td>
</tr>
<tr>
<td>{__('Reward Eligible')}</td>
<td>{user && user.is_reward_approved ? __('Yes') : __('No')}</td>
</tr>
<tr>
<td>{__('Platform')}</td>
<td>{platform}</td>
</tr>
<tr>
<td>{__('Installation ID')}</td>
<td>{this.state.lbryId}</td>
</tr>
<tr>
<td>{__('Access Token')}</td>
<td>
{this.state.accessTokenHidden && (
<Button button="link" label={__('View')} onClick={this.showAccessToken} />
)}
{!this.state.accessTokenHidden &&
accessToken && (
<div>
<p>{accessToken}</p>
<div className="alert-text">
{__('This is equivalent to a password. Do not post or share this.')}
</div>
2017-11-24 15:31:05 +01:00
</div>
)}
</td>
</tr>
</tbody>
</table>
) : (
<BusyIndicator message={__('Looking up version info')} />
)}
</div>
2017-05-25 20:29:28 +02:00
</section>
2018-03-26 23:32:43 +02:00
</Page>
2016-04-20 12:28:13 +02:00
);
}
2017-05-17 10:10:25 +02:00
}
2016-11-22 21:19:08 +01:00
2017-04-07 07:15:22 +02:00
export default HelpPage;