Vulcan/packages/example-forum/lib/components/posts/PostsNewButton.jsx
2017-09-04 18:37:21 +09:00

29 lines
989 B
JavaScript

import { Components, registerComponent, withCurrentUser } from 'meteor/vulcan:core';
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage, intlShape } from 'meteor/vulcan:i18n';
import Button from 'react-bootstrap/lib/Button';
const PostsNewButton = (props, context) => {
const size = props.currentUser ? 'large' : 'small';
const button = <Button className="posts-new-button" bsStyle="primary"><Components.Icon name="new"/> <FormattedMessage id="posts.new_post"/></Button>;
return (
<Components.ModalTrigger size={size} title={context.intl.formatMessage({ id: 'posts.new_post' })} component={button}>
<Components.PostsNewForm />
</Components.ModalTrigger>
)
}
PostsNewButton.displayName = 'PostsNewButton';
PostsNewButton.propTypes = {
currentUser: PropTypes.object,
};
PostsNewButton.contextTypes = {
messages: PropTypes.object,
intl: intlShape
};
registerComponent('PostsNewButton', PostsNewButton, withCurrentUser);