Skip to content

Commit

Permalink
AO3-5977 Hide "Approve All Unreviewed Comments" button from admins on…
Browse files Browse the repository at this point in the history
… works (#4966)

* AO3-5977 Hide "Approve All Unreviewed Comments" button from admins on works

Also hides "Approve All Unreviewed Comments" when there are no unreviewed comments.

* Simplify test, check
  • Loading branch information
WelpThatWorked authored Jan 22, 2025
1 parent 3ed0f36 commit fb325da
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions app/helpers/comments_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ def can_review_comment?(comment)
is_author_of?(comment.ultimate_parent) || policy(comment).can_review_comment?
end

def can_review_all_comments?(commentable)
commentable.is_a?(AdminPost) || is_author_of?(commentable)
end

#### HELPERS FOR REPLYING TO COMMENTS #####

# return link to add new reply to a comment
Expand Down
10 changes: 6 additions & 4 deletions app/views/comments/unreviewed.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
<!--/descriptions-->

<!--Subnavigation, sorting and actions-->
<ul class="navigation actions">
<% path = @commentable.is_a?(AdminPost) ? review_all_admin_post_comments_path(@commentable) : review_all_work_comments_path(@commentable) %>
<li><%= button_to(t(".approve_all"), path, method: :put) %></li>
</ul>
<% if can_review_all_comments?(@commentable) %>
<ul class="navigation actions">
<% path = @commentable.is_a?(AdminPost) ? review_all_admin_post_comments_path(@commentable) : review_all_work_comments_path(@commentable) %>
<li><%= button_to(t(".approve_all"), path, method: :put) %></li>
</ul>
<% end %>
<!--/subnav-->

<!--main content-->
Expand Down
13 changes: 13 additions & 0 deletions features/admins/admin_works.feature
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,19 @@ Feature: Admin Actions for Works, Comments, Series, Bookmarks
Then I should see "rolex"
And I should not see "This comment has been marked as spam."

Scenario: Moderated comments cannot be approved by admin
Given the moderated work "Moderation" by "author"
And I am logged in as "commenter"
And I post the comment "Test comment" on the work "Moderation"
When I am logged in as a "superadmin" admin
And I view the work "Moderation"
Then I should see "Unreviewed Comments (1)"
And the comment on "Moderation" should be marked as unreviewed
When I follow "Unreviewed Comments (1)"
Then I should see "Test comment"
And I should not see an "Approve All Unreviewed Comments" button
And I should not see an "Approve" button

Scenario: Admin can edit language on works when posting without previewing
Given basic languages
And I am logged in as "regular_user"
Expand Down

0 comments on commit fb325da

Please sign in to comment.