logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

boost_modal.js (2793B)


  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. const messages = defineMessages({
  12. reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
  13. });
  14. @injectIntl
  15. export default 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. componentDidMount() {
  26. this.button.focus();
  27. }
  28. handleReblog = () => {
  29. this.props.onReblog(this.props.status);
  30. this.props.onClose();
  31. }
  32. handleAccountClick = (e) => {
  33. if (e.button === 0) {
  34. e.preventDefault();
  35. this.props.onClose();
  36. this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
  37. }
  38. }
  39. setRef = (c) => {
  40. this.button = c;
  41. }
  42. render () {
  43. const { status, intl } = this.props;
  44. return (
  45. <div className='modal-root__modal boost-modal'>
  46. <div className='boost-modal__container'>
  47. <div className='status light'>
  48. <div className='boost-modal__status-header'>
  49. <div className='boost-modal__status-time'>
  50. <a href={status.get('url')} className='status__relative-time' target='_blank' rel='noopener'><RelativeTimestamp timestamp={status.get('created_at')} /></a>
  51. </div>
  52. <a onClick={this.handleAccountClick} href={status.getIn(['account', 'url'])} className='status__display-name'>
  53. <div className='status__avatar'>
  54. <Avatar account={status.get('account')} size={48} />
  55. </div>
  56. <DisplayName account={status.get('account')} />
  57. </a>
  58. </div>
  59. <StatusContent status={status} />
  60. </div>
  61. </div>
  62. <div className='boost-modal__action-bar'>
  63. <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>
  64. <Button text={intl.formatMessage(messages.reblog)} onClick={this.handleReblog} ref={this.setRef} />
  65. </div>
  66. </div>
  67. );
  68. }
  69. }