Various fixes and improvements (#12878)
* Fix unused role routes being generated * Remove unused JavaScript code * Refactor filters code to be DRYer * Fix `.count == 0` comparisons to `.empty?` in views * Fix filters in viewsgh/stable
parent
06f6995860
commit
6feafb8802
|
@ -109,21 +109,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_params
|
def filter_params
|
||||||
params.permit(
|
params.slice(*AccountFilter::KEYS).permit(*AccountFilter::KEYS)
|
||||||
:local,
|
|
||||||
:remote,
|
|
||||||
:by_domain,
|
|
||||||
:active,
|
|
||||||
:pending,
|
|
||||||
:disabled,
|
|
||||||
:silenced,
|
|
||||||
:suspended,
|
|
||||||
:username,
|
|
||||||
:display_name,
|
|
||||||
:email,
|
|
||||||
:ip,
|
|
||||||
:staff
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,7 +48,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_params
|
def filter_params
|
||||||
params.slice(:local, :remote, :by_domain, :shortcode, :page).permit(:local, :remote, :by_domain, :shortcode, :page)
|
params.slice(:page, *CustomEmojiFilter::KEYS).permit(:page, *CustomEmojiFilter::KEYS)
|
||||||
end
|
end
|
||||||
|
|
||||||
def action_from_button
|
def action_from_button
|
||||||
|
|
|
@ -62,7 +62,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_params
|
def filter_params
|
||||||
params.permit(:limited, :by_domain)
|
params.slice(*InstanceFilter::KEYS).permit(*InstanceFilter::KEYS)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,7 +47,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_params
|
def filter_params
|
||||||
params.permit(:available, :expired)
|
params.slice(*InviteFilter::KEYS).permit(*InviteFilter::KEYS)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,12 +52,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_params
|
def filter_params
|
||||||
params.permit(
|
params.slice(*ReportFilter::KEYS).permit(*ReportFilter::KEYS)
|
||||||
:account_id,
|
|
||||||
:resolved,
|
|
||||||
:target_account_id,
|
|
||||||
:by_target_domain
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_report
|
def set_report
|
||||||
|
|
|
@ -73,7 +73,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_params
|
def filter_params
|
||||||
params.slice(:directory, :reviewed, :unreviewed, :pending_review, :page, :popular, :active, :name).permit(:directory, :reviewed, :unreviewed, :pending_review, :page, :popular, :active, :name)
|
params.slice(:page, *TagFilter::KEYS).permit(:page, *TagFilter::KEYS)
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_params
|
def tag_params
|
||||||
|
|
|
@ -85,7 +85,7 @@ class RelationshipsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_params
|
def current_params
|
||||||
params.slice(:page, :status, :relationship, :by_domain, :activity, :order).permit(:page, :status, :relationship, :by_domain, :activity, :order)
|
params.slice(:page, *RelationshipFilter::KEYS).permit(:page, *RelationshipFilter::KEYS)
|
||||||
end
|
end
|
||||||
|
|
||||||
def action_from_button
|
def action_from_button
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Admin::FilterHelper
|
module Admin::FilterHelper
|
||||||
ACCOUNT_FILTERS = %i(local remote by_domain active pending silenced suspended username display_name email ip staff).freeze
|
FILTERS = [
|
||||||
REPORT_FILTERS = %i(resolved account_id target_account_id by_target_domain).freeze
|
AccountFilter::KEYS,
|
||||||
INVITE_FILTER = %i(available expired).freeze
|
CustomEmojiFilter::KEYS,
|
||||||
CUSTOM_EMOJI_FILTERS = %i(local remote by_domain shortcode).freeze
|
ReportFilter::KEYS,
|
||||||
TAGS_FILTERS = %i(directory reviewed unreviewed pending_review popular active name).freeze
|
TagFilter::KEYS,
|
||||||
INSTANCES_FILTERS = %i(limited by_domain).freeze
|
InstanceFilter::KEYS,
|
||||||
FOLLOWERS_FILTERS = %i(relationship status by_domain activity order).freeze
|
InviteFilter::KEYS,
|
||||||
|
RelationshipFilter::KEYS,
|
||||||
FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS + INVITE_FILTER + CUSTOM_EMOJI_FILTERS + TAGS_FILTERS + INSTANCES_FILTERS + FOLLOWERS_FILTERS
|
].flatten.freeze
|
||||||
|
|
||||||
def filter_link_to(text, link_to_params, link_class_params = link_to_params)
|
def filter_link_to(text, link_to_params, link_class_params = link_to_params)
|
||||||
new_url = filtered_url_for(link_to_params)
|
new_url = filtered_url_for(link_to_params)
|
||||||
|
|
|
@ -142,15 +142,6 @@ function main() {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
delegate(document, '.blocks-table button.icon-button', 'click', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
const classList = this.firstElementChild.classList;
|
|
||||||
classList.toggle('fa-chevron-down');
|
|
||||||
classList.toggle('fa-chevron-up');
|
|
||||||
this.parentElement.parentElement.nextElementSibling.classList.toggle('hidden');
|
|
||||||
});
|
|
||||||
|
|
||||||
delegate(document, '.modal-button', 'click', e => {
|
delegate(document, '.modal-button', 'click', e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,21 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AccountFilter
|
class AccountFilter
|
||||||
|
KEYS = %i(
|
||||||
|
local
|
||||||
|
remote
|
||||||
|
by_domain
|
||||||
|
active
|
||||||
|
pending
|
||||||
|
silenced
|
||||||
|
suspended
|
||||||
|
username
|
||||||
|
display_name
|
||||||
|
email
|
||||||
|
ip
|
||||||
|
staff
|
||||||
|
).freeze
|
||||||
|
|
||||||
attr_reader :params
|
attr_reader :params
|
||||||
|
|
||||||
def initialize(params)
|
def initialize(params)
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CustomEmojiFilter
|
class CustomEmojiFilter
|
||||||
|
KEYS = %i(
|
||||||
|
local
|
||||||
|
remote
|
||||||
|
by_domain
|
||||||
|
shortcode
|
||||||
|
).freeze
|
||||||
|
|
||||||
attr_reader :params
|
attr_reader :params
|
||||||
|
|
||||||
def initialize(params)
|
def initialize(params)
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class InstanceFilter
|
class InstanceFilter
|
||||||
|
KEYS = %i(
|
||||||
|
limited
|
||||||
|
by_domain
|
||||||
|
).freeze
|
||||||
|
|
||||||
attr_reader :params
|
attr_reader :params
|
||||||
|
|
||||||
def initialize(params)
|
def initialize(params)
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class InviteFilter
|
class InviteFilter
|
||||||
|
KEYS = %i(
|
||||||
|
available
|
||||||
|
expired
|
||||||
|
).freeze
|
||||||
|
|
||||||
attr_reader :params
|
attr_reader :params
|
||||||
|
|
||||||
def initialize(params)
|
def initialize(params)
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class RelationshipFilter
|
||||||
|
KEYS = %i(
|
||||||
|
relationship
|
||||||
|
status
|
||||||
|
by_domain
|
||||||
|
activity
|
||||||
|
order
|
||||||
|
).freeze
|
||||||
|
end
|
|
@ -1,6 +1,13 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ReportFilter
|
class ReportFilter
|
||||||
|
KEYS = %i(
|
||||||
|
resolved
|
||||||
|
account_id
|
||||||
|
target_account_id
|
||||||
|
by_target_domain
|
||||||
|
).freeze
|
||||||
|
|
||||||
attr_reader :params
|
attr_reader :params
|
||||||
|
|
||||||
def initialize(params)
|
def initialize(params)
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class TagFilter
|
class TagFilter
|
||||||
|
KEYS = %i(
|
||||||
|
directory
|
||||||
|
reviewed
|
||||||
|
unreviewed
|
||||||
|
pending_review
|
||||||
|
popular
|
||||||
|
active
|
||||||
|
name
|
||||||
|
).freeze
|
||||||
|
|
||||||
attr_reader :params
|
attr_reader :params
|
||||||
|
|
||||||
def initialize(params)
|
def initialize(params)
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
= 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
|
||||||
- Admin::FilterHelper::ACCOUNT_FILTERS.each do |key|
|
- AccountFilter::KEYS.each do |key|
|
||||||
- if params[key].present?
|
- if params[key].present?
|
||||||
= hidden_field_tag key, params[key]
|
= hidden_field_tag key, params[key]
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
= form_tag admin_custom_emojis_url, method: 'GET', class: 'simple_form' do
|
= form_tag admin_custom_emojis_url, method: 'GET', class: 'simple_form' do
|
||||||
.fields-group
|
.fields-group
|
||||||
- Admin::FilterHelper::CUSTOM_EMOJI_FILTERS.each do |key|
|
- CustomEmojiFilter::KEYS.each do |key|
|
||||||
= hidden_field_tag key, params[key] if params[key].present?
|
= hidden_field_tag key, params[key] if params[key].present?
|
||||||
|
|
||||||
- %i(shortcode by_domain).each do |key|
|
- %i(shortcode by_domain).each do |key|
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
= form_for(@form, url: batch_admin_custom_emojis_path) do |f|
|
= form_for(@form, url: batch_admin_custom_emojis_path) do |f|
|
||||||
= hidden_field_tag :page, params[:page] || 1
|
= hidden_field_tag :page, params[:page] || 1
|
||||||
|
|
||||||
- Admin::FilterHelper::CUSTOM_EMOJI_FILTERS.each do |key|
|
- CustomEmojiFilter::KEYS.each do |key|
|
||||||
= hidden_field_tag key, params[key] if params[key].present?
|
= hidden_field_tag key, params[key] if params[key].present?
|
||||||
|
|
||||||
.batch-table
|
.batch-table
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
- content_for :heading_actions do
|
- content_for :heading_actions do
|
||||||
= link_to t('admin.email_domain_blocks.add_new'), new_admin_email_domain_block_path, class: 'button'
|
= link_to t('admin.email_domain_blocks.add_new'), new_admin_email_domain_block_path, class: 'button'
|
||||||
|
|
||||||
- if @email_domain_blocks.count == 0
|
- if @email_domain_blocks.empty?
|
||||||
%div.muted-hint.center-text=t 'admin.email_domain_blocks.empty'
|
%div.muted-hint.center-text=t 'admin.email_domain_blocks.empty'
|
||||||
- else
|
- else
|
||||||
.table-wrapper
|
.table-wrapper
|
||||||
|
|
|
@ -19,9 +19,8 @@
|
||||||
- unless whitelist_mode?
|
- unless whitelist_mode?
|
||||||
= form_tag admin_instances_url, method: 'GET', class: 'simple_form' do
|
= form_tag admin_instances_url, method: 'GET', class: 'simple_form' do
|
||||||
.fields-group
|
.fields-group
|
||||||
- Admin::FilterHelper::INSTANCES_FILTERS.each do |key|
|
- InstanceFilter::KEYS.each do |key|
|
||||||
- if params[key].present?
|
= hidden_field_tag key, params[key] if params[key].present?
|
||||||
= hidden_field_tag key, params[key]
|
|
||||||
|
|
||||||
- %i(by_domain).each do |key|
|
- %i(by_domain).each do |key|
|
||||||
.input.string.optional
|
.input.string.optional
|
||||||
|
|
|
@ -10,9 +10,8 @@
|
||||||
|
|
||||||
= form_tag admin_reports_url, method: 'GET', class: 'simple_form' do
|
= form_tag admin_reports_url, method: 'GET', class: 'simple_form' do
|
||||||
.fields-group
|
.fields-group
|
||||||
- Admin::FilterHelper::REPORT_FILTERS.each do |key|
|
- ReportFilter::KEYS.each do |key|
|
||||||
- if params[key].present?
|
= hidden_field_tag key, params[key] if params[key].present?
|
||||||
= hidden_field_tag key, params[key]
|
|
||||||
|
|
||||||
- %i(by_target_domain).each do |key|
|
- %i(by_target_domain).each do |key|
|
||||||
.input.string.optional
|
.input.string.optional
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
= form_tag admin_tags_url, method: 'GET', class: 'simple_form' do
|
= form_tag admin_tags_url, method: 'GET', class: 'simple_form' do
|
||||||
.fields-group
|
.fields-group
|
||||||
- Admin::FilterHelper::TAGS_FILTERS.each do |key|
|
- TagFilter::KEYS.each do |key|
|
||||||
= hidden_field_tag key, params[key] if params[key].present?
|
= hidden_field_tag key, params[key] if params[key].present?
|
||||||
|
|
||||||
- %i(name).each do |key|
|
- %i(name).each do |key|
|
||||||
|
@ -43,9 +43,8 @@
|
||||||
|
|
||||||
= form_for(@form, url: batch_admin_tags_path) do |f|
|
= form_for(@form, url: batch_admin_tags_path) do |f|
|
||||||
= hidden_field_tag :page, params[:page] || 1
|
= hidden_field_tag :page, params[:page] || 1
|
||||||
= hidden_field_tag :name, params[:name] if params[:name].present?
|
|
||||||
|
|
||||||
- Admin::FilterHelper::TAGS_FILTERS.each do |key|
|
- TagFilter::KEYS.each do |key|
|
||||||
= hidden_field_tag key, params[key] if params[key].present?
|
= hidden_field_tag key, params[key] if params[key].present?
|
||||||
|
|
||||||
.batch-table.optional
|
.batch-table.optional
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
- content_for :heading_actions do
|
- content_for :heading_actions do
|
||||||
= link_to t('filters.new.title'), new_filter_path, class: 'button'
|
= link_to t('filters.new.title'), new_filter_path, class: 'button'
|
||||||
|
|
||||||
- if @filters.count == 0
|
- if @filters.empty?
|
||||||
%div.muted-hint.center-text= t 'filters.index.empty'
|
%div.muted-hint.center-text= t 'filters.index.empty'
|
||||||
- else
|
- else
|
||||||
.table-wrapper
|
.table-wrapper
|
||||||
|
|
|
@ -33,10 +33,9 @@
|
||||||
|
|
||||||
= form_for(@form, url: relationships_path, method: :patch) do |f|
|
= form_for(@form, url: relationships_path, method: :patch) do |f|
|
||||||
= hidden_field_tag :page, params[:page] || 1
|
= hidden_field_tag :page, params[:page] || 1
|
||||||
= hidden_field_tag :relationship, params[:relationship]
|
|
||||||
= hidden_field_tag :status, params[:status]
|
- RelationshipFilter::KEYS.each do |key|
|
||||||
= hidden_field_tag :activity, params[:activity]
|
= hidden_field_tag key, params[key] if params[key].present?
|
||||||
= hidden_field_tag :order, params[:order]
|
|
||||||
|
|
||||||
.batch-table
|
.batch-table
|
||||||
.batch-table__toolbar
|
.batch-table__toolbar
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
- content_for :heading_actions do
|
- content_for :heading_actions do
|
||||||
= link_to t('doorkeeper.applications.index.new'), new_settings_application_path, class: 'button'
|
= link_to t('doorkeeper.applications.index.new'), new_settings_application_path, class: 'button'
|
||||||
|
|
||||||
- if @applications.count == 0
|
- if @applications.empty?
|
||||||
%div.muted-hint.center-text=t 'doorkeeper.applications.index.empty'
|
%div.muted-hint.center-text=t 'doorkeeper.applications.index.empty'
|
||||||
- else
|
- else
|
||||||
.table-wrapper
|
.table-wrapper
|
||||||
|
|
|
@ -231,7 +231,7 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resource :role do
|
resource :role, only: [] do
|
||||||
member do
|
member do
|
||||||
post :promote
|
post :promote
|
||||||
post :demote
|
post :demote
|
||||||
|
|
Reference in New Issue