Change admin accounts default sort to most recent (#8813)

remotes/1727458204337373841/tmp_refs/heads/signup-info-prompt
Eugen Rochko 2018-10-04 16:05:38 +02:00 committed by GitHub
parent 7fe137d2f7
commit e645ae9561
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 12 deletions

View File

@ -95,7 +95,7 @@ module Admin
:remote, :remote,
:by_domain, :by_domain,
:silenced, :silenced,
:recent, :alphabetic,
:suspended, :suspended,
:username, :username,
:display_name, :display_name,

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
module Admin::FilterHelper module Admin::FilterHelper
ACCOUNT_FILTERS = %i(local remote by_domain silenced suspended recent username display_name email ip staff).freeze ACCOUNT_FILTERS = %i(local remote by_domain silenced suspended alphabetic username display_name email ip staff).freeze
REPORT_FILTERS = %i(resolved account_id target_account_id).freeze REPORT_FILTERS = %i(resolved account_id target_account_id).freeze
INVITE_FILTER = %i(available expired).freeze INVITE_FILTER = %i(available expired).freeze
CUSTOM_EMOJI_FILTERS = %i(local remote by_domain shortcode).freeze CUSTOM_EMOJI_FILTERS = %i(local remote by_domain shortcode).freeze

View File

@ -8,7 +8,7 @@ class AccountFilter
end end
def results def results
scope = Account.alphabetic scope = Account.recent
params.each do |key, value| params.each do |key, value|
scope.merge!(scope_for(key, value)) if value.present? scope.merge!(scope_for(key, value)) if value.present?
@ -29,8 +29,8 @@ class AccountFilter
Account.where(domain: value) Account.where(domain: value)
when 'silenced' when 'silenced'
Account.silenced Account.silenced
when 'recent' when 'alphabetic'
Account.recent Account.reorder(nil).alphabetic
when 'suspended' when 'suspended'
Account.suspended Account.suspended
when 'username' when 'username'

View File

@ -38,8 +38,8 @@
.filter-subset .filter-subset
%strong= t('admin.accounts.order.title') %strong= t('admin.accounts.order.title')
%ul %ul
%li= filter_link_to t('admin.accounts.order.alphabetic'), recent: nil %li= filter_link_to t('admin.accounts.order.most_recent'), alphabetic: nil
%li= filter_link_to t('admin.accounts.order.most_recent'), recent: '1' %li= filter_link_to t('admin.accounts.order.alphabetic'), alphabetic: '1'
= form_tag admin_accounts_url, method: 'GET', class: 'simple_form' do = form_tag admin_accounts_url, method: 'GET', class: 'simple_form' do
.fields-group .fields-group

View File

@ -25,7 +25,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
expect(h[:remote]).to eq '1' expect(h[:remote]).to eq '1'
expect(h[:by_domain]).to eq 'domain' expect(h[:by_domain]).to eq 'domain'
expect(h[:silenced]).to eq '1' expect(h[:silenced]).to eq '1'
expect(h[:recent]).to eq '1' expect(h[:alphabetic]).to eq '1'
expect(h[:suspended]).to eq '1' expect(h[:suspended]).to eq '1'
expect(h[:username]).to eq 'username' expect(h[:username]).to eq 'username'
expect(h[:display_name]).to eq 'display name' expect(h[:display_name]).to eq 'display name'
@ -40,7 +40,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
remote: '1', remote: '1',
by_domain: 'domain', by_domain: 'domain',
silenced: '1', silenced: '1',
recent: '1', alphabetic: '1',
suspended: '1', suspended: '1',
username: 'username', username: 'username',
display_name: 'display name', display_name: 'display name',

View File

@ -2,10 +2,10 @@ require 'rails_helper'
describe AccountFilter do describe AccountFilter do
describe 'with empty params' do describe 'with empty params' do
it 'defaults to alphabetic account list' do it 'defaults to recent account list' do
filter = described_class.new({}) filter = described_class.new({})
expect(filter.results).to eq Account.alphabetic expect(filter.results).to eq Account.recent
end end
end end
@ -60,7 +60,7 @@ describe AccountFilter do
end end
describe 'that call account methods' do describe 'that call account methods' do
%i(local remote silenced recent suspended).each do |option| %i(local remote silenced alphabetic suspended).each do |option|
it "delegates the #{option} option" do it "delegates the #{option} option" do
allow(Account).to receive(option).and_return(Account.none) allow(Account).to receive(option).and_return(Account.none)
filter = described_class.new({ option => true }) filter = described_class.new({ option => true })