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 { withRouter } from 'react-router' import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; class PostsEditForm extends Component { renderAdminArea() { return (
ID: {this.props.post._id}
) } render() { return (
{this.renderAdminArea()} { this.context.closeCallback(); this.props.flash(this.context.intl.formatMessage({id: "posts.edit_success"}, {title: post.title}), 'success'); }} removeSuccessCallback={({documentId, documentTitle}) => { if (typeof this.context.closeCallback === "function") { this.context.closeCallback(); } else { // post edit form is being included from a single post, redirect to index this.props.router.push('/'); } const deleteDocumentSuccess = this.context.intl.formatMessage({id: 'posts.delete_success'}, {title: documentTitle}); this.props.flash(deleteDocumentSuccess, "success"); this.context.events.track("post deleted", {_id: documentId}); }} />
); } } PostsEditForm.propTypes = { flash: React.PropTypes.func, post: React.PropTypes.object.isRequired, } PostsEditForm.contextTypes = { actions: React.PropTypes.object, events: React.PropTypes.object, closeCallback: React.PropTypes.func, intl: intlShape } const mapStateToProps = state => ({ messages: state.messages }); const mapDispatchToProps = dispatch => bindActionCreators(Telescope.actions.messages, dispatch); Telescope.registerComponent('PostsEditForm', PostsEditForm, connect(mapStateToProps, mapDispatchToProps), withRouter);