From 775f9237083a035ae16a24cc091e82da4876e110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1rbara=20de=20Castro=20Fernandes?= Date: Fri, 29 May 2020 15:05:24 -0300 Subject: [PATCH] Add 'block user' option to the report window --- app/soapbox/actions/reports.js | 8 +++++++ .../features/ui/components/report_modal.js | 23 +++++++++++++++++-- app/soapbox/locales/defaultMessages.json | 10 +++++++- app/soapbox/locales/en.json | 2 ++ app/soapbox/reducers/reports.js | 4 ++++ 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/app/soapbox/actions/reports.js b/app/soapbox/actions/reports.js index afa0c3412..a1214fc56 100644 --- a/app/soapbox/actions/reports.js +++ b/app/soapbox/actions/reports.js @@ -11,6 +11,7 @@ export const REPORT_SUBMIT_FAIL = 'REPORT_SUBMIT_FAIL'; export const REPORT_STATUS_TOGGLE = 'REPORT_STATUS_TOGGLE'; export const REPORT_COMMENT_CHANGE = 'REPORT_COMMENT_CHANGE'; export const REPORT_FORWARD_CHANGE = 'REPORT_FORWARD_CHANGE'; +export const REPORT_BLOCK_CHANGE = 'REPORT_BLOCK_CHANGE'; export function initReport(account, status) { return dispatch => { @@ -87,3 +88,10 @@ export function changeReportForward(forward) { forward, }; }; + +export function changeReportBlock(block) { + return { + type: REPORT_BLOCK_CHANGE, + block, + }; +}; diff --git a/app/soapbox/features/ui/components/report_modal.js b/app/soapbox/features/ui/components/report_modal.js index 3469aebbf..fcd31afb1 100644 --- a/app/soapbox/features/ui/components/report_modal.js +++ b/app/soapbox/features/ui/components/report_modal.js @@ -1,6 +1,7 @@ import React from 'react'; 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 PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; @@ -30,6 +31,7 @@ const makeMapStateToProps = () => { account: getAccount(state, accountId), comment: state.getIn(['reports', 'new', 'comment']), 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'])), }; }; @@ -47,6 +49,7 @@ class ReportModal extends ImmutablePureComponent { statusIds: ImmutablePropTypes.orderedSet.isRequired, comment: PropTypes.string.isRequired, forward: PropTypes.bool, + block: PropTypes.bool, dispatch: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, }; @@ -59,8 +62,15 @@ class ReportModal extends ImmutablePureComponent { this.props.dispatch(changeReportForward(e.target.checked)); } + handleBlockChange = e => { + this.props.dispatch(changeReportBlock(e.target.checked)); + } + handleSubmit = () => { this.props.dispatch(submitReport()); + if (this.props.block) { + this.props.dispatch(blockAccount(this.props.account.get('id'))); + } } handleKeyDown = e => { @@ -80,7 +90,7 @@ class ReportModal extends ImmutablePureComponent { } render() { - const { account, comment, intl, statusIds, isSubmitting, forward, onClose } = this.props; + const { account, comment, intl, statusIds, isSubmitting, forward, block, onClose } = this.props; if (!account) { return null; @@ -120,6 +130,15 @@ class ReportModal extends ImmutablePureComponent { )} +
+

+ +
+ + +
+
+