Add 'block user' option to the report window

This commit is contained in:
Bárbara de Castro Fernandes 2020-05-29 15:05:24 -03:00
parent 30384cbfef
commit 775f923708
5 changed files with 44 additions and 3 deletions

View file

@ -11,6 +11,7 @@ export const REPORT_SUBMIT_FAIL = 'REPORT_SUBMIT_FAIL';
export const REPORT_STATUS_TOGGLE = 'REPORT_STATUS_TOGGLE'; export const REPORT_STATUS_TOGGLE = 'REPORT_STATUS_TOGGLE';
export const REPORT_COMMENT_CHANGE = 'REPORT_COMMENT_CHANGE'; export const REPORT_COMMENT_CHANGE = 'REPORT_COMMENT_CHANGE';
export const REPORT_FORWARD_CHANGE = 'REPORT_FORWARD_CHANGE'; export const REPORT_FORWARD_CHANGE = 'REPORT_FORWARD_CHANGE';
export const REPORT_BLOCK_CHANGE = 'REPORT_BLOCK_CHANGE';
export function initReport(account, status) { export function initReport(account, status) {
return dispatch => { return dispatch => {
@ -87,3 +88,10 @@ export function changeReportForward(forward) {
forward, forward,
}; };
}; };
export function changeReportBlock(block) {
return {
type: REPORT_BLOCK_CHANGE,
block,
};
};

View file

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { changeReportComment, changeReportForward, submitReport } from '../../../actions/reports'; import { changeReportComment, changeReportForward, changeReportBlock, submitReport } from '../../../actions/reports';
import { blockAccount } from '../../../actions/accounts';
import { expandAccountTimeline } from '../../../actions/timelines'; import { expandAccountTimeline } from '../../../actions/timelines';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePropTypes from 'react-immutable-proptypes';
@ -30,6 +31,7 @@ const makeMapStateToProps = () => {
account: getAccount(state, accountId), account: getAccount(state, accountId),
comment: state.getIn(['reports', 'new', 'comment']), comment: state.getIn(['reports', 'new', 'comment']),
forward: state.getIn(['reports', 'new', 'forward']), forward: state.getIn(['reports', 'new', 'forward']),
block: state.getIn(['reports', 'new', 'block']),
statusIds: OrderedSet(state.getIn(['timelines', `account:${accountId}:with_replies`, 'items'])).union(state.getIn(['reports', 'new', 'status_ids'])), statusIds: OrderedSet(state.getIn(['timelines', `account:${accountId}:with_replies`, 'items'])).union(state.getIn(['reports', 'new', 'status_ids'])),
}; };
}; };
@ -47,6 +49,7 @@ class ReportModal extends ImmutablePureComponent {
statusIds: ImmutablePropTypes.orderedSet.isRequired, statusIds: ImmutablePropTypes.orderedSet.isRequired,
comment: PropTypes.string.isRequired, comment: PropTypes.string.isRequired,
forward: PropTypes.bool, forward: PropTypes.bool,
block: PropTypes.bool,
dispatch: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
}; };
@ -59,8 +62,15 @@ class ReportModal extends ImmutablePureComponent {
this.props.dispatch(changeReportForward(e.target.checked)); this.props.dispatch(changeReportForward(e.target.checked));
} }
handleBlockChange = e => {
this.props.dispatch(changeReportBlock(e.target.checked));
}
handleSubmit = () => { handleSubmit = () => {
this.props.dispatch(submitReport()); this.props.dispatch(submitReport());
if (this.props.block) {
this.props.dispatch(blockAccount(this.props.account.get('id')));
}
} }
handleKeyDown = e => { handleKeyDown = e => {
@ -80,7 +90,7 @@ class ReportModal extends ImmutablePureComponent {
} }
render() { render() {
const { account, comment, intl, statusIds, isSubmitting, forward, onClose } = this.props; const { account, comment, intl, statusIds, isSubmitting, forward, block, onClose } = this.props;
if (!account) { if (!account) {
return null; return null;
@ -120,6 +130,15 @@ class ReportModal extends ImmutablePureComponent {
</div> </div>
)} )}
<div>
<p><FormattedMessage id='report.block_hint' defaultMessage='Do you also want to block this account?' /></p>
<div className='setting-toggle'>
<Toggle id='report-block' checked={block} disabled={isSubmitting} onChange={this.handleBlockChange} />
<label htmlFor='report-block' className='setting-toggle__label'><FormattedMessage id='report.block' defaultMessage='Block {target}' values={{ target: account.get('acct') }} /></label>
</div>
</div>
<Button disabled={isSubmitting} text={intl.formatMessage(messages.submit)} onClick={this.handleSubmit} /> <Button disabled={isSubmitting} text={intl.formatMessage(messages.submit)} onClick={this.handleSubmit} />
</div> </div>

View file

@ -2700,6 +2700,14 @@
{ {
"defaultMessage": "Forward to {target}", "defaultMessage": "Forward to {target}",
"id": "report.forward" "id": "report.forward"
},
{
"defaultMessage": "Do you also want to block this account?",
"id": "report.block_hint"
},
{
"defaultMessage": "Block {target}",
"id": "report.block"
} }
], ],
"path": "app/soapbox/features/ui/components/report_modal.json" "path": "app/soapbox/features/ui/components/report_modal.json"
@ -2894,4 +2902,4 @@
], ],
"path": "app/soapbox/features/video/index.json" "path": "app/soapbox/features/video/index.json"
} }
] ]

View file

@ -325,6 +325,8 @@
"relative_time.minutes": "{number}m", "relative_time.minutes": "{number}m",
"relative_time.seconds": "{number}s", "relative_time.seconds": "{number}s",
"reply_indicator.cancel": "Cancel", "reply_indicator.cancel": "Cancel",
"report.block": "Block {target}",
"report.block_hint": "Do you also want to block this account?",
"report.forward": "Forward to {target}", "report.forward": "Forward to {target}",
"report.forward_hint": "The account is from another server. Send an anonymized copy of the report there as well?", "report.forward_hint": "The account is from another server. Send an anonymized copy of the report there as well?",
"report.hint": "The report will be sent to your server moderators. You can provide an explanation of why you are reporting this account below:", "report.hint": "The report will be sent to your server moderators. You can provide an explanation of why you are reporting this account below:",

View file

@ -7,6 +7,7 @@ import {
REPORT_STATUS_TOGGLE, REPORT_STATUS_TOGGLE,
REPORT_COMMENT_CHANGE, REPORT_COMMENT_CHANGE,
REPORT_FORWARD_CHANGE, REPORT_FORWARD_CHANGE,
REPORT_BLOCK_CHANGE,
} from '../actions/reports'; } from '../actions/reports';
import { Map as ImmutableMap, Set as ImmutableSet } from 'immutable'; import { Map as ImmutableMap, Set as ImmutableSet } from 'immutable';
@ -17,6 +18,7 @@ const initialState = ImmutableMap({
status_ids: ImmutableSet(), status_ids: ImmutableSet(),
comment: '', comment: '',
forward: false, forward: false,
block: false,
}), }),
}); });
@ -46,6 +48,8 @@ export default function reports(state = initialState, action) {
return state.setIn(['new', 'comment'], action.comment); return state.setIn(['new', 'comment'], action.comment);
case REPORT_FORWARD_CHANGE: case REPORT_FORWARD_CHANGE:
return state.setIn(['new', 'forward'], action.forward); return state.setIn(['new', 'forward'], action.forward);
case REPORT_BLOCK_CHANGE:
return state.setIn(['new', 'block'], action.block);
case REPORT_SUBMIT_REQUEST: case REPORT_SUBMIT_REQUEST:
return state.setIn(['new', 'isSubmitting'], true); return state.setIn(['new', 'isSubmitting'], true);
case REPORT_SUBMIT_FAIL: case REPORT_SUBMIT_FAIL: