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

31 lines
1 KiB
React
Raw Normal View History

2016-08-08 11:18:21 +09:00
import Telescope from 'meteor/nova:lib';
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';
2016-05-22 15:23:30 +09:00
import { ModalTrigger } from "meteor/nova:core";
2016-11-07 17:45:17 +09:00
import Posts from "meteor/nova:posts";
2016-11-15 18:33:16 +01:00
import { withCurrentUser } from 'meteor/nova:core';
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 (
2016-06-09 17:42:20 +09:00
<ModalTrigger size={size} title={context.intl.formatMessage({id: "posts.new_post"})} component={button}>
2016-11-07 17:45:17 +09:00
<Telescope.components.PostsNewForm />
2016-03-25 10:45:28 +09:00
</ModalTrigger>
)
}
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
Telescope.registerComponent('PostsNewButton', PostsNewButton, withCurrentUser);