From dade1c126f3015e822dec7d9bc3a7b7b49883529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20B=2E?= Date: Sun, 8 Sep 2024 03:51:38 +0200 Subject: [PATCH] AO3-6392 Comment actions when replying in full page (#4381) * Hide comment actions same as with JS https://otwarchive.atlassian.net/browse/AO3-6392 Reproduce the behavior of add_comment_reply.js * Fix Cancel button on non-JS reply By forcing a non-JS behavior https://otwarchive.atlassian.net/browse/AO3-6392 * Hound * Hound * Add test for hiding feature * Work page test * Add test for the cancel button not being updated * Hound * Hound (bis) * Reviewdog * Use function instead of copy paste * Reviewdog? * Reviewdog, but right this time At least works locally * Fix wrong domain issue in tests * Wording Totally not a trick to trigger a new build * Rename * Actually unused? The first case of the if wasn't accessible anymore As the form was hidden if the condition was true * No more need for forced reload * Test cleanup * Fix guest comments in tests --------- Co-authored-by: Brian Austin --- app/controllers/comments_controller.rb | 3 +- app/helpers/comments_helper.rb | 31 ++++++++-------- app/views/comments/_comment_actions.html.erb | 6 +-- .../comments_and_kudos/add_comment.feature | 37 +++++++++++++++++++ features/step_definitions/comment_steps.rb | 16 ++++++++ 5 files changed, 73 insertions(+), 20 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 7cd1f95b8d2..da5c9d84d95 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -674,7 +674,8 @@ def redirect_to_all_comments(commentable, options = {}) delete_comment_id: options[:delete_comment_id], view_full_work: options[:view_full_work], anchor: options[:anchor], - page: options[:page] + page: options[:page], + only_path: true end end diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 257bdca95f5..fd87f3e7946 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -212,14 +212,6 @@ def can_review_comment?(comment) #### HELPERS FOR REPLYING TO COMMENTS ##### - def add_cancel_comment_reply_link(comment) - if params[:add_comment_reply_id] && params[:add_comment_reply_id] == comment.id.to_s - cancel_comment_reply_link(comment) - else - add_comment_reply_link(comment) - end - end - # return link to add new reply to a comment def add_comment_reply_link(comment) commentable_id = comment.ultimate_parent.is_a?(Tag) ? @@ -250,14 +242,17 @@ def cancel_comment_reply_link(comment) comment.parent.id link_to( ts("Cancel"), - url_for(controller: :comments, - action: :cancel_comment_reply, - id: comment.id, - comment_id: params[:comment_id], - commentable_id => commentable_value, - view_full_work: params[:view_full_work], - page: params[:page]), - remote: true) + url_for( + controller: :comments, + action: :cancel_comment_reply, + id: comment.id, + comment_id: params[:comment_id], + commentable_id => commentable_value, + view_full_work: params[:view_full_work], + page: params[:page] + ), + remote: true + ) end # canceling an edit @@ -394,4 +389,8 @@ def comments_are_moderated(commentable) parent = find_parent(commentable) parent.respond_to?(:moderated_commenting_enabled) && parent.moderated_commenting_enabled? end + + def focused_on_comment(commentable) + params[:add_comment_reply_id] && params[:add_comment_reply_id] == commentable.id.to_s + end end diff --git a/app/views/comments/_comment_actions.html.erb b/app/views/comments/_comment_actions.html.erb index 810e7f58835..52b3815440d 100644 --- a/app/views/comments/_comment_actions.html.erb +++ b/app/views/comments/_comment_actions.html.erb @@ -1,6 +1,6 @@
<%= ts("Comment Actions") %>
-