about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2021-07-11 11:01:38 +0200
committerGitHub <noreply@github.com>2021-07-11 11:01:38 +0200
commit7095c80373c4a4d73b3e7b4f69bee24c4a57828d (patch)
tree99c4a606bfb94b320bc7061cd87ca32e0f26af1b
parentca8ac1a6390da16fe403276c60aec0e06d831f5b (diff)
Add ability to filter reports by origin of target account (#16487)
-rw-r--r--app/models/report_filter.rb14
-rw-r--r--app/views/admin/reports/index.html.haml6
-rw-r--r--config/locales/en.yml1
3 files changed, 21 insertions, 0 deletions
diff --git a/app/models/report_filter.rb b/app/models/report_filter.rb
index c32d4359e..a91a6baeb 100644
--- a/app/models/report_filter.rb
+++ b/app/models/report_filter.rb
@@ -6,6 +6,7 @@ class ReportFilter
     account_id
     target_account_id
     by_target_domain
+    target_origin
   ).freeze
 
   attr_reader :params
@@ -34,8 +35,21 @@ class ReportFilter
       Report.where(account_id: value)
     when :target_account_id
       Report.where(target_account_id: value)
+    when :target_origin
+      target_origin_scope(value)
     else
       raise "Unknown filter: #{key}"
     end
   end
+
+  def target_origin_scope(value)
+    case value.to_sym
+    when :local
+      Report.where(target_account: Account.local)
+    when :remote
+      Report.where(target_account: Account.remote)
+    else
+      raise "Unknown value: #{value}"
+    end
+  end
 end
diff --git a/app/views/admin/reports/index.html.haml b/app/views/admin/reports/index.html.haml
index 721c55f71..619173373 100644
--- a/app/views/admin/reports/index.html.haml
+++ b/app/views/admin/reports/index.html.haml
@@ -7,6 +7,12 @@
     %ul
       %li= filter_link_to t('admin.reports.unresolved'), resolved: nil
       %li= filter_link_to t('admin.reports.resolved'), resolved: '1'
+  .filter-subset
+    %strong= t('admin.reports.target_origin')
+    %ul
+      %li= filter_link_to t('admin.accounts.location.all'), target_origin: nil
+      %li= filter_link_to t('admin.accounts.location.local'), target_origin: 'local'
+      %li= filter_link_to t('admin.accounts.location.remote'), target_origin: 'remote'
 
 = form_tag admin_reports_url, method: 'GET', class: 'simple_form' do
   .fields-group
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 51764a0e1..af7266d86 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -579,6 +579,7 @@ en:
       resolved: Resolved
       resolved_msg: Report successfully resolved!
       status: Status
+      target_origin: Origin of reported account
       title: Reports
       unassign: Unassign
       unresolved: Unresolved