Initial commit

This commit is contained in:
Mathias Biilmann Christensen
2016-02-25 00:45:56 -08:00
commit c60d8ba706
19 changed files with 590 additions and 0 deletions

58
src/containers/App.js Normal file
View File

@ -0,0 +1,58 @@
import React from 'react';
import { connect } from 'react-redux';
import { loadConfig } from '../actions/config';
class App extends React.Component {
constructor(props) {
super(props);
}
componentDidMount() {
this.props.dispatch(loadConfig());
}
configError(config) {
return <div>
<h1>Error loading the CMS configuration</h1>
<div>
<p>The "config.yml" file could not be loaded or failed to parse properly.</p>
<p><strong>Error message:</strong> {config.get('error')}</p>
</div>
</div>;
}
configLoading() {
return <div>
<h1>Loading configuration...</h1>
</div>;
}
render() {
const { config, children } = this.props;
if (config === null) {
return null;
}
if (config.get('error')) {
return this.configError(config);
}
if (config.get('isFetching')) {
return this.configLoading();
}
return (
<div>{children}</div>
);
}
}
function mapStateToProps(state) {
return {
config: state.config
};
}
export default connect(mapStateToProps)(App);

View File

@ -0,0 +1,26 @@
import React from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux';
class DashboardPage extends React.Component {
render() {
const { collections } = this.props;
return <div>
<h1>Dashboard</h1>
{collections && collections.map((collection) => (
<div key={collection.get('name')}>
<Link to={`/collections/${collection.get('name')}`}>{collection.get('name')}</Link>
</div>
)).toArray()}
</div>;
}
}
function mapStateToProps(state) {
return {
collections: state.collections
};
}
export default connect(mapStateToProps)(DashboardPage);