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

chore(app): removed logout button when not signed in #1098

Merged
merged 2 commits into from Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/renderer/auth/hocs/withAuthState.js
@@ -1,14 +1,17 @@
import { compose, mapProps } from 'recompose';
import { progressValues } from 'spunky';
import { progressValues, withProgress } from 'spunky';
import { omit } from 'lodash';

import authActions from 'auth/actions/authActions';

const { LOADED } = progressValues;

export default function withAuthState() {
return compose(
withProgress(authActions, { propName: 'authStateLoadingProgress' }),
mapProps((props) => ({
...omit(props, 'progress'),
authenticated: props.progress === LOADED
...omit(props, 'authStateLoadingProgress'),
authenticated: props.authStateLoadingProgress === LOADED
}))
);
}
@@ -1,36 +1,33 @@
import React from 'react';
import { string, func, arrayOf } from 'prop-types';
import { string, func, arrayOf, bool } from 'prop-types';
import { omit } from 'lodash';
import { progressValues } from 'spunky';

import RequestProcessor from './RequestProcessor';
import requestShape from '../../shapes/requestShape';

const { LOADED } = progressValues;

export default class RequestsProcessor extends React.PureComponent {
static propTypes = {
sessionId: string.isRequired,
src: string.isRequired,
requests: arrayOf(requestShape).isRequired,
onResolve: func.isRequired,
onReject: func.isRequired,
progress: string.isRequired
authenticated: bool.isRequired
};

render() {
return this.props.requests.map(this.renderRequest);
}

renderRequest = (request) => {
const { progress } = this.props;
const { authenticated } = this.props;

return (
<RequestProcessor
{...omit(this.props, 'requests', 'progress')}
{...omit(this.props, 'requests')}
key={`request-${request.id}`}
request={request}
authenticated={progress === LOADED}
authenticated={authenticated}
/>
);
};
Expand Down
5 changes: 2 additions & 3 deletions src/renderer/browser/components/RequestsProcessor/index.js
@@ -1,9 +1,8 @@
import { compose } from 'recompose';
import { connect } from 'react-redux';
import { get } from 'lodash';
import { withProgress } from 'spunky';

import authActions from 'auth/actions/authActions';
import withAuthState from 'auth/hocs/withAuthState';

import RequestsProcessor from './RequestsProcessor';

Expand All @@ -12,6 +11,6 @@ const mapStateToProps = (state, ownProps) => ({
});

export default compose(
withProgress(authActions),
withAuthState(),
connect(mapStateToProps)
)(RequestsProcessor);
Expand Up @@ -3,7 +3,7 @@
import React from 'react';
import classNames from 'classnames';
import { NavLink } from 'react-router-dom';
import { string } from 'prop-types';
import { string, bool } from 'prop-types';

import { APPSTORE, ACCOUNT, EXCHANGE, EXTERNAL, SETTINGS } from 'browser/values/browserValues';
import AppStoreIcon from 'shared/images/icons/discover.svg';
Expand All @@ -22,7 +22,8 @@ import styles from './Navigation.scss';

export default class Navigation extends React.PureComponent {
static propTypes = {
className: string
className: string,
authenticated: bool.isRequired
};

static defaultProps = {
Expand All @@ -31,6 +32,8 @@ export default class Navigation extends React.PureComponent {

render() {
const matchExchange = (url) => /https:\/\/exchange\.nash\.io.+/i.test(url);
const { authenticated } = this.props;

return (
<nav className={classNames(styles.navigation, this.props.className)}>
<ul>
Expand Down Expand Up @@ -81,13 +84,15 @@ export default class Navigation extends React.PureComponent {
</div>
</Tooltip>
</li>
<li>
<Tooltip overlay="Logout">
<NavLink id="logout" exact to="/logout" draggable={false} className={styles.link}>
<LogoutIcon aria-label="logout" />
</NavLink>
</Tooltip>
</li>
{authenticated && (
<li>
<Tooltip overlay="Logout">
<NavLink id="logout" exact to="/logout" draggable={false} className={styles.link}>
<LogoutIcon aria-label="logout" />
</NavLink>
</Tooltip>
</li>
)}
</ul>
</nav>
);
Expand Down
@@ -1 +1,7 @@
export { default } from './Navigation';
import { compose } from 'recompose';

import withAuthState from 'auth/hocs/withAuthState';

import Navigation from './Navigation';

export default compose(withAuthState())(Navigation);
Expand Up @@ -54,17 +54,11 @@ export default class PrivateTabLink extends React.PureComponent {
onConfirm: this.handleConfirm,
onCancel: undefined
});

// return <Component {...props} />;
}
};

handleConfirm = () => {
const { type, target } = this.props;
this.props.openTab({ type, target });
};

onCancel = () => {
// TODO
};
}
@@ -1,7 +1,6 @@
import { compose, mapProps } from 'recompose';
import { compose } from 'recompose';
import { withRouter } from 'react-router-dom';
import { withProgress, progressValues } from 'spunky';
import { omit } from 'lodash';
import { withProgress } from 'spunky';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

Expand All @@ -10,11 +9,10 @@ import withAuth from 'shared/hocs/withAuth';
import authActions from 'auth/actions/authActions';

import { openTab } from 'browser/actions/browserActions';
import withAuthState from 'auth/hocs/withAuthState';

import PrivateTabLink from './PrivateTabLink';

const { LOADED } = progressValues;

const mapStateToProps = (state, props) => {
const { tabs, activeSessionId } = state.browser;
const active = props.target === tabs[activeSessionId].target;
Expand All @@ -31,5 +29,5 @@ export default compose(
),
withProgress(authActions),
withAuth(),
mapProps((props) => ({ ...omit(props, 'progress'), authenticated: props.progress === LOADED }))
withAuthState()
)(PrivateTabLink);