User moderator tools user interface redesign#2063
Conversation
(cherry picked from commit 208f515)
(cherry picked from commit 3b36262)
(cherry picked from commit 4ad7dc9)
(cherry picked from commit 1296004)
(cherry picked from commit 6d624c2)
(cherry picked from commit b6f18b2)
(cherry picked from commit c77f456)
(cherry picked from commit a697df3)
(cherry picked from commit 3155f62)
(cherry picked from commit c5847fd)
(cherry picked from commit 05cded1)
(cherry picked from commit 709b8c9)
(cherry picked from commit 62be5b0)
(cherry picked from commit d08f4af)
(cherry picked from commit fd66bc8)
(cherry picked from commit 048685b)
(cherry picked from commit f157386)
(cherry picked from commit d271b38)
(cherry picked from commit 3b225c2)
(cherry picked from commit 4f07b2a)
(cherry picked from commit 2795ff0)
(cherry picked from commit 2acc08e)
(cherry picked from commit bcfedf9)
(cherry picked from commit 588c019)
(cherry picked from commit c2acb3d)
(cherry picked from commit 126c2c4)
cellio
left a comment
There was a problem hiding this comment.
I ran through the new tools pages and everything looks good. I'll file follow-on issues for the things we decided (in the previous PR) to defer.
| 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_pii_correlation_url(user)) || | ||
| current_page?(mod_delete_network_account_url(user)) || | ||
| current_page?(mod_failban_url(user)) || | ||
| current_page?(start_impersonating_url(user)) | ||
| end |
There was a problem hiding this comment.
This looks like a good candidate for a loop, this is way too many ORs for one method
There was a problem hiding this comment.
Oh good point. I did some searching and I've found 2 approaches. I've implemented one, but the following also works:
def user_mod_tools_tab_active?(user)
user_mod_tools_tab_pages = [
mod_user_url(user),
full_user_log_url(user),
user_annotations_url(user),
mod_vote_summary_url(user),
user_privileges_url(user),
mod_warning_log_url(user),
new_mod_warning_url(user),
mod_delete_url(user),
mod_pii_correlation_url(user),
mod_delete_network_account_url(user),
mod_failban_url(user),
start_impersonating_url(user)
]
user_mod_tools_tab_pages.any? { |page| current_page?(page) }
endI'm not sure which would be more readable, so let me know if you'd prefer the other approach (or if there's a better approach I haven't considered).
There was a problem hiding this comment.
I was thinking about something a bit more succinct - what'd you say if took this approach instead:
def user_mod_tools_tab_active?(user)
methods = [
:mod_user,
:full_user_log,
:user_annotations,
:mod_vote_summary,
:user_privileges,
:mod_warning_log,
:new_mod_warning,
:mod_delete,
:mod_pii_correlation,
:mod_delete_network_account,
:mod_failban,
:start_impersonating
]
methods.any? { |name| current_page?(send("#{name}_url", user)) }
endThere was a problem hiding this comment.
current_page? also accepts controller and action options so we could use that form to simplify even further.
This converts the user moderation tools from a pop up panel on the user page to a tab at the top of the user page. On desktop this has a left hand panel listing all of the user moderation tools. On mobile this list is available by pressing "Show User Moderation Tools" near the top of the tab.
Note that this change also includes some tidying: code formatting to match the style guide and use of the new user model methods such as
admin?instead ofis_admin. Please let me know if you would prefer any of these to be a separate pull request. My aim has been to get these out of the way now to minimise such changes in later user moderator tools pull requests.