Improve admin UI for accounts (#7360)
* Improve design of account statuses admin UI (consistent with reports) * Make account moderation notes look consistent with report notes * i18n-tasks remove-unused * Fix code style issues * Fix tests
This commit is contained in:
		| @ -3,7 +3,6 @@ | ||||
| module Admin | ||||
|   class ReportedStatusesController < BaseController | ||||
|     before_action :set_report | ||||
|     before_action :set_status, only: [:update, :destroy] | ||||
|  | ||||
|     def create | ||||
|       authorize :status, :update? | ||||
| @ -14,20 +13,6 @@ module Admin | ||||
|       redirect_to admin_report_path(@report) | ||||
|     end | ||||
|  | ||||
|     def update | ||||
|       authorize @status, :update? | ||||
|       @status.update!(status_params) | ||||
|       log_action :update, @status | ||||
|       redirect_to admin_report_path(@report) | ||||
|     end | ||||
|  | ||||
|     def destroy | ||||
|       authorize @status, :destroy? | ||||
|       RemovalWorker.perform_async(@status.id) | ||||
|       log_action :destroy, @status | ||||
|       render json: @status | ||||
|     end | ||||
|  | ||||
|     private | ||||
|  | ||||
|     def status_params | ||||
| @ -51,9 +36,5 @@ module Admin | ||||
|     def set_report | ||||
|       @report = Report.find(params[:report_id]) | ||||
|     end | ||||
|  | ||||
|     def set_status | ||||
|       @status = @report.statuses.find(params[:id]) | ||||
|     end | ||||
|   end | ||||
| end | ||||
|  | ||||
| @ -5,7 +5,6 @@ module Admin | ||||
|     helper_method :current_params | ||||
|  | ||||
|     before_action :set_account | ||||
|     before_action :set_status, only: [:update, :destroy] | ||||
|  | ||||
|     PER_PAGE = 20 | ||||
|  | ||||
| @ -26,40 +25,18 @@ module Admin | ||||
|     def create | ||||
|       authorize :status, :update? | ||||
|  | ||||
|       @form         = Form::StatusBatch.new(form_status_batch_params.merge(current_account: current_account)) | ||||
|       @form         = Form::StatusBatch.new(form_status_batch_params.merge(current_account: current_account, action: action_from_button)) | ||||
|       flash[:alert] = I18n.t('admin.statuses.failed_to_execute') unless @form.save | ||||
|  | ||||
|       redirect_to admin_account_statuses_path(@account.id, current_params) | ||||
|     end | ||||
|  | ||||
|     def update | ||||
|       authorize @status, :update? | ||||
|       @status.update!(status_params) | ||||
|       log_action :update, @status | ||||
|       redirect_to admin_account_statuses_path(@account.id, current_params) | ||||
|     end | ||||
|  | ||||
|     def destroy | ||||
|       authorize @status, :destroy? | ||||
|       RemovalWorker.perform_async(@status.id) | ||||
|       log_action :destroy, @status | ||||
|       render json: @status | ||||
|     end | ||||
|  | ||||
|     private | ||||
|  | ||||
|     def status_params | ||||
|       params.require(:status).permit(:sensitive) | ||||
|     end | ||||
|  | ||||
|     def form_status_batch_params | ||||
|       params.require(:form_status_batch).permit(:action, status_ids: []) | ||||
|     end | ||||
|  | ||||
|     def set_status | ||||
|       @status = @account.statuses.find(params[:id]) | ||||
|     end | ||||
|  | ||||
|     def set_account | ||||
|       @account = Account.find(params[:account_id]) | ||||
|     end | ||||
| @ -72,5 +49,15 @@ module Admin | ||||
|         page: page > 1 && page, | ||||
|       }.select { |_, value| value.present? } | ||||
|     end | ||||
|  | ||||
|     def action_from_button | ||||
|       if params[:nsfw_on] | ||||
|         'nsfw_on' | ||||
|       elsif params[:nsfw_off] | ||||
|         'nsfw_off' | ||||
|       elsif params[:delete] | ||||
|         'delete' | ||||
|       end | ||||
|     end | ||||
|   end | ||||
| end | ||||
|  | ||||
| @ -336,7 +336,8 @@ | ||||
|   } | ||||
| } | ||||
|  | ||||
| .simple_form.new_report_note { | ||||
| .simple_form.new_report_note, | ||||
| .simple_form.new_account_moderation_note { | ||||
|   max-width: 100%; | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -1,10 +1,7 @@ | ||||
| %tr | ||||
|   %td | ||||
| .speech-bubble | ||||
|   .speech-bubble__bubble | ||||
|     = simple_format(h(account_moderation_note.content)) | ||||
|   %td | ||||
|     = account_moderation_note.account.acct | ||||
|   %td | ||||
|     %time.formatted{ datetime: account_moderation_note.created_at.iso8601, title: l(account_moderation_note.created_at) } | ||||
|       = l account_moderation_note.created_at | ||||
|   %td | ||||
|     = link_to t('admin.account_moderation_notes.delete'), admin_account_moderation_note_path(account_moderation_note), method: :delete if can?(:destroy, account_moderation_note) | ||||
|   .speech-bubble__owner | ||||
|     = admin_account_link_to account_moderation_note.account | ||||
|     %time.formatted{ datetime: account_moderation_note.created_at.iso8601 }= l account_moderation_note.created_at | ||||
|     = table_link_to 'trash', t('admin.account_moderation_notes.delete'), admin_account_moderation_note_path(account_moderation_note), method: :delete if can?(:destroy, account_moderation_note) | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
|   = @account.acct | ||||
|  | ||||
| .table-wrapper | ||||
|   %table.table | ||||
|   %table.table.inline-table | ||||
|     %tbody | ||||
|       %tr | ||||
|         %th= t('admin.accounts.username') | ||||
| @ -73,17 +73,17 @@ | ||||
|  | ||||
|       %tr | ||||
|         %th= t('admin.accounts.follows') | ||||
|         %td= @account.following_count | ||||
|         %td= number_to_human @account.following_count | ||||
|       %tr | ||||
|         %th= t('admin.accounts.followers') | ||||
|         %td= @account.followers_count | ||||
|         %td= number_to_human @account.followers_count | ||||
|       %tr | ||||
|         %th= t('admin.accounts.statuses') | ||||
|         %td= link_to @account.statuses_count, admin_account_statuses_path(@account.id) | ||||
|         %td= link_to number_to_human(@account.statuses_count), admin_account_statuses_path(@account.id) | ||||
|       %tr | ||||
|         %th= t('admin.accounts.media_attachments') | ||||
|         %td | ||||
|           = link_to @account.media_attachments.count, admin_account_statuses_path(@account.id, { media: true }) | ||||
|           = link_to number_to_human(@account.media_attachments.count), admin_account_statuses_path(@account.id, { media: true }) | ||||
|           = surround '(', ')' do | ||||
|             = number_to_human_size @account.media_attachments.sum('file_file_size') | ||||
|       %tr | ||||
| @ -120,11 +120,12 @@ | ||||
|       = link_to t('admin.accounts.perform_full_suspension'), admin_account_suspension_path(@account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') }, class: 'button' if can?(:suspend, @account) | ||||
|  | ||||
| - if !@account.local? && @account.hub_url.present? | ||||
|   %hr | ||||
|   %hr.spacer/ | ||||
|  | ||||
|   %h3 OStatus | ||||
|  | ||||
|   .table-wrapper | ||||
|     %table.table | ||||
|     %table.table.inline-table | ||||
|       %tbody | ||||
|         %tr | ||||
|           %th= t('admin.accounts.feed_url') | ||||
| @ -148,11 +149,12 @@ | ||||
|         = link_to t('admin.accounts.unsubscribe'), unsubscribe_admin_account_path(@account.id), method: :post, class: 'button negative' if can?(:unsubscribe, @account) | ||||
|  | ||||
| - if !@account.local? && @account.inbox_url.present? | ||||
|   %hr | ||||
|   %hr.spacer/ | ||||
|  | ||||
|   %h3 ActivityPub | ||||
|  | ||||
|   .table-wrapper | ||||
|     %table.table | ||||
|     %table.table.inline-table | ||||
|       %tbody | ||||
|         %tr | ||||
|           %th= t('admin.accounts.inbox_url') | ||||
| @ -167,24 +169,15 @@ | ||||
|           %th= t('admin.accounts.followers_url') | ||||
|           %td= link_to @account.followers_url, @account.followers_url | ||||
|  | ||||
| %hr | ||||
| %h3= t('admin.accounts.moderation_notes') | ||||
| %hr.spacer/ | ||||
|  | ||||
| = render @moderation_notes | ||||
|  | ||||
| = simple_form_for @account_moderation_note, url: admin_account_moderation_notes_path do |f| | ||||
|   = render 'shared/error_messages', object: @account_moderation_note | ||||
|  | ||||
|   = f.input :content | ||||
|   = f.input :content, placeholder: t('admin.reports.notes.placeholder'), rows: 6 | ||||
|   = f.hidden_field :target_account_id | ||||
|  | ||||
|   .actions | ||||
|   = f.button :button, t('admin.account_moderation_notes.create'), type: :submit | ||||
|  | ||||
| .table-wrapper | ||||
|   %table.table | ||||
|     %thead | ||||
|       %tr | ||||
|         %th | ||||
|         %th= t('admin.account_moderation_notes.account') | ||||
|         %th= t('admin.account_moderation_notes.created_at') | ||||
|     %tbody | ||||
|       = render @moderation_notes | ||||
|     = f.button :button, t('admin.account_moderation_notes.create'), type: :submit | ||||
|  | ||||
| @ -7,7 +7,7 @@ | ||||
|         %p>< | ||||
|           %strong= Formatter.instance.format_spoiler(status) | ||||
|  | ||||
|       = Formatter.instance.format(status) | ||||
|       = Formatter.instance.format(status, custom_emojify: true) | ||||
|  | ||||
|     - unless status.media_attachments.empty? | ||||
|       - if status.media_attachments.first.video? | ||||
|  | ||||
| @ -3,11 +3,8 @@ | ||||
|  | ||||
| - content_for :page_title do | ||||
|   = t('admin.statuses.title') | ||||
|  | ||||
| .back-link | ||||
|   = link_to admin_account_path(@account.id) do | ||||
|     %i.fa.fa-chevron-left.fa-fw | ||||
|     = t('admin.statuses.back_to_account') | ||||
|   \- | ||||
|   = "@#{@account.acct}" | ||||
|  | ||||
| .filters | ||||
|   .filter-subset | ||||
| @ -15,33 +12,26 @@ | ||||
|     %ul | ||||
|       %li= link_to t('admin.statuses.no_media'), admin_account_statuses_path(@account.id, current_params.merge(media: nil)), class: !params[:media] && 'selected' | ||||
|       %li= link_to t('admin.statuses.with_media'), admin_account_statuses_path(@account.id, current_params.merge(media: true)), class: params[:media] && 'selected' | ||||
|   .back-link{ style: 'flex: 1 1 auto; text-align: right' } | ||||
|     = link_to admin_account_path(@account.id) do | ||||
|       %i.fa.fa-chevron-left.fa-fw | ||||
|       = t('admin.statuses.back_to_account') | ||||
|  | ||||
| - if @statuses.empty? | ||||
|   .accounts-grid | ||||
|     = render 'accounts/nothing_here' | ||||
| - else | ||||
|   = form_for(@form, url: admin_account_statuses_path(@account.id)) do |f| | ||||
|     = hidden_field_tag :page, params[:page] | ||||
|     = hidden_field_tag :media, params[:media] | ||||
|     .batch-form-box | ||||
|       .batch-checkbox-all | ||||
| %hr.spacer/ | ||||
|  | ||||
| = form_for(@form, url: admin_account_statuses_path(@account.id)) do |f| | ||||
|   = hidden_field_tag :page, params[:page] | ||||
|   = hidden_field_tag :media, params[:media] | ||||
|  | ||||
|   .batch-table | ||||
|     .batch-table__toolbar | ||||
|       %label.batch-table__toolbar__select.batch-checkbox-all | ||||
|         = check_box_tag :batch_checkbox_all, nil, false | ||||
|       = f.select :action, Form::StatusBatch::ACTION_TYPE.map{|action| [t("admin.statuses.batch.#{action}"), action]} | ||||
|       = f.submit t('admin.statuses.execute'), data: { confirm: t('admin.reports.are_you_sure') }, class: 'button' | ||||
|       .media-spoiler-toggle-buttons | ||||
|         .media-spoiler-show-button.button= t('admin.statuses.media.show') | ||||
|         .media-spoiler-hide-button.button= t('admin.statuses.media.hide') | ||||
|     - @statuses.each do |status| | ||||
|       .account-status{ data: { id: status.id } } | ||||
|         .batch-checkbox | ||||
|           = f.check_box :status_ids, { multiple: true, include_hidden: false }, status.id | ||||
|         .activity-stream.activity-stream-headless | ||||
|           .entry= render 'stream_entries/simple_status', status: status | ||||
|         .account-status__actions | ||||
|           - unless status.media_attachments.empty? | ||||
|             = link_to admin_account_status_path(@account.id, status, current_params.merge(status: { sensitive: !status.sensitive })), method: :patch, class: 'icon-button nsfw-button', title: t("admin.reports.nsfw.#{!status.sensitive}") do | ||||
|               = fa_icon status.sensitive? ? 'eye' : 'eye-slash' | ||||
|           = link_to admin_account_status_path(@account.id, status), method: :delete, class: 'icon-button trash-button', title: t('admin.reports.delete'), data: { confirm: t('admin.reports.are_you_sure') }, remote: true do | ||||
|             = fa_icon 'trash' | ||||
|       .batch-table__toolbar__actions | ||||
|         = f.button safe_join([fa_icon('eye-slash'), t('admin.statuses.batch.nsfw_on')]), name: :nsfw_on, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } | ||||
|         = f.button safe_join([fa_icon('eye'), t('admin.statuses.batch.nsfw_off')]), name: :nsfw_off, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } | ||||
|         = f.button safe_join([fa_icon('trash'), t('admin.statuses.batch.delete')]), name: :delete, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } | ||||
|     .batch-table__body | ||||
|       = render partial: 'admin/reports/status', collection: @statuses, locals: { f: f } | ||||
|  | ||||
| = paginate @statuses | ||||
|  | ||||
		Reference in New Issue
	
	Block a user