2017-03-23 16:27:59 +09:00
|
|
|
import { Components, registerComponent, withCurrentUser } from 'meteor/vulcan:core';
|
2017-05-19 14:42:43 -06:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-06-01 11:42:30 +09:00
|
|
|
import { FormattedMessage, intlShape } from 'meteor/vulcan:i18n';
|
2016-03-25 10:45:28 +09:00
|
|
|
import { Button } from 'react-bootstrap';
|
2016-03-27 13:04:21 +09:00
|
|
|
|
2016-04-14 14:12:06 +09:00
|
|
|
const PostsNewButton = (props, context) => {
|
2016-03-25 10:45:28 +09:00
|
|
|
|
2017-05-19 14:42:43 -06:00
|
|
|
const size = props.currentUser ? 'large' : 'small';
|
2017-05-16 11:04:43 +09:00
|
|
|
const button = <Button className="posts-new-button" bsStyle="primary"><Components.Icon name="new"/> <FormattedMessage id="posts.new_post"/></Button>;
|
2016-03-25 10:45:28 +09:00
|
|
|
return (
|
2017-05-19 14:42:43 -06:00
|
|
|
<Components.ModalTrigger size={size} title={context.intl.formatMessage({ id: 'posts.new_post' })} component={button}>
|
2016-12-06 18:06:29 +01:00
|
|
|
<Components.PostsNewForm />
|
2017-01-30 19:46:48 +09:00
|
|
|
</Components.ModalTrigger>
|
2016-03-25 10:45:28 +09:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2017-05-19 14:42:43 -06:00
|
|
|
PostsNewButton.displayName = 'PostsNewButton';
|
2016-05-22 16:42:24 +09:00
|
|
|
|
2016-11-15 18:33:16 +01:00
|
|
|
PostsNewButton.propTypes = {
|
2017-05-19 14:42:43 -06:00
|
|
|
currentUser: PropTypes.object,
|
2016-11-15 18:33:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
PostsNewButton.contextTypes = {
|
2017-05-19 14:42:43 -06:00
|
|
|
messages: PropTypes.object,
|
2016-06-09 17:42:20 +09:00
|
|
|
intl: intlShape
|
2016-11-15 18:33:16 +01:00
|
|
|
};
|
2016-06-09 17:42:20 +09:00
|
|
|
|
2017-02-02 16:18:33 +01:00
|
|
|
registerComponent('PostsNewButton', PostsNewButton, withCurrentUser);
|