The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

86 lines
2.8 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 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. import ImmutablePureComponent from 'react-immutable-pure-component';
  11. import Icon from 'mastodon/components/icon';
  12. const messages = defineMessages({
  13. reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
  14. });
  15. export default @injectIntl
  16. class BoostModal extends ImmutablePureComponent {
  17. static contextTypes = {
  18. router: PropTypes.object,
  19. };
  20. static propTypes = {
  21. status: ImmutablePropTypes.map.isRequired,
  22. onReblog: PropTypes.func.isRequired,
  23. onClose: PropTypes.func.isRequired,
  24. intl: PropTypes.object.isRequired,
  25. };
  26. componentDidMount() {
  27. this.button.focus();
  28. }
  29. handleReblog = () => {
  30. this.props.onReblog(this.props.status);
  31. this.props.onClose();
  32. }
  33. handleAccountClick = (e) => {
  34. if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
  35. e.preventDefault();
  36. this.props.onClose();
  37. this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
  38. }
  39. }
  40. setRef = (c) => {
  41. this.button = c;
  42. }
  43. render () {
  44. const { status, intl } = this.props;
  45. return (
  46. <div className='modal-root__modal boost-modal'>
  47. <div className='boost-modal__container'>
  48. <div className='status light'>
  49. <div className='boost-modal__status-header'>
  50. <div className='boost-modal__status-time'>
  51. <a href={status.get('url')} className='status__relative-time' target='_blank' rel='noopener'><RelativeTimestamp timestamp={status.get('created_at')} /></a>
  52. </div>
  53. <a onClick={this.handleAccountClick} href={status.getIn(['account', 'url'])} className='status__display-name'>
  54. <div className='status__avatar'>
  55. <Avatar account={status.get('account')} size={48} />
  56. </div>
  57. <DisplayName account={status.get('account')} />
  58. </a>
  59. </div>
  60. <StatusContent status={status} />
  61. </div>
  62. </div>
  63. <div className='boost-modal__action-bar'>
  64. <div><FormattedMessage id='boost_modal.combo' defaultMessage='You can press {combo} to skip this next time' values={{ combo: <span>Shift + <Icon id='retweet' /></span> }} /></div>
  65. <Button text={intl.formatMessage(messages.reblog)} onClick={this.handleReblog} ref={this.setRef} />
  66. </div>
  67. </div>
  68. );
  69. }
  70. }