闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.9 KiB

  1. import React from 'react';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import PropTypes from 'prop-types';
  4. import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
  5. import IconButton from '../../../components/icon_button';
  6. import Button from '../../../components/button';
  7. import StatusContent from '../../../components/status_content';
  8. import Avatar from '../../../components/avatar';
  9. import RelativeTimestamp from '../../../components/relative_timestamp';
  10. import DisplayName from '../../../components/display_name';
  11. import ImmutablePureComponent from 'react-immutable-pure-component';
  12. const messages = defineMessages({
  13. reblog: { id: 'status.reblog', defaultMessage: 'Boost' }
  14. });
  15. class BoostModal extends ImmutablePureComponent {
  16. constructor (props, context) {
  17. super(props, context);
  18. this.handleReblog = this.handleReblog.bind(this);
  19. this.handleAccountClick = this.handleAccountClick.bind(this);
  20. }
  21. handleReblog() {
  22. this.props.onReblog(this.props.status);
  23. this.props.onClose();
  24. }
  25. handleAccountClick (e) {
  26. if (e.button === 0) {
  27. e.preventDefault();
  28. this.props.onClose();
  29. this.context.router.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
  30. }
  31. }
  32. render () {
  33. const { status, intl, onClose } = this.props;
  34. return (
  35. <div className='modal-root__modal boost-modal'>
  36. <div className='boost-modal__container'>
  37. <div className='status light'>
  38. <div className='boost-modal__status-header'>
  39. <div className='boost-modal__status-time'>
  40. <a href={status.get('url')} className='status__relative-time' target='_blank' rel='noopener'><RelativeTimestamp timestamp={status.get('created_at')} /></a>
  41. </div>
  42. <a onClick={this.handleAccountClick} href={status.getIn(['account', 'url'])} className='status__display-name'>
  43. <div className='status__avatar'>
  44. <Avatar src={status.getIn(['account', 'avatar'])} staticSrc={status.getIn(['account', 'avatar_static'])} size={48} />
  45. </div>
  46. <DisplayName account={status.get('account')} />
  47. </a>
  48. </div>
  49. <StatusContent status={status} />
  50. </div>
  51. </div>
  52. <div className='boost-modal__action-bar'>
  53. <div><FormattedMessage id='boost_modal.combo' defaultMessage='You can press {combo} to skip this next time' values={{ combo: <span>Shift + <i className='fa fa-retweet' /></span> }} /></div>
  54. <Button text={intl.formatMessage(messages.reblog)} onClick={this.handleReblog} />
  55. </div>
  56. </div>
  57. );
  58. }
  59. }
  60. BoostModal.contextTypes = {
  61. router: PropTypes.object
  62. };
  63. BoostModal.propTypes = {
  64. status: ImmutablePropTypes.map.isRequired,
  65. onReblog: PropTypes.func.isRequired,
  66. onClose: PropTypes.func.isRequired,
  67. intl: PropTypes.object.isRequired
  68. };
  69. export default injectIntl(BoostModal);