Initial commit
This commit is contained in:
58
src/containers/App.js
Normal file
58
src/containers/App.js
Normal 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);
|
26
src/containers/DashboardPage.js
Normal file
26
src/containers/DashboardPage.js
Normal 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);
|
Reference in New Issue
Block a user