Redesign admin instances area (#9645)
This commit is contained in:
parent
9a38357111
commit
1c6588accc
60 changed files with 159 additions and 531 deletions
|
@ -4,14 +4,9 @@ module Admin
|
|||
class DomainBlocksController < BaseController
|
||||
before_action :set_domain_block, only: [:show, :destroy]
|
||||
|
||||
def index
|
||||
authorize :domain_block, :index?
|
||||
@domain_blocks = DomainBlock.page(params[:page])
|
||||
end
|
||||
|
||||
def new
|
||||
authorize :domain_block, :create?
|
||||
@domain_block = DomainBlock.new
|
||||
@domain_block = DomainBlock.new(domain: params[:_domain])
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -22,7 +17,7 @@ module Admin
|
|||
if @domain_block.save
|
||||
DomainBlockWorker.perform_async(@domain_block.id)
|
||||
log_action :create, @domain_block
|
||||
redirect_to admin_domain_blocks_path, notice: I18n.t('admin.domain_blocks.created_msg')
|
||||
redirect_to admin_instances_path(limited: '1'), notice: I18n.t('admin.domain_blocks.created_msg')
|
||||
else
|
||||
render :new
|
||||
end
|
||||
|
@ -36,7 +31,7 @@ module Admin
|
|||
authorize @domain_block, :destroy?
|
||||
UnblockDomainService.new.call(@domain_block, retroactive_unblock?)
|
||||
log_action :destroy, @domain_block
|
||||
redirect_to admin_domain_blocks_path, notice: I18n.t('admin.domain_blocks.destroyed_msg')
|
||||
redirect_to admin_instances_path(limited: '1'), notice: I18n.t('admin.domain_blocks.destroyed_msg')
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -4,14 +4,21 @@ module Admin
|
|||
class InstancesController < BaseController
|
||||
def index
|
||||
authorize :instance, :index?
|
||||
|
||||
@instances = ordered_instances
|
||||
end
|
||||
|
||||
def resubscribe
|
||||
authorize :instance, :resubscribe?
|
||||
params.require(:by_domain)
|
||||
Pubsubhubbub::SubscribeWorker.push_bulk(subscribeable_accounts.pluck(:id))
|
||||
redirect_to admin_instances_path
|
||||
def show
|
||||
authorize :instance, :show?
|
||||
|
||||
@instance = Instance.new(Account.by_domain_accounts.find_by(domain: params[:id]) || DomainBlock.find_by!(domain: params[:id]))
|
||||
@following_count = Follow.where(account: Account.where(domain: params[:id])).count
|
||||
@followers_count = Follow.where(target_account: Account.where(domain: params[:id])).count
|
||||
@reports_count = Report.where(target_account: Account.where(domain: params[:id])).count
|
||||
@blocks_count = Block.where(target_account: Account.where(domain: params[:id])).count
|
||||
@available = DeliveryFailureTracker.available?(Account.select(:shared_inbox_url).where(domain: params[:id]).first&.shared_inbox_url)
|
||||
@media_storage = MediaAttachment.where(account: Account.where(domain: params[:id])).sum(:file_file_size)
|
||||
@domain_block = DomainBlock.find_by(domain: params[:id])
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -27,17 +34,11 @@ module Admin
|
|||
helper_method :paginated_instances
|
||||
|
||||
def ordered_instances
|
||||
paginated_instances.map { |account| Instance.new(account) }
|
||||
end
|
||||
|
||||
def subscribeable_accounts
|
||||
Account.remote.where(protocol: :ostatus).where(domain: params[:by_domain])
|
||||
paginated_instances.map { |resource| Instance.new(resource) }
|
||||
end
|
||||
|
||||
def filter_params
|
||||
params.permit(
|
||||
:domain_name
|
||||
)
|
||||
params.permit(:limited)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,8 +6,9 @@ module Admin::FilterHelper
|
|||
INVITE_FILTER = %i(available expired).freeze
|
||||
CUSTOM_EMOJI_FILTERS = %i(local remote by_domain shortcode).freeze
|
||||
TAGS_FILTERS = %i(hidden).freeze
|
||||
INSTANCES_FILTERS = %i(limited).freeze
|
||||
|
||||
FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS + INVITE_FILTER + CUSTOM_EMOJI_FILTERS + TAGS_FILTERS
|
||||
FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS + INVITE_FILTER + CUSTOM_EMOJI_FILTERS + TAGS_FILTERS + INSTANCES_FILTERS
|
||||
|
||||
def filter_link_to(text, link_to_params, link_class_params = link_to_params)
|
||||
new_url = filtered_url_for(link_to_params)
|
||||
|
|
|
@ -151,6 +151,20 @@ $no-columns-breakpoint: 600px;
|
|||
font-weight: 500;
|
||||
}
|
||||
|
||||
.directory__tag a {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.directory__tag h4 {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: $primary-text-color;
|
||||
text-transform: none;
|
||||
padding-bottom: 0;
|
||||
margin-bottom: 0;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
& > p {
|
||||
font-size: 14px;
|
||||
line-height: 18px;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
color: $primary-text-color;
|
||||
font-family: $font-display, sans-serif;
|
||||
margin-bottom: 20px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
&__text {
|
||||
|
|
|
@ -3,10 +3,23 @@
|
|||
class Instance
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_accessor :domain, :accounts_count
|
||||
attr_accessor :domain, :accounts_count, :domain_block
|
||||
|
||||
def initialize(account)
|
||||
@domain = account.domain
|
||||
@accounts_count = account.accounts_count
|
||||
def initialize(resource)
|
||||
@domain = resource.domain
|
||||
@accounts_count = resource.accounts_count
|
||||
@domain_block = resource.is_a?(DomainBlock) ? resource : DomainBlock.find_by(domain: domain)
|
||||
end
|
||||
|
||||
def cached_sample_accounts
|
||||
Rails.cache.fetch("#{cache_key}/sample_accounts", expires_in: 12.hours) { Account.where(domain: domain).searchable.joins(:account_stat).popular.limit(3) }
|
||||
end
|
||||
|
||||
def to_param
|
||||
domain
|
||||
end
|
||||
|
||||
def cache_key
|
||||
domain
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,21 +8,10 @@ class InstanceFilter
|
|||
end
|
||||
|
||||
def results
|
||||
scope = Account.remote.by_domain_accounts
|
||||
params.each do |key, value|
|
||||
scope.merge!(scope_for(key, value)) if value.present?
|
||||
end
|
||||
scope
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def scope_for(key, value)
|
||||
case key.to_s
|
||||
when 'domain_name'
|
||||
Account.matches_domain(value)
|
||||
if params[:limited].present?
|
||||
DomainBlock.order(id: :desc)
|
||||
else
|
||||
raise "Unknown filter: #{key}"
|
||||
Account.remote.by_domain_accounts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ class InstancePolicy < ApplicationPolicy
|
|||
admin?
|
||||
end
|
||||
|
||||
def resubscribe?
|
||||
def show?
|
||||
admin?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
%tr
|
||||
%td
|
||||
%samp= domain_block.domain
|
||||
%td.severity
|
||||
= t("admin.domain_blocks.severities.#{domain_block.severity}")
|
||||
%td.reject_media
|
||||
- if domain_block.reject_media? || domain_block.suspend?
|
||||
%i.fa.fa-check
|
||||
%td.reject_reports
|
||||
- if domain_block.reject_reports? || domain_block.suspend?
|
||||
%i.fa.fa-check
|
||||
%td
|
||||
= table_link_to 'undo', t('admin.domain_blocks.undo'), admin_domain_block_path(domain_block)
|
|
@ -1,17 +0,0 @@
|
|||
- content_for :page_title do
|
||||
= t('admin.domain_blocks.title')
|
||||
|
||||
.table-wrapper
|
||||
%table.table
|
||||
%thead
|
||||
%tr
|
||||
%th= t('admin.domain_blocks.domain')
|
||||
%th= t('admin.domain_blocks.severity')
|
||||
%th= t('admin.domain_blocks.reject_media')
|
||||
%th= t('admin.domain_blocks.reject_reports')
|
||||
%th
|
||||
%tbody
|
||||
= render @domain_blocks
|
||||
|
||||
= paginate @domain_blocks
|
||||
= link_to t('admin.domain_blocks.add_new'), new_admin_domain_block_path, class: 'button'
|
|
@ -1,7 +1,5 @@
|
|||
%tr
|
||||
%td
|
||||
= link_to instance.domain, admin_accounts_path(by_domain: instance.domain)
|
||||
= link_to instance.domain, admin_instance_path(instance)
|
||||
%td.count
|
||||
= instance.accounts_count
|
||||
%td
|
||||
= table_link_to 'paper-plane-o', t('admin.accounts.resubscribe'), resubscribe_admin_instances_url(by_domain: instance.domain), method: :post, data: { confirm: t('admin.accounts.are_you_sure') }
|
||||
|
|
|
@ -1,23 +1,39 @@
|
|||
- content_for :page_title do
|
||||
= t('admin.instances.title')
|
||||
|
||||
= form_tag admin_instances_url, method: 'GET', class: 'simple_form' do
|
||||
.fields-group
|
||||
- %i(domain_name).each do |key|
|
||||
.input.string.optional
|
||||
= text_field_tag key, params[key], class: 'string optional', placeholder: I18n.t("admin.instances.#{key}")
|
||||
.filters
|
||||
.filter-subset
|
||||
%strong= t('admin.instances.moderation.title')
|
||||
%ul
|
||||
%li= filter_link_to t('admin.instances.moderation.all'), limited: nil
|
||||
%li= filter_link_to t('admin.instances.moderation.limited'), limited: '1'
|
||||
|
||||
.actions
|
||||
%button= t('admin.instances.search')
|
||||
= link_to t('admin.instances.reset'), admin_instances_path, class: 'button negative'
|
||||
%div{ style: 'flex: 1 1 auto; text-align: right' }
|
||||
= link_to t('admin.domain_blocks.add_new'), new_admin_domain_block_path, class: 'button'
|
||||
|
||||
.table-wrapper
|
||||
%table.table
|
||||
%thead
|
||||
%tr
|
||||
%th= t('admin.instances.domain_name')
|
||||
%th= t('admin.instances.account_count')
|
||||
%tbody
|
||||
= render @instances
|
||||
%hr.spacer/
|
||||
|
||||
- @instances.each do |instance|
|
||||
.directory__tag
|
||||
= link_to admin_instance_path(instance) do
|
||||
%h4
|
||||
= instance.domain
|
||||
%small
|
||||
= t('admin.instances.known_accounts', count: instance.accounts_count)
|
||||
|
||||
- if instance.domain_block
|
||||
- if !instance.domain_block.noop?
|
||||
•
|
||||
= t("admin.domain_blocks.severity.#{instance.domain_block.severity}")
|
||||
- if instance.domain_block.reject_media?
|
||||
•
|
||||
= t('admin.domain_blocks.rejecting_media')
|
||||
- if instance.domain_block.reject_reports?
|
||||
•
|
||||
= t('admin.domain_blocks.rejecting_reports')
|
||||
|
||||
.avatar-stack
|
||||
- instance.cached_sample_accounts.each do |account|
|
||||
= image_tag current_account&.user&.setting_auto_play_gif ? account.avatar_original_url : account.avatar_static_url, width: 48, height: 48, alt: '', class: 'account__avatar'
|
||||
|
||||
= paginate paginated_instances
|
||||
|
|
44
app/views/admin/instances/show.html.haml
Normal file
44
app/views/admin/instances/show.html.haml
Normal file
|
@ -0,0 +1,44 @@
|
|||
- content_for :page_title do
|
||||
= @instance.domain
|
||||
|
||||
.dashboard__counters
|
||||
%div
|
||||
%div
|
||||
.dashboard__counters__num= number_with_delimiter @following_count
|
||||
.dashboard__counters__label= t 'admin.instances.total_followed_by_them'
|
||||
%div
|
||||
%div
|
||||
.dashboard__counters__num= number_with_delimiter @followers_count
|
||||
.dashboard__counters__label= t 'admin.instances.total_followed_by_us'
|
||||
%div
|
||||
%div
|
||||
.dashboard__counters__num= number_to_human_size @media_storage
|
||||
.dashboard__counters__label= t 'admin.instances.total_storage'
|
||||
%div
|
||||
%div
|
||||
.dashboard__counters__num= number_with_delimiter @blocks_count
|
||||
.dashboard__counters__label= t 'admin.instances.total_blocked_by_us'
|
||||
%div
|
||||
%div
|
||||
.dashboard__counters__num= number_with_delimiter @reports_count
|
||||
.dashboard__counters__label= t 'admin.instances.total_reported'
|
||||
%div
|
||||
%div
|
||||
.dashboard__counters__num
|
||||
- if @available
|
||||
= fa_icon 'check'
|
||||
- else
|
||||
= fa_icon 'times'
|
||||
.dashboard__counters__label= t 'admin.instances.delivery_available'
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
%div{ style: 'overflow: hidden' }
|
||||
%div{ style: 'float: left' }
|
||||
= link_to t('admin.accounts.title'), admin_accounts_path(remote: '1', by_domain: @instance.domain), class: 'button'
|
||||
|
||||
%div{ style: 'float: right' }
|
||||
- if @domain_block
|
||||
= link_to t('admin.domain_blocks.undo'), admin_domain_block_path(@domain_block), class: 'button'
|
||||
- else
|
||||
= link_to t('admin.domain_blocks.add_new'), new_admin_domain_block_path(_domain: @instance.domain), class: 'button'
|
Loading…
Add table
Add a link
Reference in a new issue