import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { defineMessages, injectIntl } from 'react-intl'; import Button from '../button'; import StatusContent from '../status_content'; import Avatar from '../avatar'; import RelativeTimestamp from '../relative_timestamp'; import DisplayName from '../display_name'; import Icon from '../icon'; const messages = defineMessages({ cancel_repost: { id: 'status.cancel_repost_private', defaultMessage: 'Un-repost' }, repost: { id: 'status.repost', defaultMessage: 'Repost' }, combo: { id: 'boost_modal.combo', defaultMessage: 'You can press {combo} to skip this next time' }, }); export default @injectIntl class BoostModal extends ImmutablePureComponent { static contextTypes = { router: PropTypes.object, }; static propTypes = { status: ImmutablePropTypes.map.isRequired, onRepost: PropTypes.func.isRequired, onClose: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, }; componentDidMount() { this.button.focus(); } handleRepost = () => { this.props.onRepost(this.props.status); this.props.onClose(); } handleAccountClick = (e) => { if (e.button === 0 && !(e.ctrlKey || e.metaKey)) { e.preventDefault(); this.props.onClose(); this.context.router.history.push(`/${this.props.status.getIn(['account', 'acct'])}`); } } handleStatusClick = (e) => { if (e.button === 0 && !(e.ctrlKey || e.metaKey)) { e.preventDefault(); this.props.onClose(); this.context.router.history.push(`/${this.props.status.getIn(['account', 'acct'])}/posts/${this.props.status.get('url')}`); } } setRef = (c) => { this.button = c; } render () { const { status, intl } = this.props; const buttonText = status.get('reblogged') ? messages.cancel_repost : messages.repost; const statusUrl = `/${status.getIn(['account', 'acct'])}/posts/${status.get('url')}`; return (
); } }