import Telescope from 'meteor/nova:lib'; import React, { PropTypes, Component } from 'react'; import { FormattedMessage, intlShape } from 'react-intl'; import NovaForm from "meteor/nova:forms"; import Posts from "meteor/nova:posts"; import Users from 'meteor/nova:users'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; class PostsEditForm extends Component{ constructor() { super(); this.deletePost = this.deletePost.bind(this); } deletePost() { const post = this.props.post; const deletePostConfirm = this.context.intl.formatMessage({id: "posts.delete_confirm"}, {title: post.title}); const deletePostSuccess = this.context.intl.formatMessage({id: "posts.delete_success"}, {title: post.title}); if (window.confirm(deletePostConfirm)) { this.context.actions.call('posts.remove', post._id, (error, result) => { this.props.flash(deletePostSuccess, "success"); this.context.events.track("post deleted", {'_id': post._id}); }); } } renderAdminArea() { return (
ID: {this.props.post._id}
) } render() { return (
{this.renderAdminArea()} { this.props.flash(this.context.intl.formatMessage({id: "posts.edit_success"}, {title: post.title}), 'success'); } }} />
) } } PostsEditForm.propTypes = { post: React.PropTypes.object.isRequired } PostsEditForm.contextTypes = { currentUser: React.PropTypes.object, actions: React.PropTypes.object, events: React.PropTypes.object, intl: intlShape } const mapStateToProps = state => ({ messages: state.messages, }); const mapDispatchToProps = dispatch => bindActionCreators(Telescope.actions.messages, dispatch); module.exports = connect(mapStateToProps, mapDispatchToProps)(PostsEditForm); export default connect(mapStateToProps, mapDispatchToProps)(PostsEditForm);