Skip to content
Open
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
85dc3a2
Add moderator tools to user header
luap42 Feb 5, 2022
012f11b
Implement sidebar infrastructure for new mod tools
luap42 Feb 5, 2022
430b3f2
Apply new theme to existing mod pages
luap42 Feb 5, 2022
991381c
Add deletion entry
luap42 Feb 5, 2022
73f7e97
Add dashboard in UMT
luap42 Feb 5, 2022
6522be2
Add FA icons to UMT sidebar
luap42 Feb 5, 2022
d55d258
mod_destroy
luap42 Feb 5, 2022
b5a07bd
Implement clearing user profiles
luap42 Feb 5, 2022
40d1d9b
Add skull (back?)
luap42 Feb 5, 2022
47f9f6c
Add flags stat to user mod db
luap42 Feb 5, 2022
dc66326
Improve logs
luap42 Feb 5, 2022
80539a0
Rubocop :)
luap42 Feb 5, 2022
f424561
Improve log (better scanability and space usage)
luap42 Feb 17, 2022
ffee010
chore: General spelling fixes
sau226 May 20, 2022
07a5f9b
Undo unintended change from previous commit
trichoplax Jun 10, 2026
1335a52
Remove redundant space
trichoplax Jun 10, 2026
e74b287
Drop commas and keep to 140 characters per line
trichoplax Feb 16, 2023
ee45ab4
Remove 'destroy user' from routes and user interface
trichoplax Aug 29, 2023
66b1a99
Remove confusing development-only in joke from fail-ban interface
trichoplax Oct 25, 2023
edea494
Rename mod tools subsection to avoid Codidact-specific naming
trichoplax Oct 25, 2023
aec6c0a
Split user mod tools sections and remove Codidact specific wording
trichoplax Jun 7, 2024
769f6c8
Use 'failban' rather than 'hellban' throughout code for consistency
trichoplax Jun 7, 2024
7c8ebc4
Improve wording of user mod tools page intro message
trichoplax Jun 27, 2024
3e25274
Make impersonate section of user mod tools show correct side panels
trichoplax Jun 27, 2024
5540e14
Make user mod tools tab remain highlighted when switching sections
trichoplax Jun 27, 2024
1d139e4
Make 'without_sidebar' the default layout for the users controller
trichoplax Apr 24, 2026
b1e303f
Add missing do block (thanks Rubocop!)
trichoplax Apr 24, 2026
3d1eb5b
Remove expand buttons in mod warning log
trichoplax Apr 27, 2026
18d3c0c
Restore accidentally removed widget body div
trichoplax Jun 11, 2026
0a601df
Only render once in impersonate method
trichoplax May 15, 2026
380cfe0
Avoid separate views for desktop and mobile mod tools lists
trichoplax May 24, 2026
9ca27f7
Restore new method names and formatting lost in previous cherry-pick …
trichoplax Jun 11, 2026
fabb912
Match left panel layout change in mod tools to right panel in other p…
trichoplax May 26, 2026
a043484
Fix old method names and formatting introduced by cherry pick commit
trichoplax Jun 11, 2026
02358d2
Add temporary CSS variable for mod tools
trichoplax May 26, 2026
a08a0b4
Use new moderator and admin methods on user model throughout
trichoplax Jun 11, 2026
5392192
Fix typo in variable name
trichoplax Jun 11, 2026
0e72d8f
Nest staff inside global admin inside admin for single widget style
trichoplax Jun 11, 2026
31f32b8
Remove unintentionally included profile clear and reset code
trichoplax Jun 12, 2026
fdefb4f
Fix test following change from hellban to failban
trichoplax Jun 12, 2026
4d5a0f6
Remove reference to not yet added mod reset profile page
trichoplax Jun 12, 2026
6905c22
Improve formatting and break up long lines
trichoplax Jun 13, 2026
9ed0dcb
Add missing newline at end of file
trichoplax Jun 15, 2026
1b89fa9
Remove reference to destroy methods that no longer exist
trichoplax Jun 15, 2026
4e4de5b
Tidy before_action lines in Users controller
trichoplax Jun 15, 2026
f2bc639
Include message count on Moderator Tools tab of user page
trichoplax Jun 15, 2026
a10d978
Reduce line lengths in full log code
trichoplax Jun 17, 2026
42e05c0
Reduce line lengths in mod delete view code
trichoplax Jun 17, 2026
e9ae8e7
Reduce line lengths in mod delete network account view code
trichoplax Jun 17, 2026
dcb9bcf
Reduce line lengths in failban view code
trichoplax Jun 17, 2026
330ce29
Reduce line lengths in mod privileges view code
trichoplax Jun 17, 2026
e55751d
Reduce line lengths users show view code
trichoplax Jun 17, 2026
8d87994
Reduce line lengths in impersonate view code
trichoplax Jun 17, 2026
366c03a
Reduce line lengths in admin setup view code
trichoplax Jun 17, 2026
e26b334
Reduce line lengths in application dashboard view code
trichoplax Jun 17, 2026
c40cf3e
Reduce line lengths in mod warning log view code
trichoplax Jun 17, 2026
bb931fd
Reduce line lengths in moderator user vote summary view code
trichoplax Jun 17, 2026
6802b0e
Reduce line lengths in pinned links form view code
trichoplax Jun 17, 2026
eb35782
Reduce line lengths in suggested edit show view code
trichoplax Jun 17, 2026
4c0209d
Reduce line lengths in users tabs view code
trichoplax Jun 17, 2026
1cc6520
Reduce line lengths in users mod view code
trichoplax Jun 17, 2026
74eff7b
Merge branch 'develop' into trichoplax/mod-tools-user-interface
trichoplax Jun 18, 2026
6df2733
Restore original wording for 'Feed to STAT'
trichoplax Jun 18, 2026
8dd55cb
Remove redundant comma and improve wording
trichoplax Jun 18, 2026
fb68b3e
Add helper user_mod_tools_tab_active?
trichoplax Jun 18, 2026
260dada
Formatting and usage improvements thanks to Rubocop
trichoplax Jun 18, 2026
19fa31d
Make user mod tools more specific about deleting community profile
trichoplax Jun 22, 2026
a512b4e
Improve wording of Delete Community Profile tab
trichoplax Jul 1, 2026
69387f7
Merge branch 'develop' into trichoplax/mod-tools-user-interface
trichoplax Jul 1, 2026
6540518
Make irreversible action warnings consistent on user mod tools pages
trichoplax Jul 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/assets/stylesheets/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ $screen-md: 780px;
$screen-lg: 992px;
$screen-xl: 1200px;

$mod-tools-medium-to-large-breakpoint: 768px !default;

// Colors
$key: #335;
$muted-text: #666;
Expand Down
6 changes: 5 additions & 1 deletion app/assets/stylesheets/tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

.tabs {
margin-bottom: 1em;
}

.tabs--push {
flex-grow: 1;
}
}
53 changes: 53 additions & 0 deletions app/assets/stylesheets/users.scss
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,56 @@ $sizes: (16, 32, 40, 48, 64, 128, 256);
}
}
}

.modtools--usercard {
padding: 0.5rem;
}

.modtools-tbl-noborder {
th {
border-bottom-width: 1px !important;
width: 150px;
}
}

.mod-warnings-clear-form { display: inline; }

.modtools--sidebar {
margin-right: 1rem;
}

.modtools--sidebar {
> .widget--header {
display: none;
}

label {
display: block;
}

#mobile-mod-tools-toggle {
+ .widget--body {
display: none;
}

&:checked + .widget--body {
display: block;
}
}
}

@media screen and (min-width: $mod-tools-medium-to-large-breakpoint) {
.modtools--sidebar {
> .widget--header {
display: block;
}

label {
display: none;
}

#mobile-mod-tools-toggle + .widget--body {
display: block;
}
}
}
10 changes: 6 additions & 4 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
class AdminController < ApplicationController
before_action :verify_admin, except: [:change_back, :verify_elevation]
before_action :verify_global_admin, only: [:admin_email, :send_admin_email, :new_site, :create_site, :setup,
:setup_save, :hellban, :all_email, :send_all_email]
:setup_save, :failban, :all_email, :send_all_email]
before_action :verify_developer, only: [:change_users, :impersonate]
before_action :set_user, only: [:change_users, :hellban, :impersonate]
before_action :set_user, only: [:change_users, :failban, :impersonate]

skip_before_action :check_if_warning_or_suspension_pending, only: [:change_back, :verify_elevation]

Expand Down Expand Up @@ -109,7 +109,7 @@ def audit_logs
@log_types = AuditLog.unscoped.select(:log_type).distinct.map(&:log_type) - ['user_annotation', 'user_history']
@event_types = AuditLog.unscoped.select(:event_type).distinct.map(&:event_type)

@logs = if current_user.is_global_admin
@logs = if current_user.global_admin?
AuditLog.unscoped.where.not(log_type: ['user_annotation', 'user_history'])
else
AuditLog.where.not(log_type: ['block_log', 'user_annotation', 'user_history'])
Expand Down Expand Up @@ -204,7 +204,7 @@ def setup_save
render
end

def hellban
def failban
@user.block("user manually blocked by admin ##{current_user.id}")
flash[:success] = t 'admin.user_fed_stat'
redirect_back fallback_location: admin_path
Expand All @@ -213,6 +213,8 @@ def hellban
def impersonate
if Rails.env.development?
change_users
else
render layout: 'without_sidebar'
end
end

Expand Down
5 changes: 2 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def verify_admin
end

def verify_global_admin
if !user_signed_in? || !current_user.is_global_admin
if !user_signed_in? || !current_user.global_admin?
render 'errors/not_found', layout: 'without_sidebar', status: :not_found
return false
end
Expand Down Expand Up @@ -307,8 +307,7 @@ def enforce_2fa
SiteSetting['EnableMandatoryGlobalAdminMod2FA'] &&
# Enable users to log out even if 2fa is enforced
!request.fullpath.end_with?('/users/sign_out') &&
(current_user.is_global_admin ||
current_user.is_global_moderator) &&
current_user.at_least_global_moderator? &&
(current_user.sso_profile.blank? || SiteSetting['Enable2FAForSsoUsers'])
redirect_path = '/users/two-factor'
unless request.fullpath.end_with?(redirect_path)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/moderator_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def user_vote_summary
total: Vote.for(@user).count
)
)
render layout: 'without_sidebar'
end

def spammy_users
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/site_settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SiteSettingsController < ApplicationController
# @param community_id [String, nil] id of the community to check access on
# @return [Boolean] Check result
def access?(user, community_id)
community_id.present? || user.is_global_admin
community_id.present? || user.global_admin?
end

def index
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/tag_sets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ def update
private

def set_tag_set
@tag_set = (current_user&.is_global_admin ? TagSet.unscoped : TagSet).find(params[:id])
@tag_set = (current_user&.global_admin? ? TagSet.unscoped : TagSet).find(params[:id])
end
end
44 changes: 14 additions & 30 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# rubocop:disable Metrics/ClassLength
class UsersController < ApplicationController
layout 'without_sidebar'

include Devise::Controllers::Rememberable

before_action :authenticate_user!, only: [:edit_profile, :update_profile, :stack_redirect,
Expand All @@ -12,11 +14,12 @@ class UsersController < ApplicationController

before_action :redirect_to_sign_in, only: [:filters], unless: [:user_signed_in?, :json_request?]

before_action :verify_moderator, only: [:mod, :destroy, :soft_delete, :role_toggle, :full_log,
:annotate, :annotations, :mod_privileges, :mod_privilege_action]
before_action :set_user, only: [:show, :mod, :destroy, :soft_delete, :posts, :role_toggle, :full_log, :activity,
:annotate, :annotations, :mod_privileges, :mod_privilege_action,
:vote_summary, :network, :avatar]
before_action :verify_moderator, only: [:annotate, :annotations, :full_log, :mod, :mod_delete, :mod_privilege_action,
:mod_privileges, :role_toggle, :soft_delete]
before_action :verify_global_moderator, only: [:mod_delete_network_account, :mod_failban]
before_action :set_user, only: [:activity, :annotate, :annotations, :avatar, :full_log, :mod, :mod_delete,
:mod_delete_network_account, :mod_failban, :mod_privilege_action, :mod_privileges,
:network, :posts, :role_toggle, :show, :soft_delete, :vote_summary]
before_action :check_deleted, only: [:show, :posts, :activity]

def index
Expand All @@ -36,7 +39,9 @@ def index
@post_counts = Post.where(user_id: @users.pluck(:id).uniq).group(:user_id).count

respond_to do |format|
format.html
format.html do
render layout: 'application'
end
format.json do
render json: @users
end
Expand All @@ -60,7 +65,6 @@ def show
.count
end
@posts = @posts.first(@limit)
render layout: 'without_sidebar'
end

def me
Expand Down Expand Up @@ -92,7 +96,6 @@ def preferences
prefs = current_user.preferences
@preferences = prefs[:global]
@community_prefs = prefs[:community]
render layout: 'without_sidebar'
end
format.json do
render json: current_user.preferences
Expand Down Expand Up @@ -135,9 +138,7 @@ def filters_json

def filters
respond_to do |format|
format.html do
render layout: 'without_sidebar'
end
format.html
format.json do
render json: filters_json
end
Expand Down Expand Up @@ -171,7 +172,7 @@ def delete_filter
as_user = current_user

if params[:system] == true
if current_user&.is_global_admin
if current_user&.global_admin?
as_user = User.find(-1)
else
return render json: { status: 'failed', success: false, errors: ['You do not have permission to delete'] },
Expand Down Expand Up @@ -225,7 +226,7 @@ def posts

respond_to do |format|
format.html do
render :posts
render :posts, layout: 'application'
end
format.json do
render json: @posts
Expand All @@ -239,7 +240,6 @@ def my_network

def network
@communities = Community.all
render layout: 'without_sidebar'
end

def my_activity
Expand Down Expand Up @@ -272,11 +272,8 @@ def activity
end

@items = items.sort_by(&:created_at).reverse.paginate(page: params[:page], per_page: 50)
render layout: 'without_sidebar'
end

def mod; end

def full_log
@posts = Post.by(@user).count
@comments = Comment.by(@user).count
Expand Down Expand Up @@ -315,8 +312,6 @@ def full_log
SuggestedEdit.by(@user).all + PostHistory.by(@user).all +
ModWarning.to(@user).all
end).sort_by(&:created_at).reverse.paginate(page: params[:page], per_page: 50)

render layout: 'without_sidebar'
end

def mod_privileges
Expand Down Expand Up @@ -349,10 +344,6 @@ def soft_delete
render json: { status: 'success', user: @user.id }
end

def edit_profile
render layout: 'without_sidebar'
end

def cleaned_profile_websites(profile_params)
sites = profile_params[:user_websites_attributes]

Expand Down Expand Up @@ -575,7 +566,6 @@ def annotations
@logs = AuditLog.where(log_type: 'user_annotation', related: @user)
.newest_first
.paginate(page: params[:page], per_page: 20)
render layout: 'without_sidebar'
end

def annotate
Expand Down Expand Up @@ -605,8 +595,6 @@ def vote_summary
[k, vl.group_by(&:post), vl.sum { |v| v.vote_type * v.vote_count }]
end
.paginate(page: params[:page], per_page: 15)

render layout: 'without_sidebar'
end

def avatar
Expand All @@ -628,10 +616,6 @@ def specific_avatar
end
end

def disconnect_sso
render layout: 'without_sidebar'
end

def confirm_disconnect_sso
if current_user.sso_profile.blank? || !helpers.devise_sign_in_enabled? || !SiteSetting['AllowSsoDisconnect']
flash[:danger] = 'You cannot disable Single Sign-On.'
Expand Down
18 changes: 18 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,22 @@ def safe_page(params)
def safe_per_page(params, min = 20)
params[:per_page].nil? || params[:per_page].to_i < min ? min : params[:per_page].to_i
end

##
# Is the Moderator Tools tab of the user page the active tab?
# @param user [User] user whose page is being viewed
# @return [Boolean]
def user_mod_tools_tab_active?(user)
current_page?(mod_user_url(user)) ||
current_page?(full_user_log_url(user)) ||
current_page?(user_annotations_url(user)) ||
current_page?(mod_vote_summary_url(user)) ||
current_page?(user_privileges_url(user)) ||
current_page?(mod_warning_log_url(user)) ||
current_page?(new_mod_warning_url(user)) ||
current_page?(mod_delete_url(user)) ||
current_page?(mod_delete_network_account_url(user)) ||
current_page?(mod_failban_url(user)) ||
current_page?(start_impersonating_url(user))
end
end
2 changes: 1 addition & 1 deletion app/views/admin/create_site.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

<p>Once you are ready, click on the following button:</p>

<a href="//<%= @new_community.host %>/admin/setup" class="button is-filled is-very-large">To new site</a>
<a href="//<%= @new_community.host %>/admin/setup" class="button is-filled is-very-large">To new site</a>
Loading
Loading