Vulcan/packages/vulcan-base-components/lib/posts/PostsNewButton.jsx

29 lines
944 B
React
Raw Normal View History

2017-03-23 16:27:59 +09:00
import { Components, registerComponent, withCurrentUser } from 'meteor/vulcan:core';
2016-03-25 10:45:28 +09:00
import React, { PropTypes, Component } from 'react';
2016-06-10 10:25:38 +09:00
import { FormattedMessage, intlShape } from 'react-intl';
2016-03-25 10:45:28 +09:00
import { Button } from 'react-bootstrap';
const PostsNewButton = (props, context) => {
2016-03-25 10:45:28 +09:00
2016-11-15 18:33:16 +01:00
const size = props.currentUser ? "large" : "small";
2016-06-09 17:42:20 +09:00
const button = <Button className="posts-new-button" bsStyle="primary"><FormattedMessage id="posts.new_post"/></Button>;
2016-03-25 10:45:28 +09:00
return (
<Components.ModalTrigger size={size} title={context.intl.formatMessage({id: "posts.new_post"})} component={button}>
<Components.PostsNewForm />
</Components.ModalTrigger>
2016-03-25 10:45:28 +09:00
)
}
PostsNewButton.displayName = "PostsNewButton";
2016-11-15 18:33:16 +01:00
PostsNewButton.propTypes = {
2016-06-10 10:25:38 +09:00
currentUser: React.PropTypes.object,
2016-11-15 18:33:16 +01:00
};
PostsNewButton.contextTypes = {
messages: React.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
registerComponent('PostsNewButton', PostsNewButton, withCurrentUser);