2016-03-25 10:45:28 +09:00
|
|
|
import React, { PropTypes, Component } from 'react';
|
|
|
|
import { Button } from 'react-bootstrap';
|
|
|
|
|
2016-03-27 13:04:21 +09:00
|
|
|
import Core from "meteor/nova:core";
|
|
|
|
const Messages = Core.Messages;
|
|
|
|
|
|
|
|
import ReactForms from "meteor/utilities:react-form-containers";
|
|
|
|
const NewDocument = ReactForms.NewDocument;
|
|
|
|
|
2016-03-25 10:45:28 +09:00
|
|
|
const NewPostButton = (props, context) => {
|
|
|
|
|
2016-03-27 13:04:21 +09:00
|
|
|
({ModalTrigger, CanCreatePost} = Telescope.components);
|
2016-03-25 10:45:28 +09:00
|
|
|
|
|
|
|
return (
|
|
|
|
<ModalTrigger component={<Button bsStyle="primary">New Post</Button>}>
|
|
|
|
<CanCreatePost user={context.currentUser}>
|
2016-03-27 18:17:20 +09:00
|
|
|
<div className="new-post-form">
|
|
|
|
<h3 className="modal-form-title">New Post</h3>
|
|
|
|
<NewDocument
|
|
|
|
collection={Posts}
|
|
|
|
currentUser={context.currentUser}
|
|
|
|
methodName="posts.new"
|
|
|
|
successCallback={(post)=>{
|
|
|
|
Messages.flash("Post created.", "success");
|
|
|
|
Router.go('posts.single', post);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
2016-03-25 10:45:28 +09:00
|
|
|
</CanCreatePost>
|
|
|
|
</ModalTrigger>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
NewPostButton.contextTypes = {
|
|
|
|
currentUser: React.PropTypes.object
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = NewPostButton;
|
|
|
|
export default NewPostButton;
|