5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 10:06:23 +00:00

feat: filtros comunes

This commit is contained in:
f 2024-03-05 16:24:16 -03:00
parent 2df9f721cd
commit 0da69de6a7
No known key found for this signature in database
10 changed files with 30 additions and 13 deletions

View file

@ -3,6 +3,7 @@
# Gestiona la cola de moderación de actores # Gestiona la cola de moderación de actores
class ActorModerationsController < ApplicationController class ActorModerationsController < ApplicationController
include ModerationConcern include ModerationConcern
include ModerationFiltersConcern
ActorModeration.events.each do |actor_event| ActorModeration.events.each do |actor_event|
define_method(actor_event) do define_method(actor_event) do
@ -20,7 +21,7 @@ class ActorModerationsController < ApplicationController
# Ver el perfil remoto # Ver el perfil remoto
def show def show
@remote_profile = actor_moderation.actor.content @remote_profile = actor_moderation.actor.content
@moderation_queue = site.activity_pubs.where(actor_id: actor_moderation.actor_id) @moderation_queue = rubanok_process(site.activity_pubs.where(actor_id: actor_moderation.actor_id), with: ActivityPubProcessor)
end end
def action_on_several def action_on_several

View file

@ -0,0 +1,15 @@
# frozen_string_literal: true
module ModerationFiltersConcern
extend ActiveSupport::Concern
included do
before_action :store_filters_in_session!, only: %i[index show]
private
def store_filters_in_session!
session[:moderation_queue_filters] = params.permit(:instance_state, :actor_state, :activity_pub_state)
end
end
end

View file

@ -2,10 +2,10 @@
# Cola de moderación de ActivityPub # Cola de moderación de ActivityPub
class ModerationQueueController < ApplicationController class ModerationQueueController < ApplicationController
include ModerationFiltersConcern
# Cola de moderación viendo todo el sitio # Cola de moderación viendo todo el sitio
def index def index
session[:moderation_queue_filters] = params.permit(:state, :actor_state, :activity_pub_state)
# @todo cambiar el estado por query # @todo cambiar el estado por query
@activity_pubs = site.activity_pubs @activity_pubs = site.activity_pubs
@instance_moderations = rubanok_process(site.instance_moderations, with: InstanceModerationProcessor) @instance_moderations = rubanok_process(site.instance_moderations, with: InstanceModerationProcessor)

View file

@ -6,7 +6,7 @@ class InstanceModerationProcessor < Rubanok::Processor
raw.includes(:instance).order('activity_pub_instances.hostname') raw.includes(:instance).order('activity_pub_instances.hostname')
end end
map :state, activate_always: true do |state: 'paused'| map :instance_state, activate_always: true do |instance_state: 'paused'|
raw.where(aasm_state: state) raw.where(aasm_state: instance_state)
end end
end end

View file

@ -1,4 +1,4 @@
- ActivityPub.states.each do |state| - ActivityPub.states.each do |state|
= render 'components/dropdown_item', = render 'components/dropdown_item',
text: t(".submenu_#{state}", count: activity_pubs.unscope(where: :aasm_state).public_send(state).count), text: t(".submenu_#{state}", count: activity_pubs.unscope(where: :aasm_state).public_send(state).count),
path: site_moderation_queue_path(filter_states(activity_pub_state: state)) path: filter_states(activity_pub_state: state)

View file

@ -1,4 +1,4 @@
-# -#
@param :text [String] Contenido del link @param :text [String] Contenido del link
@param :path [String] Link @param :path [String,Hash] Link
= link_to text, path, class: 'dropdown-item', data: { target: 'dropdown.item' } = link_to text, path, class: 'dropdown-item', data: { target: 'dropdown.item' }

View file

@ -6,4 +6,4 @@
= render 'components/instances_checked_submenu', form_id: form_id, current_state: current_state = render 'components/instances_checked_submenu', form_id: form_id, current_state: current_state
= render 'components/dropdown', text: t('.text_show') do = render 'components/dropdown', text: t('.text_show') do
= render 'components/instances_show_submenu', site: site = render 'components/instances_show_submenu', instance_moderations: instance_moderations

View file

@ -1,3 +1,4 @@
= render 'components/dropdown_item', text: t('.submenu_paused', count: site.instance_moderations.paused.count), path: site_moderation_queue_path(state: 'paused') - InstanceModeration.states.each do |state|
= render 'components/dropdown_item', text: t('.submenu_allowed', count: site.instance_moderations.allowed.count), path: site_moderation_queue_path(state: 'allowed') = render 'components/dropdown_item',
= render 'components/dropdown_item', text: t('.submenu_blocked', count: site.instance_moderations.blocked.count), path: site_moderation_queue_path(state: 'blocked') text: t(".submenu_#{state}", count: instance_moderations.unscope(where: :aasm_state).public_send(state).count),
path: filter_states(instance_state: state)

View file

@ -1,4 +1,4 @@
- ActorModeration.states.each do |actor_state| - ActorModeration.states.each do |actor_state|
= render 'components/dropdown_item', = render 'components/dropdown_item',
text: t(".submenu_#{actor_state}", count: actor_moderations.unscope(where: :aasm_state).public_send(actor_state).count), text: t(".submenu_#{actor_state}", count: actor_moderations.unscope(where: :aasm_state).public_send(actor_state).count),
path: site_moderation_queue_path(filter_states(actor_state: actor_state)) path: filter_states(actor_state: actor_state)

View file

@ -7,7 +7,7 @@
= render 'components/select_all', id: 'instances', form_id: form_id = render 'components/select_all', id: 'instances', form_id: form_id
.col-11 .col-11
-# Filtros -# Filtros
= render 'components/instances_filters', site: site, form_id: form_id = render 'components/instances_filters', instance_moderations: instance_moderations, form_id: form_id
.col-12 .col-12
- if instance_moderations.count.zero? - if instance_moderations.count.zero?