Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
BigFatDog committed Jun 13, 2018
2 parents 5478ff1 + 4aa6c95 commit 7aad946
Show file tree
Hide file tree
Showing 26 changed files with 328 additions and 1,820 deletions.
2 changes: 1 addition & 1 deletion app/components/Auth/SubmitButton.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from 'styled-components';

const SubmitButton = styled.div`
background: #0575E6;
background: #0575e6;
color: white;
border: 0;
text-transform: uppercase;
Expand Down
17 changes: 11 additions & 6 deletions app/containers/Auth/Login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import isNull from 'lodash/isNull';
import isUndefined from 'lodash/isUndefined';
import trim from 'lodash/trim';

import injectSaga from '../../../utils/injectSaga';
import injectSaga from '../../../core/runtime/injectSaga';
import saga from './saga';

import { loginRequest, loginFailure } from '../../../core/auth/actions';
Expand Down Expand Up @@ -172,12 +172,11 @@ class Login extends Component {
<BottomPrompt>
<FormattedMessage {...messages.registerPrompt} />
&nbsp;<Link to="/signup">
<FormattedMessage {...messages.signUp} />
</Link>
<FormattedMessage {...messages.signUp} />
</Link>
</BottomPrompt>
</LoginPanel>
</LoginBox>

</LoginBoxContainer>
</CentralContainer>
);
Expand All @@ -199,7 +198,13 @@ const mapDispatchToProps = dispatch => {
};
};

const withConnect = connect(mapStateToProps, mapDispatchToProps);
const withConnect = connect(
mapStateToProps,
mapDispatchToProps
);
const withSaga = injectSaga({ key: 'login', saga });

export default compose(withConnect, withSaga)(injectIntl(Login));
export default compose(
withConnect,
withSaga
)(injectIntl(Login));
16 changes: 11 additions & 5 deletions app/containers/Auth/SignUp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import isNull from 'lodash/isNull';
import isUndefined from 'lodash/isUndefined';
import trim from 'lodash/trim';

import injectSaga from '../../../utils/injectSaga';
import injectSaga from '../../../core/runtime/injectSaga';
import saga from './saga';

import { signUpRequest, signUpFailure } from '../../../core/auth/actions';
Expand Down Expand Up @@ -199,8 +199,8 @@ class SignUp extends Component {
<BottomPrompt>
<FormattedMessage {...messages.signUpHaveAccount} />
&nbsp;<Link to={'/login'}>
<FormattedMessage {...messages.signIn} />
</Link>
<FormattedMessage {...messages.signIn} />
</Link>
</BottomPrompt>
</LoginPanel>
</LoginBox>
Expand All @@ -225,7 +225,13 @@ const mapDispatchToProps = dispatch => {
};
};

const withConnect = connect(mapStateToProps, mapDispatchToProps);
const withConnect = connect(
mapStateToProps,
mapDispatchToProps
);
const withSaga = injectSaga({ key: 'signUp', saga });

export default compose(withConnect, withSaga)(injectIntl(SignUp));
export default compose(
withConnect,
withSaga
)(injectIntl(SignUp));
12 changes: 9 additions & 3 deletions app/containers/Layout/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { NavBar, NavHeader, NavLink } from './Styles';

import { logout } from '../../../core/auth/actions';
import saga from './saga';
import injectSaga from '../../../utils/injectSaga';
import injectSaga from '../../../core/runtime/injectSaga';

class Header extends Component {
static propTypes = {
Expand Down Expand Up @@ -63,7 +63,13 @@ const mapDispatchToProps = dispatch => {
};
};

const withConnect = connect(null, mapDispatchToProps);
const withConnect = connect(
null,
mapDispatchToProps
);
const withSaga = injectSaga({ key: 'logout', saga });

export default compose(withConnect, withSaga)(Header);
export default compose(
withConnect,
withSaga
)(Header);
5 changes: 4 additions & 1 deletion app/containers/LocaleToggle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ export function mapDispatchToProps(dispatch) {
};
}

export default connect(mapStateToProps, mapDispatchToProps)(LocaleToggle);
export default connect(
mapStateToProps,
mapDispatchToProps
)(LocaleToggle);
18 changes: 12 additions & 6 deletions app/containers/PostList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { compose } from 'redux';
import { createStructuredSelector } from 'reselect';
import { graphql } from 'react-apollo';

import injectReducer from '../../utils/injectReducer';
import injectSaga from '../../utils/injectSaga';
import injectReducer from '../../core/runtime/injectReducer';
import injectSaga from '../../core/runtime/injectSaga';
import messages from './messages';

import { changeUsername } from './actions';
Expand Down Expand Up @@ -77,7 +77,10 @@ const mapStateToProps = createStructuredSelector({
username: makeSelectUsername(),
});

const withConnect = connect(mapStateToProps, mapDispatchToProps);
const withConnect = connect(
mapStateToProps,
mapDispatchToProps
);

const withReducer = injectReducer({ key: 'home', reducer });
const withSaga = injectSaga({ key: 'home', saga });
Expand All @@ -90,6 +93,9 @@ const withGraphQL = graphql(DashboardListQuery, {
},
});

export default compose(withGraphQL, withReducer, withSaga, withConnect)(
HomePage
);
export default compose(
withGraphQL,
withReducer,
withSaga,
withConnect
)(HomePage);
2 changes: 1 addition & 1 deletion app/containers/PostList/saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { call, put, select, takeLatest } from 'redux-saga/effects';

import request from '../../utils/request';
import request from '../../core/http/request';
import { makeSelectUsername } from './/selectors';

/**
Expand Down
17 changes: 13 additions & 4 deletions app/core/auth/AuthComp.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from './selector';

import saga from './saga';
import injectSaga from '../../utils/injectSaga';
import injectSaga from '../runtime/injectSaga';
import Loading from '../../components/Loading';

export default function requireAuthentication(Component) {
Expand All @@ -25,7 +25,10 @@ export default function requireAuthentication(Component) {
}

checkAuth() {
if (localStorage.getItem('token') === null || localStorage.getItem('refreshToken') === null ) {
if (
localStorage.getItem('token') === null ||
localStorage.getItem('refreshToken') === null
) {
this.props.dispatch(push(`/login`));
} else {
if (
Expand Down Expand Up @@ -57,7 +60,13 @@ export default function requireAuthentication(Component) {
isAuthenticating: makeSelectIsAuthenticating(),
});

const withConnect = connect(mapStateToProps, null);
const withConnect = connect(
mapStateToProps,
null
);
const withSaga = injectSaga({ key: 'verify', saga });
return compose(withConnect, withSaga)(AuthenticatedComponent);
return compose(
withConnect,
withSaga
)(AuthenticatedComponent);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import hoistNonReactStatics from 'hoist-non-react-statics';

import getInjectors from './reducerInjectors';

/* eslint-disable no-undef */

/**
* Dynamically injects a reducer
*
Expand Down
13 changes: 10 additions & 3 deletions app/utils/injectSaga.js → app/core/runtime/injectSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import hoistNonReactStatics from 'hoist-non-react-statics';

import getInjectors from './sagaInjectors';

/* eslint-disable no-undef */

/**
* Dynamically injects a saga, passes component's props as saga arguments
*
Expand All @@ -13,9 +15,13 @@ import getInjectors from './sagaInjectors';
* cancelled with `task.cancel()` on component un-mount for improved performance. Another two options:
* - constants.DAEMON—starts the saga on component mount and never cancels it or starts again,
* - constants.ONCE_TILL_UNMOUNT—behaves like 'RESTART_ON_REMOUNT' but never runs it again.
*
* @param {array} [args] Arguments passed to the saga once called
* By default your saga will receive
* - component props
* - action
* If defined, the saga will receive those args instead of the component props
*/
export default ({ key, saga, mode }) => WrappedComponent => {
export default ({ key, saga, mode, args }) => WrappedComponent => {
class InjectSaga extends React.Component {
static WrappedComponent = WrappedComponent;
static contextTypes = {
Expand All @@ -27,8 +33,9 @@ export default ({ key, saga, mode }) => WrappedComponent => {

componentWillMount() {
const { injectSaga } = this.injectors;
const injectedArgs = args || [this.props];

injectSaga(key, { saga, mode }, this.props);
injectSaga(key, { saga, mode }, ...injectedArgs);
}

componentWillUnmount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import isFunction from 'lodash/isFunction';
import isString from 'lodash/isString';

import checkStore from './checkStore';
import createReducer from '../reducers';
import createReducer from '../../reducers';

export function injectReducerFactory(store, isValid) {
return function injectReducer(key, reducer) {
if (!isValid) checkStore(store);

invariant(
isString(key) && !isEmpty(key) && isFunction(reducer),
'(client/utils...) injectReducer: Expected `reducer` to be a reducer function'
'(core/runtime...) injectReducer: Expected `reducer` to be a reducer function'
);

// Check `store.injectedReducers[key] === reducer` for hot reloading when a key is the same but a reducer is different
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const allowedModes = [RESTART_ON_REMOUNT, DAEMON, ONCE_TILL_UNMOUNT];
const checkKey = key =>
invariant(
isString(key) && !isEmpty(key),
'(client/utils...) injectSaga: Expected `key` to be a non empty string'
'(core/runtime...) injectSaga: Expected `key` to be a non empty string'
);

const checkDescriptor = descriptor => {
Expand All @@ -22,12 +22,12 @@ const checkDescriptor = descriptor => {
};
invariant(
conformsTo(descriptor, shape),
'(client/utils...) injectSaga: Expected a valid saga descriptor'
'(core/runtime...) injectSaga: Expected a valid saga descriptor'
);
};

export function injectSagaFactory(store, isValid) {
return function injectSaga(key, descriptor = {}, args) {
return function injectSaga(key, descriptor = {}, ...args) {
if (!isValid) checkStore(store);

const newDescriptor = {
Expand Down Expand Up @@ -56,7 +56,7 @@ export function injectSagaFactory(store, isValid) {
) {
store.injectedSagas[key] = {
...newDescriptor,
task: store.runSaga(saga, args),
task: store.runSaga(saga, ...args),
}; // eslint-disable-line no-param-reassign
}
};
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { shallow } from 'enzyme';
import React from 'react';
import identity from 'lodash/identity';

import configureStore from '../../core/configureStore';
import configureStore from '../../configureStore';
import injectReducer from '../injectReducer';
import * as reducerInjectors from '../reducerInjectors';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { put } from 'redux-saga/effects';
import { shallow } from 'enzyme';
import React from 'react';

import configureStore from '../../core/configureStore';
import configureStore from '../../configureStore';
import injectSaga from '../injectSaga';
import * as sagaInjectors from '../sagaInjectors';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { memoryHistory } from 'react-router-dom';
import { fromJS } from 'immutable';
import identity from 'lodash/identity';

import configureStore from '../../core/configureStore';
import configureStore from '../../configureStore';

import getInjectors, { injectReducerFactory } from '../reducerInjectors';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Test the request function
*/

import request from '../request';
import request from '../../http/request';

describe('request', () => {
// Before each test, stub the fetch function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { memoryHistory } from 'react-router-dom';
import { put } from 'redux-saga/effects';

import configureStore from '../../core/configureStore';
import configureStore from '../../configureStore';
import getInjectors, {
injectSagaFactory,
ejectSagaFactory,
Expand Down
10 changes: 8 additions & 2 deletions app/server/database/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ export default app => {
});
db.on('disconnected', function() {
console.log('MongoDB disconnected!');
mongoose.connect(Settings.mongodb.url, { auto_reconnect: true });
mongoose.connect(
Settings.mongodb.url,
{ auto_reconnect: true }
);
});

mongoose.connect(Settings.mongodb.url, { auto_reconnect: true });
mongoose.connect(
Settings.mongodb.url,
{ auto_reconnect: true }
);
};
15 changes: 9 additions & 6 deletions app/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,16 @@ app.listen(port, host, err => {

// Connect to ngrok in dev mode
if (ngrok) {
ngrok.connect(port, (innerErr, url) => {
if (innerErr) {
return logger.error(innerErr);
ngrok.connect(
port,
(innerErr, url) => {
if (innerErr) {
return logger.error(innerErr);
}

logger.appStarted(port, prettyHost, url);
}

logger.appStarted(port, prettyHost, url);
});
);
} else {
logger.appStarted(port, prettyHost);
}
Expand Down
1 change: 1 addition & 0 deletions internals/webpack/webpack.dev.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const dependencyHandlers = () => {
};

export default baseConfig({
mode: 'development',
// Add hot reloading in development
entry: [
'eventsource-polyfill', // Necessary for hot reloading with IE
Expand Down
Loading

0 comments on commit 7aad946

Please sign in to comment.