Add confirmation page when importing blocked domains (#1773)
* Move glitch-soc-specific strings to glitch-soc-specific locale files * Add confirmation page when importing blocked domainsmain
parent
3a08411306
commit
b91196f4b7
@ -0,0 +1,35 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Form::DomainBlockBatch
|
||||
include ActiveModel::Model
|
||||
include Authorization
|
||||
include AccountableConcern
|
||||
|
||||
attr_accessor :domain_blocks_attributes, :action, :current_account
|
||||
|
||||
def save
|
||||
case action
|
||||
when 'save'
|
||||
save!
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def domain_blocks
|
||||
@domain_blocks ||= domain_blocks_attributes.values.filter_map do |attributes|
|
||||
DomainBlock.new(attributes.without('enabled')) if ActiveModel::Type::Boolean.new.cast(attributes['enabled'])
|
||||
end
|
||||
end
|
||||
|
||||
def save!
|
||||
domain_blocks.each do |domain_block|
|
||||
authorize(domain_block, :create?)
|
||||
next if DomainBlock.rule_for(domain_block.domain).present?
|
||||
|
||||
domain_block.save!
|
||||
DomainBlockWorker.perform_async(domain_block.id)
|
||||
log_action :create, domain_block
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,27 @@
|
||||
- existing_relationships ||= false
|
||||
|
||||
.batch-table__row{ class: [existing_relationships && 'batch-table__row--attention'] }
|
||||
%label.batch-table__row__select.batch-table__row__select--aligned.batch-checkbox
|
||||
= f.check_box :enabled, checked: !existing_relationships
|
||||
.batch-table__row__content.pending-account
|
||||
.pending-account__header
|
||||
%strong
|
||||
= f.object.domain
|
||||
= f.hidden_field :domain
|
||||
= f.hidden_field :severity
|
||||
= f.hidden_field :reject_media
|
||||
= f.hidden_field :reject_reports
|
||||
= f.hidden_field :obfuscate
|
||||
= f.hidden_field :private_comment
|
||||
= f.hidden_field :public_comment
|
||||
|
||||
%br/
|
||||
|
||||
= f.object.policies.map { |policy| t(policy, scope: 'admin.instances.content_policies.policies') }.join(' • ')
|
||||
- if f.object.public_comment.present?
|
||||
•
|
||||
= f.object.public_comment
|
||||
- if existing_relationships
|
||||
•
|
||||
= fa_icon 'warning fw'
|
||||
= t('admin.export_domain_blocks.import.existing_relationships_warning')
|
@ -0,0 +1,21 @@
|
||||
- content_for :page_title do
|
||||
= t('admin.export_domain_blocks.import.title')
|
||||
|
||||
%p= t('admin.export_domain_blocks.import.description_html')
|
||||
|
||||
- if defined?(@global_private_comment) && @global_private_comment.present?
|
||||
%p= t('admin.export_domain_blocks.import.private_comment_description_html', comment: @global_private_comment)
|
||||
|
||||
= form_for(@form, url: batch_admin_domain_blocks_path) do |f|
|
||||
.batch-table
|
||||
.batch-table__toolbar
|
||||
%label.batch-table__toolbar__select.batch-checkbox-all
|
||||
= check_box_tag :batch_checkbox_all, nil, false
|
||||
.batch-table__toolbar__actions
|
||||
= f.button safe_join([fa_icon('copy'), t('admin.domain_blocks.import')]), name: :save, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') }
|
||||
.batch-table__body
|
||||
- if @domain_blocks.empty?
|
||||
= nothing_here 'nothing-here--under-tabs'
|
||||
- else
|
||||
= f.simple_fields_for :domain_blocks, @domain_blocks do |ff|
|
||||
= render 'domain_block', f: ff, existing_relationships: @warning_domains.include?(ff.object.domain)
|
Loading…
Reference in new issue