From 1c113fd72df18999de1d6f09fa3790dd1f715506 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 16 Mar 2019 11:23:22 +0100 Subject: Add relationship manager UI (#10268) --- app/views/relationships/_account.html.haml | 20 ++++++++++++++ app/views/relationships/show.html.haml | 43 ++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 app/views/relationships/_account.html.haml create mode 100644 app/views/relationships/show.html.haml (limited to 'app/views/relationships') diff --git a/app/views/relationships/_account.html.haml b/app/views/relationships/_account.html.haml new file mode 100644 index 000000000..6c22deb51 --- /dev/null +++ b/app/views/relationships/_account.html.haml @@ -0,0 +1,20 @@ +.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.batch-table__row__content--unpadded + %table.accounts-table + %tbody + %tr + %td= account_link_to account + %td.accounts-table__count.optional + = number_to_human account.statuses_count, strip_insignificant_zeros: true + %small= t('accounts.posts', count: account.statuses_count).downcase + %td.accounts-table__count.optional + = number_to_human account.followers_count, strip_insignificant_zeros: true + %small= t('accounts.followers', count: account.followers_count).downcase + %td.accounts-table__count + - if 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 + \- + %small= t('accounts.last_active') diff --git a/app/views/relationships/show.html.haml b/app/views/relationships/show.html.haml new file mode 100644 index 000000000..33a43f1a8 --- /dev/null +++ b/app/views/relationships/show.html.haml @@ -0,0 +1,43 @@ +- content_for :page_title do + = t('settings.relationships') + +- content_for :header_tags do + = javascript_pack_tag 'admin', integrity: true, async: true, crossorigin: 'anonymous' + +.filters + .filter-subset + %strong= t 'relationships.relationship' + %ul + %li= filter_link_to t('accounts.following', count: current_account.following_count), relationship: nil + %li= filter_link_to t('accounts.followers', count: current_account.followers_count), relationship: 'followed_by' + %li= filter_link_to t('relationships.mutual'), relationship: 'mutual' + + .filter-subset + %strong= t 'relationships.status' + %ul + %li= filter_link_to t('generic.all'), status: nil + %li= filter_link_to t('relationships.active'), status: 'active' + %li= filter_link_to t('relationships.abandoned'), status: 'abandoned' + += form_for(@form, url: relationships_path, method: :patch) do |f| + = hidden_field_tag :page, params[:page] || 1 + = hidden_field_tag :relationship, params[:relationship] + = hidden_field_tag :status, params[:status] + + .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('user-times'), t('relationships.remove_selected_follows')]), name: :unfollow, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } unless followed_by_relationship? + + = f.button safe_join([fa_icon('trash'), t('relationships.remove_selected_followers')]), name: :remove_from_followers, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } unless following_relationship? + + = f.button safe_join([fa_icon('trash'), t('relationships.remove_selected_domains')]), name: :block_domains, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } if followed_by_relationship? + .batch-table__body + - if @accounts.empty? + = nothing_here 'nothing-here--under-tabs' + - else + = render partial: 'account', collection: @accounts, locals: { f: f } + += paginate @accounts -- cgit From 8e5d72dba89e8d2c4ecb8aa13827aabbcd92b633 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Sat, 16 Mar 2019 14:26:14 +0100 Subject: Fix relationships controller/view wrt. glitch-soc theming engine --- app/controllers/relationships_controller.rb | 5 +++++ app/views/relationships/show.html.haml | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'app/views/relationships') diff --git a/app/controllers/relationships_controller.rb b/app/controllers/relationships_controller.rb index e6dd65e44..af91cb658 100644 --- a/app/controllers/relationships_controller.rb +++ b/app/controllers/relationships_controller.rb @@ -5,6 +5,7 @@ class RelationshipsController < ApplicationController before_action :authenticate_user! before_action :set_accounts, only: :show + before_action :set_pack before_action :set_body_classes helper_method :following_relationship?, :followed_by_relationship?, :mutual_relationship? @@ -95,4 +96,8 @@ class RelationshipsController < ApplicationController def set_body_classes @body_classes = 'admin' end + + def set_pack + use_pack 'admin' + end end diff --git a/app/views/relationships/show.html.haml b/app/views/relationships/show.html.haml index 33a43f1a8..94972026a 100644 --- a/app/views/relationships/show.html.haml +++ b/app/views/relationships/show.html.haml @@ -1,9 +1,6 @@ - content_for :page_title do = t('settings.relationships') -- content_for :header_tags do - = javascript_pack_tag 'admin', integrity: true, async: true, crossorigin: 'anonymous' - .filters .filter-subset %strong= t 'relationships.relationship' -- cgit From b8e4c85e69443abb141e666b36606056e86e116c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 18 Mar 2019 03:53:17 +0100 Subject: Add dormant filter to relationship manager, rename other filters (#10308) Rename "abandoned" to "moved", and "active" to "primary" --- app/controllers/relationships_controller.rb | 19 ++++++++++++------- app/helpers/admin/filter_helper.rb | 2 +- app/views/relationships/show.html.haml | 11 +++++++++-- config/locales/en.yml | 6 ++++-- 4 files changed, 26 insertions(+), 12 deletions(-) (limited to 'app/views/relationships') diff --git a/app/controllers/relationships_controller.rb b/app/controllers/relationships_controller.rb index e6dd65e44..84cb178a6 100644 --- a/app/controllers/relationships_controller.rb +++ b/app/controllers/relationships_controller.rb @@ -31,17 +31,18 @@ class RelationshipsController < ApplicationController def relationships_scope scope = begin if following_relationship? - current_account.following.includes(:account_stat) + current_account.following.joins(:account_stat) else - current_account.followers.includes(:account_stat) + current_account.followers.joins(:account_stat) end end scope.merge!(Follow.recent) scope.merge!(mutual_relationship_scope) if mutual_relationship? - scope.merge!(abandoned_account_scope) if params[:status] == 'abandoned' - scope.merge!(active_account_scope) if params[:status] == 'active' + scope.merge!(moved_account_scope) if params[:status] == 'moved' + scope.merge!(primary_account_scope) if params[:status] == 'primary' scope.merge!(by_domain_scope) if params[:by_domain].present? + scope.merge!(dormant_account_scope) if params[:activity] == 'dormant' scope end @@ -50,14 +51,18 @@ class RelationshipsController < ApplicationController Account.where(id: current_account.following) end - def abandoned_account_scope + def moved_account_scope Account.where.not(moved_to_account_id: nil) end - def active_account_scope + def primary_account_scope Account.where(moved_to_account_id: nil) end + def dormant_account_scope + AccountStat.where(last_status_at: nil).or(AccountStat.where(AccountStat.arel_table[:last_status_at].lt(1.month.ago))) + end + def by_domain_scope Account.where(domain: params[:by_domain]) end @@ -79,7 +84,7 @@ class RelationshipsController < ApplicationController end def current_params - params.slice(:page, :status, :relationship, :by_domain).permit(:page, :status, :relationship, :by_domain) + params.slice(:page, :status, :relationship, :by_domain, :activity).permit(:page, :status, :relationship, :by_domain, :activity) end def action_from_button diff --git a/app/helpers/admin/filter_helper.rb b/app/helpers/admin/filter_helper.rb index 09a356296..4fd36ef42 100644 --- a/app/helpers/admin/filter_helper.rb +++ b/app/helpers/admin/filter_helper.rb @@ -7,7 +7,7 @@ module Admin::FilterHelper CUSTOM_EMOJI_FILTERS = %i(local remote by_domain shortcode).freeze TAGS_FILTERS = %i(hidden).freeze INSTANCES_FILTERS = %i(limited by_domain).freeze - FOLLOWERS_FILTERS = %i(relationship status by_domain).freeze + FOLLOWERS_FILTERS = %i(relationship status by_domain activity).freeze FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS + INVITE_FILTER + CUSTOM_EMOJI_FILTERS + TAGS_FILTERS + INSTANCES_FILTERS + FOLLOWERS_FILTERS diff --git a/app/views/relationships/show.html.haml b/app/views/relationships/show.html.haml index 33a43f1a8..63745119a 100644 --- a/app/views/relationships/show.html.haml +++ b/app/views/relationships/show.html.haml @@ -16,13 +16,20 @@ %strong= t 'relationships.status' %ul %li= filter_link_to t('generic.all'), status: nil - %li= filter_link_to t('relationships.active'), status: 'active' - %li= filter_link_to t('relationships.abandoned'), status: 'abandoned' + %li= filter_link_to t('relationships.primary'), status: 'primary' + %li= filter_link_to t('relationships.moved'), status: 'moved' + + .filter-subset + %strong= t 'relationships.activity' + %ul + %li= filter_link_to t('generic.all'), activity: nil + %li= filter_link_to t('relationships.dormant'), activity: 'dormant' = form_for(@form, url: relationships_path, method: :patch) do |f| = hidden_field_tag :page, params[:page] || 1 = hidden_field_tag :relationship, params[:relationship] = hidden_field_tag :status, params[:status] + = hidden_field_tag :activity, params[:activity] .batch-table .batch-table__toolbar diff --git a/config/locales/en.yml b/config/locales/en.yml index 4f9104eea..9f1081fb8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -751,9 +751,11 @@ en: publishing: Publishing web: Web relationships: - abandoned: Abandoned - active: Active + activity: Account activity + dormant: Dormant + moved: Moved mutual: Mutual + primary: Primary relationship: Relationship remove_selected_domains: Remove all followers from the selected domains remove_selected_followers: Remove selected followers -- cgit