Add toggle for moderation view
This commit is contained in:
parent
a857887398
commit
1b09d51443
|
@ -66,6 +66,11 @@ class ModerationController < ApplicationController
|
|||
render template: 'moderation/priority'
|
||||
end
|
||||
|
||||
def toggle_unmask
|
||||
session[:moderation_view] = !session[:moderation_view]
|
||||
redirect_back fallback_location: root_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def list_reports(type:, last_id:, size: nil)
|
||||
|
|
|
@ -42,6 +42,10 @@ module ApplicationHelper
|
|||
false
|
||||
end
|
||||
|
||||
def moderation_view?
|
||||
current_user.mod? && session[:moderation_view] == true
|
||||
end
|
||||
|
||||
def rails_admin_path_for_resource(resource)
|
||||
[rails_admin_path, resource.model_name.param_key, resource.id].join("/")
|
||||
end
|
||||
|
|
|
@ -28,6 +28,14 @@
|
|||
Announcements
|
||||
.dropdown-divider
|
||||
- if current_user.mod?
|
||||
- if moderation_view?
|
||||
= link_to moderation_toggle_unmask_path, method: :post, class: "dropdown-item" do
|
||||
%i.fa.fa-toggle-on
|
||||
Disable Moderation View
|
||||
- else
|
||||
= link_to moderation_toggle_unmask_path, method: :post, class: "dropdown-item" do
|
||||
%i.fa.fa-toggle-off
|
||||
Enable Moderation View
|
||||
%a.dropdown-item{ href: moderation_path }
|
||||
%i.fa.fa-fw.fa-gavel
|
||||
= t("views.navigation.moderation")
|
||||
|
|
|
@ -22,6 +22,14 @@
|
|||
Announcements
|
||||
.dropdown-divider
|
||||
- if current_user.mod?
|
||||
- if moderation_view?
|
||||
= link_to moderation_toggle_unmask_path, method: :post, class: "dropdown-item" do
|
||||
%i.fa.fa-toggle-on
|
||||
Disable Moderation View
|
||||
- else
|
||||
= link_to moderation_toggle_unmask_path, method: :post, class: "dropdown-item" do
|
||||
%i.fa.fa-toggle-off
|
||||
Enable Moderation View
|
||||
%a.dropdown-item{ href: moderation_path }
|
||||
%i.fa.fa-fw.fa-gavel
|
||||
= t("views.navigation.moderation")
|
||||
|
|
|
@ -22,6 +22,7 @@ Rails.application.routes.draw do
|
|||
# Moderation panel
|
||||
constraints ->(req) { req.env["warden"].authenticate?(scope: :user) &&
|
||||
req.env["warden"].user.mod? } do
|
||||
match '/moderation/unmask', to: 'moderation#toggle_unmask', via: :post, as: :moderation_toggle_unmask
|
||||
match '/moderation/priority(/:user_id)', to: 'moderation#priority', via: :get, as: :moderation_priority
|
||||
match '/moderation/ip/:user_id', to: 'moderation#ip', via: :get, as: :moderation_ip
|
||||
match '/moderation(/:type)', to: 'moderation#index', via: :get, as: :moderation, defaults: {type: 'all'}
|
||||
|
|
Loading…
Reference in New Issue