-
-
Notifications
You must be signed in to change notification settings - Fork 72
Mod tools interface: Temporary pull request for feedback only #2040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
trichoplax
wants to merge
13
commits into
develop
from
trichoplax/temporary-mod-tools-interface-for-matching-to
Closed
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f16bd3a
Temporary commit to confirm what should be cherry picked from the mod…
trichoplax 6c29d6d
Add missing image upload modal for warnings
trichoplax ed3e5d9
Formatting improvements thanks to Rubocop
trichoplax bcfedf9
Make 'without_sidebar' the default layout for the users controller
trichoplax 588c019
Add missing do block (thanks Rubocop!)
trichoplax c2acb3d
Remove expand buttons in mod warning log
trichoplax ae78b0b
Restore formatting of mod tools previous warning log
trichoplax efd7158
Make user mod tools left panel move to top on mobile
trichoplax 126c2c4
Only render once in impersonate method
trichoplax 586c9c9
Avoid separate views for desktop and mobile mod tools lists
trichoplax 6ad16ae
Improve code formatting
trichoplax 7c87bb1
Match left panel layout change in mod tools to right panel in other p…
trichoplax 8de70f0
Add temporary CSS variable for mod tools
trichoplax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,8 @@ | |
|
|
||
| .tabs { | ||
| margin-bottom: 1em; | ||
| } | ||
|
|
||
| .tabs--push { | ||
| flex-grow: 1; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,49 @@ | ||
| <h1>Warnings sent to <%= user_link @user %></h1> | ||
| <% content_for :title, "Moderator Tools: #{rtl_safe_username(@user)}" %> | ||
|
|
||
| <table class="table is-full-width is-with-hover"> | ||
| <tr> | ||
| <th>Date</th> | ||
| <th>Type</th> | ||
| <th>From</th> | ||
| <th>Excerpt</th> | ||
| <th>Status</th> | ||
| </tr> | ||
| <% @warnings.each do |w| %> | ||
| <tr> | ||
| <td> | ||
| <span title="<%= w.created_at.iso8601 %>"><%= time_ago_in_words(w.created_at) %> ago</span> | ||
| </td> | ||
| <td> | ||
| <% if w.suspension? %> | ||
| <% diff = ((w.suspension_end - w.created_at) / (3600 * 24)).to_i %> | ||
| <span class="badge is-tag is-red is-filled nowrap">Suspension</span> (<%= diff %>d) | ||
| <% else %> | ||
| <span class="badge is-tag is-muted nowrap">Warning</span> | ||
| <% end %> | ||
| </td> | ||
| <td><%= user_link w.author %></td> | ||
| <td><%= raw(sanitize(render_markdown(w.body), scrubber: scrubber)) %></td> | ||
| <td class="wrap-word"> | ||
| <% if w.suspension_active? %> | ||
| <strong>Current</strong> | ||
| <%= form_tag lift_mod_warning_url(@user.id), method: :post do %> | ||
| <%= submit_tag '(lift)', class: 'link is-red' %> | ||
| <% end %> | ||
| <% elsif w.active %> | ||
| <strong>Unread</strong> | ||
| <% elsif w.read %> | ||
| Read | ||
| <% else %> | ||
| <strong>Lifted</strong> | ||
| <% end %> | ||
| </td> | ||
| </tr> | ||
| <% end %> | ||
| </table> | ||
| <%= render 'users/tabs', user: @user %> | ||
|
|
||
| <div class="grid"> | ||
| <%= render 'shared/user_mod_sidebar', user: @user %> | ||
|
|
||
| <div class="grid--cell is-9"> | ||
| <h1>Previously Sent Warnings</h1> | ||
|
|
||
| <% if @warnings.size == 0 %> | ||
| <p class="has-color-tertiary"><em>No warnings found for this user.</em></p> | ||
| <% end %> | ||
|
|
||
| <% @warnings.each do |w| %> | ||
| <div class="widget"> | ||
| <div class="widget--header is-complex h-bg-tertiary-050"> | ||
| <div class="has-float-right h-p-1 h-fs-caption"> | ||
| <% if w.suspension_active? %> | ||
| <%= form_tag lift_mod_warning_url(@user.id), method: :post, class: 'mod-warnings-clear-form' do %> | ||
| <%= submit_tag '(lift)', class: 'link is-red' %> | ||
| <% end %> · | ||
| <strong>Current <i class="fas fa-fw fa-clock"></i></strong> | ||
| <% elsif w.active %> | ||
| <strong>Unread <i class="fas fa-fw fa-eye-slash"></i></strong> | ||
| <% elsif w.read %> | ||
| Read <i class="fas fa-fw fa-eye"></i> | ||
| <% else %> | ||
| Lifted <i class="fas fa-fw fa-undo"></i> | ||
| <% end %> | ||
| </div> | ||
| <div> | ||
| <% if w.is_suspension %> | ||
| <% diff = ((w.suspension_end - w.created_at) / (3600 * 24)).to_i %> | ||
| <span class="badge is-tag is-red is-filled badge-nobreak"><i class="fas fa-user-slash fa-fw"></i> Suspension</span> | ||
| <span class="badge is-tag is-muted badge-nobreak">length: <%= diff %>d</span> | ||
| <% else %> | ||
| <span class="badge is-tag is-yellow is-filled badge-nobreak"><i class="fas fa-exclamation-triangle fa-fw"></i> Warning</span> | ||
| <% end %> | ||
| </div> | ||
| <div class="h-c-tertiary-700 h-fs-caption h-m-t-2"><span title="<%= w.created_at.iso8601 %>"><%= time_ago_in_words(w.created_at) %> ago</span> by <%= user_link w.author %></div> | ||
| </div> | ||
| <div class="widget--body is-partial-only"> | ||
| <%= raw(sanitize(render_markdown(w.body), scrubber: scrubber)) %> | ||
| </div> | ||
| </div> | ||
| <% end %> | ||
| </div> | ||
| </div> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of these in this controller - is it worth just making it the default layout for the controller?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware of how to do that so I've had a look into it.
There's the standard Rails way of doing it, by adding
layout "without_sidebar"at the top of the controller file. I noticed we also have a variable@prevent_sidebarthat is used in places where the sidebar is to be omitted only sometimes.The advantage of a variable is that it can be made to only affect that one aspect. Currently it does not. Currently the variable is used to choose between the default
application.html.erbandwithout_sidebar.html.erb. Unfortunately the two layout files differ in more than just whether the sidebar is included. I don't know if this is due to accidental divergence due to having near identical code in 2 separate places, or whether there is currently a need for the other differences.If there is a need for the other differences with the pages that currently happen to have no sidebar, this is not clear from the name so it would be easy for someone to add or remove a sidebar on a page that should not have the other differences.
Even if there is currently no accidental divergence, the fact that I had to look into this to understand that there are more differences suggests it would be easy for someone with my level of knowledge to accidentally cause divergence in future by modifying either of these layouts without the other.
How would you feel about this being raised as a separate issue to consider how best to mitigate these risks? I can imagine a solution that involves no longer having a
without_sidebarlayout, and just having the sidebar inapplication.html.erbbe controlled by a variable, so there are no surprising side effects.I'm happy to also make the change here in the meantime if you prefer. In case it isn't obvious, I was out of my depth with this question so these are just my thoughts based on finding out how this currently works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds ideal to me. For now let's use the
layoutcall here to avoid widening the scope of this work again, but we should file it for future - it's not difficult, but will be a chunk of work to convert the layout and change all existinglayoutcalls to use that approach.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've now applied 'without_sidebar' as the default layout for the Users controller, and removed this layout call from affected methods. There were only a couple that needed to be overridden back to the 'application' layout, so this has made a big difference - thanks. I've completely removed those methods that existed only for this reason.
I've also raised #2043 for the future work.