Load, display and edit entries from test repo and github

This commit is contained in:
Mathias Biilmann Christensen
2016-06-05 01:52:18 -07:00
parent 7601d3f5a1
commit 32e54cdbdc
16 changed files with 433 additions and 46 deletions

View File

@ -1,21 +1,38 @@
import React from 'react';
import { connect } from 'react-redux';
import { Map } from 'immutable';
import { loadEntry } from '../actions/entries';
import { selectEntry } from '../reducers/entries';
import EntryEditor from '../components/EntryEditor';
class EntryPage extends React.Component {
render() {
const { collection, entry } = this.props;
constructor(props) {
super(props);
this.props.dispatch(loadEntry(props.collection, props.slug));
}
return <EntryEditor entry={entry || new Map()} collection={collection}/>;
render() {
const { entry, collection } = this.props;
if (entry == null || entry.get('isFetching')) {
return <div>Loading...</div>;
}
return (
<EntryEditor
entry={entry || new Map()}
collection={collection}
/>
);
}
}
function mapStateToProps(state, ownProps) {
const { collections, media } = state;
const { collections } = state;
const collection = collections.get(ownProps.params.name);
const slug = ownProps.params.slug;
const entry = selectEntry(state, collection.get('name'), slug);
return {media, collection, collections};
return {collection, collections, slug, entry};
}
export default connect(mapStateToProps)(EntryPage);