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

Adding ability to view logs and open log directory #1569

Merged
merged 7 commits into from
Jun 13, 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
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ module.name_mapper='^lbry\(.*\)$' -> '<PROJECT_ROOT>/src/renderer/lbry\1'
module.name_mapper='^rewards\(.*\)$' -> '<PROJECT_ROOT>/src/renderer/rewards\1'
module.name_mapper='^modal\(.*\)$' -> '<PROJECT_ROOT>/src/renderer/modal\1'
module.name_mapper='^app\(.*\)$' -> '<PROJECT_ROOT>/src/renderer/app\1'
module.name_mapper='^native\(.*\)$' -> '<PROJECT_ROOT>/src/renderer/native\1'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this was added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seanyesmunt This was to resolve a flow error that was on in line


[strict]
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

### Added

* Add ability to open log file and log directory in the help page ([#1556](https://github.com/lbryio/lbry-app/issues/1556))
* Add ability to resend verification email ([#1492](https://github.com/lbryio/lbry-app/issues/1492))
* Add Narrative about Feature Request on Help Page and Report Page ([#1551](https://github.com/lbryio/lbry-app/pull/1551))
* Add keyboard shortcut to quit the app on Windows ([#1202](https://github.com/lbryio/lbry-app/pull/1202))
Expand All @@ -27,6 +28,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
* Move rewards logic to interal api ([#1509](https://github.com/lbryio/lbry-app/pull/1509))

### Fixed
* Fixing content address extending outside of visible area. ([#741](https://github.com/lbryio/lbry-app/issues/741))
* Fix content-type not shown correctly in file description ([#863](https://github.com/lbryio/lbry-app/pull/863))
* Fix [Flow](https://flow.org/) ([#1197](https://github.com/lbryio/lbry-app/pull/1197))
* Fix black screen on macOS after maximizing LBRY and then closing ([#1235](https://github.com/lbryio/lbry-app/pull/1235))
Expand Down
7 changes: 6 additions & 1 deletion src/renderer/page/help/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import { connect } from 'react-redux';
import { doAuthNavigate } from 'redux/actions/navigation';
import { doFetchAccessToken } from 'redux/actions/user';
import { selectDaemonSettings } from 'redux/selectors/settings';
import { selectAccessToken, selectUser } from 'redux/selectors/user';
import HelpPage from './view';

const select = state => ({
user: selectUser(state),
accessToken: selectAccessToken(state),
deamonSettings: selectDaemonSettings(state),
});

const perform = dispatch => ({
doAuth: () => dispatch(doAuthNavigate('/help')),
fetchAccessToken: () => dispatch(doFetchAccessToken()),
});

export default connect(select, perform)(HelpPage);
export default connect(
select,
perform
)(HelpPage);
79 changes: 71 additions & 8 deletions src/renderer/page/help/view.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
// @TODO: Customize advice based on OS
import React from 'react';
// @flow
import * as React from 'react';
import { shell } from 'electron';
import { Lbry } from 'lbry-redux';
import Native from 'native';
import Button from 'component/button';
import BusyIndicator from 'component/common/busy-indicator';
import Icon from 'component/common/icon';
import Page from 'component/page';
import * as icons from 'constants/icons';

class HelpPage extends React.PureComponent {
constructor(props) {
type DeamonSettings = {
data_dir: string | any,
};

type Props = {
deamonSettings: DeamonSettings,
accessToken: string,
fetchAccessToken: () => void,
doAuth: () => void,
user: any,
};

type VersionInfo = {
os_system: string,
os_release: string,
platform: string,
lbrynet_version: string,
lbryum_version: string,
};

type State = {
versionInfo: VersionInfo | any,
lbryId: String | any,
uiVersion: ?string,
upgradeAvailable: ?boolean,
accessTokenHidden: ?boolean,
};

class HelpPage extends React.PureComponent<Props, State> {
constructor(props: Props) {
super(props);

this.state = {
Expand All @@ -20,11 +49,12 @@ class HelpPage extends React.PureComponent {
accessTokenHidden: true,
};

this.showAccessToken = this.showAccessToken.bind(this);
(this: any).showAccessToken = this.showAccessToken.bind(this);
(this: any).openLogFile = this.openLogFile.bind(this);
}

componentDidMount() {
Native.getAppVersionInfo().then(({ remoteVersion, localVersion, upgradeAvailable }) => {
Native.getAppVersionInfo().then(({ localVersion, upgradeAvailable }) => {
this.setState({
uiVersion: localVersion,
upgradeAvailable,
Expand All @@ -50,13 +80,24 @@ class HelpPage extends React.PureComponent {
});
}

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}`);
}
}

render() {
let ver;
let osName;
let platform;
let newVerLink;

const { accessToken, doAuth, user } = this.props;
const { accessToken, doAuth, user, deamonSettings } = this.props;
const { data_dir: dataDirectory } = deamonSettings;

if (this.state.versionInfo) {
ver = this.state.versionInfo;
Expand Down Expand Up @@ -108,12 +149,34 @@ class HelpPage extends React.PureComponent {
</div>
</section>

<section className="card card--section">
<div className="card__title">{__('View your Log')}</div>
<p className="card__subtitle">
{__(
'Do you find something wrong? Have a look in your log, or send your log to support for some help.'
)}
</p>
<div className="card__actions">
<Button
button="primary"
label={__('Open Log')}
icon={icons.REPORT}
onClick={() => this.openLogFile(dataDirectory)}
/>
<Button
button="primary"
label={__('Open Log Folder')}
icon={icons.REPORT}
onClick={() => shell.showItemInFolder(dataDirectory)}
/>
</div>
</section>

<section className="card card--section">
<div className="card__title">{__('Report a Bug or Suggest a New Feature')}</div>
<p className="card__subtitle">
{__('Did you find something wrong? Think LBRY could add something useful and cool?')}
</p>

<div className="card__actions">
<Button
navigate="/report"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/scss/component/_card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
flex-direction: column;
}

.card > h1 {
word-wrap: break-word;
}

.card--section {
background-color: var(--card-bg);
padding: $spacing-vertical;
Expand Down