mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
get rid of PostNewContainer and PostEditContainer
This commit is contained in:
parent
13df8f5df7
commit
50b0c57de3
7 changed files with 73 additions and 49 deletions
|
@ -3,7 +3,7 @@ import NoSSR from 'react-no-ssr';
|
|||
|
||||
const Header = props => {
|
||||
|
||||
({Logo, ListContainer, CategoriesList, FlashContainer, NewPostButton, ModalButton, PostNewContainer} = Telescope.components);
|
||||
({Logo, ListContainer, CategoriesList, FlashContainer, NewPostButton, ModalButton, PostNewContainer, CurrentUserContainer, PostNew} = Telescope.components);
|
||||
|
||||
const logoUrl = Telescope.settings.get("logoUrl");
|
||||
const siteTitle = Telescope.settings.get("title", "Telescope");
|
||||
|
@ -25,7 +25,7 @@ const Header = props => {
|
|||
|
||||
{props.currentUser ? <p><a href={FlowRouter.path("account")}>My Account</a></p> : ""}
|
||||
|
||||
<ModalButton label="New Post" className="button button--primary"><PostNewContainer/></ModalButton>
|
||||
<ModalButton label="New Post" className="button button--primary"><CurrentUserContainer><PostNew /></CurrentUserContainer></ModalButton>
|
||||
|
||||
<FlashContainer />
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ FlowRouter.route('/', {
|
|||
FlowRouter.route('/posts/new', {
|
||||
name: 'posts.new',
|
||||
action(params, queryParams) {
|
||||
({AppContainer, PostNewContainer} = Telescope.components);
|
||||
mount(AppContainer, {content: <PostNewContainer />});
|
||||
({AppContainer, CurrentUserContainer, PostNew} = Telescope.components);
|
||||
mount(AppContainer, {content: <CurrentUserContainer><PostNew /></CurrentUserContainer>});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -50,8 +50,13 @@ FlowRouter.route('/posts/:_id', {
|
|||
FlowRouter.route('/posts/:_id/edit', {
|
||||
name: 'posts.edit',
|
||||
action(params, queryParams) {
|
||||
({AppContainer, PostEditContainer} = Telescope.components);
|
||||
mount(AppContainer, {content: <PostEditContainer postId={params._id}/>});
|
||||
({AppContainer, ItemContainer} = Telescope.components);
|
||||
mount(AppContainer, {content: <ItemContainer
|
||||
collection={Posts}
|
||||
publication="posts.single"
|
||||
terms={{_id: params._id}}
|
||||
component={PostEdit}
|
||||
/>});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -2,5 +2,6 @@ Telescope.registerComponent("AppContainer", require('./containers/AppContainer.j
|
|||
Telescope.registerComponent("ItemContainer", require('./containers/ItemContainer.jsx'));
|
||||
Telescope.registerComponent("ListContainer", require('./containers/ListContainer.jsx'));
|
||||
Telescope.registerComponent("FlashContainer", require('./containers/FlashContainer.jsx'));
|
||||
Telescope.registerComponent("CurrentUserContainer", require('./containers/CurrentUserContainer.jsx'));
|
||||
|
||||
Telescope.registerComponent("ModalButton", require('./components/ModalButton.jsx'));
|
18
packages/nova-core/lib/containers/CurrentUserContainer.jsx
Normal file
18
packages/nova-core/lib/containers/CurrentUserContainer.jsx
Normal file
|
@ -0,0 +1,18 @@
|
|||
const CurrentUserContainer = React.createClass({
|
||||
|
||||
mixins: [ReactMeteorData],
|
||||
|
||||
getMeteorData() {
|
||||
|
||||
return {
|
||||
currentUser: Meteor.user()
|
||||
};
|
||||
},
|
||||
|
||||
render() {
|
||||
return React.cloneElement(this.props.children, { currentUser: this.data.currentUser });
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = CurrentUserContainer;
|
|
@ -1,2 +1,2 @@
|
|||
Telescope.registerComponent("PostNewContainer", require('./containers/PostNewContainer.jsx'));
|
||||
Telescope.registerComponent("PostEditContainer", require('./containers/PostEditContainer.jsx'));
|
||||
// Telescope.registerComponent("PostNewContainer", require('./containers/PostNewContainer.jsx'));
|
||||
// Telescope.registerComponent("PostEditContainer", require('./containers/PostEditContainer.jsx'));
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
// import React from 'react';
|
||||
// // not used anymore
|
||||
|
||||
const PostEditContainer = React.createClass({
|
||||
// const PostEditContainer = React.createClass({
|
||||
|
||||
propTypes: {
|
||||
postId: React.PropTypes.string.isRequired
|
||||
},
|
||||
// propTypes: {
|
||||
// postId: React.PropTypes.string.isRequired
|
||||
// },
|
||||
|
||||
mixins: [ReactMeteorData],
|
||||
// mixins: [ReactMeteorData],
|
||||
|
||||
getMeteorData() {
|
||||
return {
|
||||
categories: Categories.find().fetch(),
|
||||
// postUrl: Session.get("postUrl"),
|
||||
};
|
||||
},
|
||||
// getMeteorData() {
|
||||
// return {
|
||||
// categories: Categories.find().fetch(),
|
||||
// // postUrl: Session.get("postUrl"),
|
||||
// };
|
||||
// },
|
||||
|
||||
render() {
|
||||
({ItemContainer, PostEdit} = Telescope.components);
|
||||
// render() {
|
||||
// ({ItemContainer, PostEdit} = Telescope.components);
|
||||
|
||||
return (
|
||||
<ItemContainer
|
||||
propsToPass={this.data}
|
||||
collection={Posts}
|
||||
publication="posts.single"
|
||||
terms={{_id: this.props.postId}}
|
||||
component={PostEdit}
|
||||
/>
|
||||
)
|
||||
}
|
||||
// return (
|
||||
// <ItemContainer
|
||||
// propsToPass={this.data}
|
||||
// collection={Posts}
|
||||
// publication="posts.single"
|
||||
// terms={{_id: this.props.postId}}
|
||||
// component={PostEdit}
|
||||
// />
|
||||
// )
|
||||
// }
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
module.exports = PostEditContainer;
|
||||
// module.exports = PostEditContainer;
|
|
@ -1,22 +1,22 @@
|
|||
// import React from 'react';
|
||||
// // not used anymore
|
||||
|
||||
const PostNewContainer = React.createClass({
|
||||
// const PostNewContainer = React.createClass({
|
||||
|
||||
mixins: [ReactMeteorData],
|
||||
// mixins: [ReactMeteorData],
|
||||
|
||||
getMeteorData() {
|
||||
// getMeteorData() {
|
||||
|
||||
return {
|
||||
// postUrl: Session.get("postUrl"), // replace with state?
|
||||
currentUser: Meteor.user()
|
||||
};
|
||||
},
|
||||
// return {
|
||||
// // postUrl: Session.get("postUrl"), // replace with state?
|
||||
// currentUser: Meteor.user()
|
||||
// };
|
||||
// },
|
||||
|
||||
render() {
|
||||
({PostNew} = Telescope.components);
|
||||
return <PostNew {...this.props} {...this.data} />;
|
||||
}
|
||||
// render() {
|
||||
// ({PostNew} = Telescope.components);
|
||||
// return <PostNew {...this.props} {...this.data} />;
|
||||
// }
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
module.exports = PostNewContainer;
|
||||
// module.exports = PostNewContainer;
|
Loading…
Add table
Reference in a new issue