闭社主体 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.

78 lines
2.7 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. static contextTypes = {
  17. router: PropTypes.object,
  18. };
  19. static propTypes = {
  20. status: ImmutablePropTypes.map.isRequired,
  21. onReblog: PropTypes.func.isRequired,
  22. onClose: PropTypes.func.isRequired,
  23. intl: PropTypes.object.isRequired,
  24. };
  25. handleReblog = () => {
  26. this.props.onReblog(this.props.status);
  27. this.props.onClose();
  28. }
  29. handleAccountClick = (e) => {
  30. if (e.button === 0) {
  31. e.preventDefault();
  32. this.props.onClose();
  33. this.context.router.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
  34. }
  35. }
  36. render () {
  37. const { status, intl, onClose } = this.props;
  38. return (
  39. <div className='modal-root__modal boost-modal'>
  40. <div className='boost-modal__container'>
  41. <div className='status light'>
  42. <div className='boost-modal__status-header'>
  43. <div className='boost-modal__status-time'>
  44. <a href={status.get('url')} className='status__relative-time' target='_blank' rel='noopener'><RelativeTimestamp timestamp={status.get('created_at')} /></a>
  45. </div>
  46. <a onClick={this.handleAccountClick} href={status.getIn(['account', 'url'])} className='status__display-name'>
  47. <div className='status__avatar'>
  48. <Avatar src={status.getIn(['account', 'avatar'])} staticSrc={status.getIn(['account', 'avatar_static'])} size={48} />
  49. </div>
  50. <DisplayName account={status.get('account')} />
  51. </a>
  52. </div>
  53. <StatusContent status={status} />
  54. </div>
  55. </div>
  56. <div className='boost-modal__action-bar'>
  57. <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>
  58. <Button text={intl.formatMessage(messages.reblog)} onClick={this.handleReblog} />
  59. </div>
  60. </div>
  61. );
  62. }
  63. }
  64. export default injectIntl(BoostModal);