thanks.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import ImmutablePropTypes from 'react-immutable-proptypes';
  4. import { FormattedMessage } from 'react-intl';
  5. import Button from 'mastodon/components/button';
  6. import { connect } from 'react-redux';
  7. import {
  8. unfollowAccount,
  9. muteAccount,
  10. blockAccount,
  11. } from 'mastodon/actions/accounts';
  12. const mapStateToProps = () => ({});
  13. export default @connect(mapStateToProps)
  14. class Thanks extends React.PureComponent {
  15. static propTypes = {
  16. submitted: PropTypes.bool,
  17. onClose: PropTypes.func.isRequired,
  18. account: ImmutablePropTypes.map.isRequired,
  19. dispatch: PropTypes.func.isRequired,
  20. };
  21. handleCloseClick = () => {
  22. const { onClose } = this.props;
  23. onClose();
  24. };
  25. handleUnfollowClick = () => {
  26. const { dispatch, account, onClose } = this.props;
  27. dispatch(unfollowAccount(account.get('id')));
  28. onClose();
  29. };
  30. handleMuteClick = () => {
  31. const { dispatch, account, onClose } = this.props;
  32. dispatch(muteAccount(account.get('id')));
  33. onClose();
  34. };
  35. handleBlockClick = () => {
  36. const { dispatch, account, onClose } = this.props;
  37. dispatch(blockAccount(account.get('id')));
  38. onClose();
  39. };
  40. render () {
  41. const { account, submitted } = this.props;
  42. return (
  43. <React.Fragment>
  44. <h3 className='report-dialog-modal__title'>{submitted ? <FormattedMessage id='report.thanks.title_actionable' defaultMessage="Thanks for reporting, we'll look into this." /> : <FormattedMessage id='report.thanks.title' defaultMessage="Don't want to see this?" />}</h3>
  45. <p className='report-dialog-modal__lead'>{submitted ? <FormattedMessage id='report.thanks.take_action_actionable' defaultMessage='While we review this, you can take action against @{name}:' values={{ name: account.get('username') }} /> : <FormattedMessage id='report.thanks.take_action' defaultMessage='Here are your options for controlling what you see on Mastodon:' />}</p>
  46. {account.getIn(['relationship', 'following']) && (
  47. <React.Fragment>
  48. <h4 className='report-dialog-modal__subtitle'><FormattedMessage id='report.unfollow' defaultMessage='Unfollow @{name}' values={{ name: account.get('username') }} /></h4>
  49. <p className='report-dialog-modal__lead'><FormattedMessage id='report.unfollow_explanation' defaultMessage='You are following this account. To not see their posts in your home feed anymore, unfollow them.' /></p>
  50. <Button secondary onClick={this.handleUnfollowClick}><FormattedMessage id='account.unfollow' defaultMessage='Unfollow' /></Button>
  51. <hr />
  52. </React.Fragment>
  53. )}
  54. <h4 className='report-dialog-modal__subtitle'><FormattedMessage id='account.mute' defaultMessage='Mute @{name}' values={{ name: account.get('username') }} /></h4>
  55. <p className='report-dialog-modal__lead'><FormattedMessage id='report.mute_explanation' defaultMessage='You will not see their posts. They can still follow you and see your posts and will not know that they are muted.' /></p>
  56. <Button secondary onClick={this.handleMuteClick}>{!account.getIn(['relationship', 'muting']) ? <FormattedMessage id='report.mute' defaultMessage='Mute' /> : <FormattedMessage id='account.muted' defaultMessage='Muted' />}</Button>
  57. <hr />
  58. <h4 className='report-dialog-modal__subtitle'><FormattedMessage id='account.block' defaultMessage='Block @{name}' values={{ name: account.get('username') }} /></h4>
  59. <p className='report-dialog-modal__lead'><FormattedMessage id='report.block_explanation' defaultMessage='You will not see their posts. They will not be able to see your posts or follow you. They will be able to tell that they are blocked.' /></p>
  60. <Button secondary onClick={this.handleBlockClick}>{!account.getIn(['relationship', 'blocking']) ? <FormattedMessage id='report.block' defaultMessage='Block' /> : <FormattedMessage id='account.blocked' defaultMessage='Blocked' />}</Button>
  61. <div className='flex-spacer' />
  62. <div className='report-dialog-modal__actions'>
  63. <Button onClick={this.handleCloseClick}><FormattedMessage id='report.close' defaultMessage='Done' /></Button>
  64. </div>
  65. </React.Fragment>
  66. );
  67. }
  68. }