Vulcan/packages/vulcan-base-components/lib/posts/PostsNewForm.jsx

39 lines
1.2 KiB
React
Raw Normal View History

2017-03-23 16:27:59 +09:00
import { Components, registerComponent, getRawComponent, getFragment, withMessages } from 'meteor/vulcan:core';
import Posts from "meteor/vulcan:posts";
import React, { PropTypes, Component } from 'react';
2016-06-10 10:25:38 +09:00
import { intlShape } from 'react-intl';
2016-06-14 10:01:44 +09:00
import { withRouter } from 'react-router'
2017-03-29 22:36:17 +09:00
const PostsNewForm = (props, context) =>
<Components.ShowIf
2016-12-01 16:09:54 +09:00
check={Posts.options.mutations.new.check}
2017-03-29 22:36:17 +09:00
failureComponent={<Components.AccountsLoginForm />}
2016-11-04 14:14:19 +01:00
>
<div className="posts-new-form">
<Components.SmartForm
2016-11-04 14:14:19 +01:00
collection={Posts}
mutationFragment={getFragment('PostsPage')}
2016-11-04 14:14:19 +01:00
successCallback={post => {
props.closeModal();
props.router.push({pathname: Posts.getPageUrl(post)});
2016-11-04 14:14:19 +01:00
props.flash(context.intl.formatMessage({id: "posts.created_message"}), "success");
}}
/>
</div>
</Components.ShowIf>
2016-11-05 18:37:46 +09:00
PostsNewForm.propTypes = {
closeModal: React.PropTypes.func,
2016-11-05 18:37:46 +09:00
router: React.PropTypes.object,
2016-11-07 11:46:58 +09:00
flash: React.PropTypes.func,
2016-11-05 18:37:46 +09:00
}
2016-04-14 10:12:35 +09:00
PostsNewForm.contextTypes = {
2016-11-08 14:56:48 +09:00
closeCallback: React.PropTypes.func,
2016-06-10 10:25:38 +09:00
intl: intlShape
};
PostsNewForm.displayName = "PostsNewForm";
registerComponent('PostsNewForm', PostsNewForm, withRouter, withMessages);