From 0fb9536d3888cd7b6013c239d5be85f095a6e8ad Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 5 Dec 2021 21:48:39 +0100 Subject: Add batch suspend for accounts in admin UI (#17009) --- app/views/admin/accounts/_account.html.haml | 59 +++++++++++++--------- app/views/admin/accounts/index.html.haml | 56 ++++++++++++-------- app/views/admin/dashboard/index.html.haml | 2 +- app/views/admin/instances/show.html.haml | 2 +- app/views/admin/ip_blocks/_ip_block.html.haml | 6 +-- .../admin/pending_accounts/_account.html.haml | 16 ------ app/views/admin/pending_accounts/index.html.haml | 33 ------------ 7 files changed, 75 insertions(+), 99 deletions(-) delete mode 100644 app/views/admin/pending_accounts/_account.html.haml delete mode 100644 app/views/admin/pending_accounts/index.html.haml (limited to 'app/views/admin') diff --git a/app/views/admin/accounts/_account.html.haml b/app/views/admin/accounts/_account.html.haml index c9bd8c686..2df91301e 100644 --- a/app/views/admin/accounts/_account.html.haml +++ b/app/views/admin/accounts/_account.html.haml @@ -1,24 +1,35 @@ -%tr - %td - = admin_account_link_to(account) - %td - %div.account-badges= account_badge(account, all: true) - %td - - if account.user_current_sign_in_ip - %samp.ellipsized-ip{ title: account.user_current_sign_in_ip }= account.user_current_sign_in_ip - - else - \- - %td - - if account.user_current_sign_in_at - %time.time-ago{ datetime: account.user_current_sign_in_at.iso8601, title: l(account.user_current_sign_in_at) }= l account.user_current_sign_in_at - - elsif account.last_status_at.present? - %time.time-ago{ datetime: account.last_status_at.iso8601, title: l(account.last_status_at) }= l account.last_status_at - - else - \- - %td - - if account.local? && account.user_pending? - = table_link_to 'check', t('admin.accounts.approve'), approve_admin_account_path(account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') } if can?(:approve, account.user) - = table_link_to 'times', t('admin.accounts.reject'), reject_admin_account_path(account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') } if can?(:reject, account.user) - - else - = table_link_to 'circle', t('admin.accounts.web'), web_path("accounts/#{account.id}") - = table_link_to 'globe', t('admin.accounts.public'), ActivityPub::TagManager.instance.url_for(account) +.batch-table__row{ class: [!account.suspended? && account.user_pending? && 'batch-table__row--attention', account.suspended? && 'batch-table__row--muted'] } + %label.batch-table__row__select.batch-table__row__select--aligned.batch-checkbox + = f.check_box :account_ids, { multiple: true, include_hidden: false }, account.id + .batch-table__row__content.batch-table__row__content--unpadded + %table.accounts-table + %tbody + %tr + %td + = account_link_to account, path: admin_account_path(account.id) + %td.accounts-table__count.optional + - if account.suspended? || account.user_pending? + \- + - else + = friendly_number_to_human account.statuses_count + %small= t('accounts.posts', count: account.statuses_count).downcase + %td.accounts-table__count.optional + - if account.suspended? || account.user_pending? + \- + - else + = friendly_number_to_human account.followers_count + %small= t('accounts.followers', count: account.followers_count).downcase + %td.accounts-table__count + = relevant_account_timestamp(account) + %small= t('accounts.last_active') + %td.accounts-table__extra + - if account.local? + - if account.user_email + = link_to account.user_email.split('@').last, admin_accounts_path(email: "%@#{account.user_email.split('@').last}"), title: account.user_email + - else + \- + %br/ + %samp.ellipsized-ip= relevant_account_ip(account, params[:ip]) + - if !account.suspended? && account.user_pending? && account.user&.invite_request&.text&.present? + .batch-table__row__content__quote + %p= account.user&.invite_request&.text diff --git a/app/views/admin/accounts/index.html.haml b/app/views/admin/accounts/index.html.haml index 398ab4bb4..7c0045145 100644 --- a/app/views/admin/accounts/index.html.haml +++ b/app/views/admin/accounts/index.html.haml @@ -1,34 +1,37 @@ - content_for :page_title do = t('admin.accounts.title') +- content_for :header_tags do + = javascript_pack_tag 'admin', async: true, crossorigin: 'anonymous' + .filters .filter-subset %strong= t('admin.accounts.location.title') %ul - %li= filter_link_to t('admin.accounts.location.local'), remote: nil - %li= filter_link_to t('admin.accounts.location.remote'), remote: '1' + %li= filter_link_to t('generic.all'), origin: nil + %li= filter_link_to t('admin.accounts.location.local'), origin: 'local' + %li= filter_link_to t('admin.accounts.location.remote'), origin: 'remote' .filter-subset %strong= t('admin.accounts.moderation.title') %ul - %li= link_to safe_join([t('admin.accounts.moderation.pending'), "(#{number_with_delimiter(User.pending.count)})"], ' '), admin_pending_accounts_path - %li= filter_link_to t('admin.accounts.moderation.active'), silenced: nil, suspended: nil, pending: nil - %li= filter_link_to t('admin.accounts.moderation.silenced'), silenced: '1', suspended: nil, pending: nil - %li= filter_link_to t('admin.accounts.moderation.suspended'), suspended: '1', silenced: nil, pending: nil + %li= filter_link_to t('generic.all'), status: nil + %li= filter_link_to t('admin.accounts.moderation.active'), status: 'active' + %li= filter_link_to t('admin.accounts.moderation.suspended'), status: 'suspended' + %li= filter_link_to safe_join([t('admin.accounts.moderation.pending'), "(#{number_with_delimiter(User.pending.count)})"], ' '), status: 'pending' .filter-subset %strong= t('admin.accounts.role') %ul - %li= filter_link_to t('admin.accounts.moderation.all'), staff: nil - %li= filter_link_to t('admin.accounts.roles.staff'), staff: '1' + %li= filter_link_to t('admin.accounts.moderation.all'), permissions: nil + %li= filter_link_to t('admin.accounts.roles.staff'), permissions: 'staff' .filter-subset %strong= t 'generic.order_by' %ul %li= filter_link_to t('relationships.most_recent'), order: nil - %li= filter_link_to t('admin.accounts.username'), order: 'alphabetic' %li= filter_link_to t('relationships.last_active'), order: 'active' = form_tag admin_accounts_url, method: 'GET', class: 'simple_form' do .fields-group - - AccountFilter::KEYS.each do |key| + - (AccountFilter::KEYS - %i(origin status permissions)).each do |key| - if params[key].present? = hidden_field_tag key, params[key] @@ -41,16 +44,27 @@ %button.button= t('admin.accounts.search') = link_to t('admin.accounts.reset'), admin_accounts_path, class: 'button negative' -.table-wrapper - %table.table - %thead - %tr - %th= t('admin.accounts.username') - %th= t('admin.accounts.role') - %th= t('admin.accounts.most_recent_ip') - %th= t('admin.accounts.most_recent_activity') - %th - %tbody - = render partial: 'account', collection: @accounts += form_for(@form, url: batch_admin_accounts_path) do |f| + = hidden_field_tag :page, params[:page] || 1 + + - AccountFilter::KEYS.each do |key| + = hidden_field_tag key, params[key] if params[key].present? + + .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 + - if @accounts.any? { |account| account.user_pending? } + = f.button safe_join([fa_icon('check'), t('admin.accounts.approve')]), name: :approve, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } + + = f.button safe_join([fa_icon('times'), t('admin.accounts.reject')]), name: :reject, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } + + = f.button safe_join([fa_icon('lock'), t('admin.accounts.perform_full_suspension')]), name: :suspend, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } + .batch-table__body + - if @accounts.empty? + = nothing_here 'nothing-here--under-tabs' + - else + = render partial: 'account', collection: @accounts, locals: { f: f } = paginate @accounts diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index 895333a58..4b581f5ea 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -38,7 +38,7 @@ %span= t('admin.dashboard.pending_reports_html', count: @pending_reports_count) = fa_icon 'chevron-right fw' - = link_to admin_pending_accounts_path, class: 'dashboard__quick-access' do + = link_to admin_accounts_path(status: 'pending'), class: 'dashboard__quick-access' do %span= t('admin.dashboard.pending_users_html', count: @pending_users_count) = fa_icon 'chevron-right fw' diff --git a/app/views/admin/instances/show.html.haml b/app/views/admin/instances/show.html.haml index 462529338..d6542ac3e 100644 --- a/app/views/admin/instances/show.html.haml +++ b/app/views/admin/instances/show.html.haml @@ -15,7 +15,7 @@ .dashboard__counters %div - = link_to admin_accounts_path(remote: '1', by_domain: @instance.domain) do + = link_to admin_accounts_path(origin: 'remote', by_domain: @instance.domain) do .dashboard__counters__num= number_with_delimiter @instance.accounts_count .dashboard__counters__label= t 'admin.accounts.title' %div diff --git a/app/views/admin/ip_blocks/_ip_block.html.haml b/app/views/admin/ip_blocks/_ip_block.html.haml index e07e2b444..b8d3ac0e8 100644 --- a/app/views/admin/ip_blocks/_ip_block.html.haml +++ b/app/views/admin/ip_blocks/_ip_block.html.haml @@ -1,9 +1,9 @@ .batch-table__row %label.batch-table__row__select.batch-table__row__select--aligned.batch-checkbox = f.check_box :ip_block_ids, { multiple: true, include_hidden: false }, ip_block.id - .batch-table__row__content - .batch-table__row__content__text - %samp= "#{ip_block.ip}/#{ip_block.ip.prefix}" + .batch-table__row__content.pending-account + .pending-account__header + %samp= link_to "#{ip_block.ip}/#{ip_block.ip.prefix}", admin_accounts_path(ip: "#{ip_block.ip}/#{ip_block.ip.prefix}") - if ip_block.comment.present? • = ip_block.comment diff --git a/app/views/admin/pending_accounts/_account.html.haml b/app/views/admin/pending_accounts/_account.html.haml deleted file mode 100644 index 5b475b59a..000000000 --- a/app/views/admin/pending_accounts/_account.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -.batch-table__row - %label.batch-table__row__select.batch-table__row__select--aligned.batch-checkbox - = f.check_box :account_ids, { multiple: true, include_hidden: false }, account.id - .batch-table__row__content.pending-account - .pending-account__header - = link_to admin_account_path(account.id) do - %strong= account.user_email - = "(@#{account.username})" - %br/ - %samp= account.user_current_sign_in_ip - • - = t 'admin.accounts.time_in_queue', time: time_ago_in_words(account.user&.created_at) - - - if account.user&.invite_request&.text&.present? - .pending-account__body - %p= account.user&.invite_request&.text diff --git a/app/views/admin/pending_accounts/index.html.haml b/app/views/admin/pending_accounts/index.html.haml deleted file mode 100644 index 8384a1c9f..000000000 --- a/app/views/admin/pending_accounts/index.html.haml +++ /dev/null @@ -1,33 +0,0 @@ -- content_for :page_title do - = t('admin.pending_accounts.title', count: User.pending.count) - -- content_for :header_tags do - = javascript_pack_tag 'admin', async: true, crossorigin: 'anonymous' - -= form_for(@form, url: batch_admin_pending_accounts_path) do |f| - = hidden_field_tag :page, params[:page] || 1 - - .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('check'), t('admin.accounts.approve')]), name: :approve, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } - - = f.button safe_join([fa_icon('times'), t('admin.accounts.reject')]), name: :reject, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } - .batch-table__body - - if @accounts.empty? - = nothing_here 'nothing-here--under-tabs' - - else - = render partial: 'account', collection: @accounts, locals: { f: f } - -= paginate @accounts - -%hr.spacer/ - -%div.action-buttons - %div - = link_to t('admin.accounts.approve_all'), approve_all_admin_pending_accounts_path, method: :post, data: { confirm: t('admin.accounts.are_you_sure') }, class: 'button' - - %div - = link_to t('admin.accounts.reject_all'), reject_all_admin_pending_accounts_path, method: :post, data: { confirm: t('admin.accounts.are_you_sure') }, class: 'button button--destructive' -- cgit