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.

82 lines
3.0 KiB

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