From 7601d3f5a1a2d6689271904dc093074d05f9017c Mon Sep 17 00:00:00 2001 From: Mathias Biilmann Christensen Date: Mon, 30 May 2016 17:13:40 -0700 Subject: [PATCH] Cleanup --- src/actions/auth.js | 5 ++--- src/components/EntryEditor.js | 3 +-- src/containers/App.js | 17 +++-------------- src/containers/CollectionPage.js | 9 +++------ src/containers/EntryPage.js | 13 ++----------- 5 files changed, 11 insertions(+), 36 deletions(-) diff --git a/src/actions/auth.js b/src/actions/auth.js index ca6b3835..e22be181 100644 --- a/src/actions/auth.js +++ b/src/actions/auth.js @@ -31,8 +31,7 @@ export function loginUser(credentials) { const backend = currentBackend(state.config); dispatch(authenticating()); - backend.authenticate(credentials) - .then((user) => dispatch(authenticate(user))) - //.catch((err) => dispatch(authError(err))); + return backend.authenticate(credentials) + .then((user) => dispatch(authenticate(user))); }; } diff --git a/src/components/EntryEditor.js b/src/components/EntryEditor.js index e397784b..bd872c63 100644 --- a/src/components/EntryEditor.js +++ b/src/components/EntryEditor.js @@ -10,7 +10,6 @@ export default class EntryEditor extends React.Component { } handleChange(entry) { - console.log('Got new entry: %o', entry.toObject()); this.setState({entry: entry}); } @@ -28,6 +27,6 @@ export default class EntryEditor extends React.Component { - + ; } } diff --git a/src/containers/App.js b/src/containers/App.js index 629169e0..74808844 100644 --- a/src/containers/App.js +++ b/src/containers/App.js @@ -5,18 +5,10 @@ import { loginUser } from '../actions/auth'; import { currentBackend } from '../backends/backend'; class App extends React.Component { - constructor(props) { - super(props); - } - componentDidMount() { this.props.dispatch(loadConfig()); } - componentWillReceiveProps(nextProps) { - //this.props.dispatch(loadBackend()); - } - configError(config) { return

Error loading the CMS configuration

@@ -81,13 +73,10 @@ class App extends React.Component { } function mapStateToProps(state) { - const { auth } = state; + const { auth, config } = state; + const user = auth && auth.get('user'); - return { - auth: auth, - user: auth && auth.get('user'), - config: state.config - }; + return {auth, config, user}; } export default connect(mapStateToProps)(App); diff --git a/src/containers/CollectionPage.js b/src/containers/CollectionPage.js index ca0b6302..276a2168 100644 --- a/src/containers/CollectionPage.js +++ b/src/containers/CollectionPage.js @@ -21,7 +21,7 @@ class DashboardPage extends React.Component { } render() { - const { collections, collection, slug, children } = this.props; + const { collections, collection } = this.props; if (collections == null) { return

No collections defined in your config.yml

; @@ -48,12 +48,9 @@ class DashboardPage extends React.Component { function mapStateToProps(state, ownProps) { const { collections } = state; const { name, slug } = ownProps.params; + const collection = name ? collections.get(name) : collections.first(); - return { - slug: slug, - collection: name ? collections.get(name) : collections.first(), - collections: collections - }; + return {slug, collection, collections}; } export default connect(mapStateToProps)(DashboardPage); diff --git a/src/containers/EntryPage.js b/src/containers/EntryPage.js index a953b2c0..17285f89 100644 --- a/src/containers/EntryPage.js +++ b/src/containers/EntryPage.js @@ -4,12 +4,6 @@ import { Map } from 'immutable'; import EntryEditor from '../components/EntryEditor'; class EntryPage extends React.Component { - componentDidMount() { - } - - componentWillReceiveProps(nextProps) { - } - render() { const { collection, entry } = this.props; @@ -18,13 +12,10 @@ class EntryPage extends React.Component { } function mapStateToProps(state, ownProps) { - const { collections } = state; + const { collections, media } = state; const collection = collections.get(ownProps.params.name); - return { - collection: collection, - collections: collections - }; + return {media, collection, collections}; } export default connect(mapStateToProps)(EntryPage);