Add confirmation screen when handling reports (#22375)
* Add confirmation screen on moderation actions * Add flash notice when a report has been processed * Refactor tests * Add tests
This commit is contained in:
@ -21,7 +21,7 @@ module Admin
|
||||
account_action.save!
|
||||
|
||||
if account_action.with_report?
|
||||
redirect_to admin_reports_path
|
||||
redirect_to admin_reports_path, notice: I18n.t('admin.reports.processed_msg', id: params[:report_id])
|
||||
else
|
||||
redirect_to admin_account_path(@account.id)
|
||||
end
|
||||
|
@ -3,6 +3,11 @@
|
||||
class Admin::Reports::ActionsController < Admin::BaseController
|
||||
before_action :set_report
|
||||
|
||||
def preview
|
||||
authorize @report, :show?
|
||||
@moderation_action = action_from_button
|
||||
end
|
||||
|
||||
def create
|
||||
authorize @report, :show?
|
||||
|
||||
@ -13,7 +18,8 @@ class Admin::Reports::ActionsController < Admin::BaseController
|
||||
status_ids: @report.status_ids,
|
||||
current_account: current_account,
|
||||
report_id: @report.id,
|
||||
send_email_notification: !@report.spam?
|
||||
send_email_notification: !@report.spam?,
|
||||
text: params[:text]
|
||||
)
|
||||
|
||||
status_batch_action.save!
|
||||
@ -23,13 +29,16 @@ class Admin::Reports::ActionsController < Admin::BaseController
|
||||
report_id: @report.id,
|
||||
target_account: @report.target_account,
|
||||
current_account: current_account,
|
||||
send_email_notification: !@report.spam?
|
||||
send_email_notification: !@report.spam?,
|
||||
text: params[:text]
|
||||
)
|
||||
|
||||
account_action.save!
|
||||
else
|
||||
return redirect_to admin_report_path(@report), alert: I18n.t('admin.reports.unknown_action_msg', action: action_from_button)
|
||||
end
|
||||
|
||||
redirect_to admin_reports_path
|
||||
redirect_to admin_reports_path, notice: I18n.t('admin.reports.processed_msg', id: @report.id)
|
||||
end
|
||||
|
||||
private
|
||||
@ -47,6 +56,8 @@ class Admin::Reports::ActionsController < Admin::BaseController
|
||||
'silence'
|
||||
elsif params[:suspend]
|
||||
'suspend'
|
||||
elsif params[:moderation_action]
|
||||
params[:moderation_action]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -6,7 +6,8 @@ class Admin::StatusBatchAction
|
||||
include Authorization
|
||||
|
||||
attr_accessor :current_account, :type,
|
||||
:status_ids, :report_id
|
||||
:status_ids, :report_id,
|
||||
:text
|
||||
|
||||
attr_reader :send_email_notification
|
||||
|
||||
@ -57,7 +58,8 @@ class Admin::StatusBatchAction
|
||||
action: :delete_statuses,
|
||||
account: current_account,
|
||||
report: report,
|
||||
status_ids: status_ids
|
||||
status_ids: status_ids,
|
||||
text: text
|
||||
)
|
||||
|
||||
statuses.each { |status| Tombstone.find_or_create_by(uri: status.uri, account: status.account, by_moderator: true) } unless target_account.local?
|
||||
@ -95,7 +97,8 @@ class Admin::StatusBatchAction
|
||||
action: :mark_statuses_as_sensitive,
|
||||
account: current_account,
|
||||
report: report,
|
||||
status_ids: status_ids
|
||||
status_ids: status_ids,
|
||||
text: text
|
||||
)
|
||||
|
||||
UserMailer.warning(target_account.user, @warning).deliver_later! if warnable?
|
||||
|
@ -1,4 +1,4 @@
|
||||
= form_tag admin_report_actions_path(@report), method: :post do
|
||||
= form_tag preview_admin_report_actions_path(@report), method: :post do
|
||||
.report-actions
|
||||
.report-actions__item
|
||||
.report-actions__item__button
|
||||
|
78
app/views/admin/reports/actions/preview.html.haml
Normal file
78
app/views/admin/reports/actions/preview.html.haml
Normal file
@ -0,0 +1,78 @@
|
||||
- target_acct = @report.target_account.acct
|
||||
- warning_action = { 'delete' => 'delete_statuses', 'mark_as_sensitive' => 'mark_statuses_as_sensitive' }.fetch(@moderation_action, @moderation_action)
|
||||
|
||||
- content_for :page_title do
|
||||
= t('admin.reports.confirm_action', acct: target_acct)
|
||||
|
||||
= form_tag admin_report_actions_path(@report), class: 'simple_form', method: :post do
|
||||
= hidden_field_tag :moderation_action, @moderation_action
|
||||
|
||||
%p.hint= t("admin.reports.summary.action_preambles.#{@moderation_action}_html", acct: target_acct)
|
||||
%ul.hint
|
||||
%li.warning-hint= t("admin.reports.summary.actions.#{@moderation_action}_html", acct: target_acct)
|
||||
- if @moderation_action == 'suspend'
|
||||
%li.warning-hint= t('admin.reports.summary.delete_data_html', acct: target_acct)
|
||||
- if %w(silence suspend).include?(@moderation_action)
|
||||
%li.warning-hint= t('admin.reports.summary.close_reports_html', acct: target_acct)
|
||||
- else
|
||||
%li= t('admin.reports.summary.close_report', id: @report.id)
|
||||
%li= t('admin.reports.summary.record_strike_html', acct: target_acct)
|
||||
- if @report.target_account.local? && !@report.spam?
|
||||
%li= t('admin.reports.summary.send_email_html', acct: target_acct)
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
- if @report.target_account.local?
|
||||
%p.hint= t('admin.reports.summary.preview_preamble_html', acct: target_acct)
|
||||
|
||||
.strike-card
|
||||
- unless warning_action == 'none'
|
||||
%p= t "user_mailer.warning.explanation.#{warning_action}", instance: Rails.configuration.x.local_domain
|
||||
|
||||
.fields-group
|
||||
= text_area_tag :text, nil, placeholder: t('admin.reports.summary.warning_placeholder')
|
||||
|
||||
- if !@report.other?
|
||||
%p
|
||||
%strong= t('user_mailer.warning.reason')
|
||||
= t("user_mailer.warning.categories.#{@report.category}")
|
||||
|
||||
- if @report.violation? && @report.rule_ids.present?
|
||||
%ul.strike-card__rules
|
||||
- @report.rules.each do |rule|
|
||||
%li
|
||||
%span.strike-card__rules__text= rule.text
|
||||
|
||||
- if @report.status_ids.present? && !@report.status_ids.empty?
|
||||
%p
|
||||
%strong= t('user_mailer.warning.statuses')
|
||||
|
||||
.strike-card__statuses-list
|
||||
- status_map = @report.statuses.includes(:application, :media_attachments).index_by(&:id)
|
||||
|
||||
- @report.status_ids.each do |status_id|
|
||||
.strike-card__statuses-list__item
|
||||
- if (status = status_map[status_id.to_i])
|
||||
.one-liner
|
||||
= link_to short_account_status_url(@report.target_account, status_id), class: 'emojify' do
|
||||
= one_line_preview(status)
|
||||
|
||||
- status.ordered_media_attachments.each do |media_attachment|
|
||||
%abbr{ title: media_attachment.description }
|
||||
= fa_icon 'link'
|
||||
= media_attachment.file_file_name
|
||||
.strike-card__statuses-list__item__meta
|
||||
%time.formatted{ datetime: status.created_at.iso8601, title: l(status.created_at) }= l(status.created_at)
|
||||
- unless status.application.nil?
|
||||
·
|
||||
= status.application.name
|
||||
- else
|
||||
.one-liner= t('disputes.strikes.status', id: status_id)
|
||||
.strike-card__statuses-list__item__meta
|
||||
= t('disputes.strikes.status_removed')
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
.actions
|
||||
= link_to t('admin.reports.cancel'), admin_report_path(@report), class: 'button button-tertiary'
|
||||
= button_tag t('admin.reports.confirm'), name: :confirm, class: 'button', type: :submit
|
Reference in New Issue
Block a user