The code powering m.abunchtell.com https://m.abunchtell.com
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

109 строки
3.3 KiB

  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import PropTypes from 'prop-types';
  4. import { injectIntl, FormattedMessage } from 'react-intl';
  5. import Toggle from 'react-toggle';
  6. import Button from '../../../components/button';
  7. import { closeModal } from '../../../actions/modal';
  8. import { muteAccount } from '../../../actions/accounts';
  9. import { toggleHideNotifications } from '../../../actions/mutes';
  10. const mapStateToProps = state => {
  11. return {
  12. account: state.getIn(['mutes', 'new', 'account']),
  13. notifications: state.getIn(['mutes', 'new', 'notifications']),
  14. };
  15. };
  16. const mapDispatchToProps = dispatch => {
  17. return {
  18. onConfirm(account, notifications) {
  19. dispatch(muteAccount(account.get('id'), notifications));
  20. },
  21. onClose() {
  22. dispatch(closeModal());
  23. },
  24. onToggleNotifications() {
  25. dispatch(toggleHideNotifications());
  26. },
  27. };
  28. };
  29. export default @connect(mapStateToProps, mapDispatchToProps)
  30. @injectIntl
  31. class MuteModal extends React.PureComponent {
  32. static propTypes = {
  33. account: PropTypes.object.isRequired,
  34. notifications: PropTypes.bool.isRequired,
  35. onClose: PropTypes.func.isRequired,
  36. onConfirm: PropTypes.func.isRequired,
  37. onToggleNotifications: PropTypes.func.isRequired,
  38. intl: PropTypes.object.isRequired,
  39. };
  40. componentDidMount() {
  41. this.button.focus();
  42. }
  43. handleClick = () => {
  44. this.props.onClose();
  45. this.props.onConfirm(this.props.account, this.props.notifications);
  46. }
  47. handleCancel = () => {
  48. this.props.onClose();
  49. }
  50. setRef = (c) => {
  51. this.button = c;
  52. }
  53. toggleNotifications = () => {
  54. this.props.onToggleNotifications();
  55. }
  56. render () {
  57. const { account, notifications } = this.props;
  58. return (
  59. <div className='modal-root__modal mute-modal'>
  60. <div className='mute-modal__container'>
  61. <p>
  62. <FormattedMessage
  63. id='confirmations.mute.message'
  64. defaultMessage='Are you sure you want to mute {name}?'
  65. values={{ name: <strong>@{account.get('acct')}</strong> }}
  66. />
  67. </p>
  68. <p className='mute-modal__explanation'>
  69. <FormattedMessage
  70. id='confirmations.mute.explanation'
  71. defaultMessage='This will hide posts from them and posts mentioning them, but it will still allow them to see your posts follow you.'
  72. />
  73. </p>
  74. <div className='setting-toggle'>
  75. <Toggle id='mute-modal__hide-notifications-checkbox' checked={notifications} onChange={this.toggleNotifications} />
  76. <label className='setting-toggle__label' htmlFor='mute-modal__hide-notifications-checkbox'>
  77. <FormattedMessage id='mute_modal.hide_notifications' defaultMessage='Hide notifications from this user?' />
  78. </label>
  79. </div>
  80. </div>
  81. <div className='mute-modal__action-bar'>
  82. <Button onClick={this.handleCancel} className='mute-modal__cancel-button'>
  83. <FormattedMessage id='confirmation_modal.cancel' defaultMessage='Cancel' />
  84. </Button>
  85. <Button onClick={this.handleClick} ref={this.setRef}>
  86. <FormattedMessage id='confirmations.mute.confirm' defaultMessage='Mute' />
  87. </Button>
  88. </div>
  89. </div>
  90. );
  91. }
  92. }