mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 04:26:41 -04:00
51 lines
No EOL
1.4 KiB
JavaScript
51 lines
No EOL
1.4 KiB
JavaScript
import { Components, registerComponent } from 'meteor/nova:lib';
|
|
import NovaForm from "meteor/nova:forms";
|
|
import { ShowIf, withMessages } from 'meteor/nova:core';
|
|
import Posts from "meteor/nova:posts";
|
|
import React, { PropTypes, Component } from 'react';
|
|
import { intlShape } from 'react-intl';
|
|
import { withRouter } from 'react-router'
|
|
|
|
const PostsNewForm = (props, context) => {
|
|
return (
|
|
<ShowIf
|
|
check={Posts.options.mutations.new.check}
|
|
failureComponent={<Components.UsersAccountForm />}
|
|
>
|
|
<div className="posts-new-form">
|
|
<NovaForm
|
|
collection={Posts}
|
|
extraFragment={`
|
|
htmlBody
|
|
postedAt
|
|
user{
|
|
_id
|
|
__displayName
|
|
__emailHash
|
|
__slug
|
|
}
|
|
`}
|
|
successCallback={post => {
|
|
props.router.push({pathname: Posts.getPageUrl(post)});
|
|
context.closeCallback();
|
|
props.flash(context.intl.formatMessage({id: "posts.created_message"}), "success");
|
|
}}
|
|
/>
|
|
</div>
|
|
</ShowIf>
|
|
);
|
|
};
|
|
|
|
PostsNewForm.propTypes = {
|
|
router: React.PropTypes.object,
|
|
flash: React.PropTypes.func,
|
|
}
|
|
|
|
PostsNewForm.contextTypes = {
|
|
closeCallback: React.PropTypes.func,
|
|
intl: intlShape
|
|
};
|
|
|
|
PostsNewForm.displayName = "PostsNewForm";
|
|
|
|
registerComponent('PostsNewForm', PostsNewForm, withRouter, withMessages); |