From a1d650848b19942d900eb268568342fa9dfed9e7 Mon Sep 17 00:00:00 2001 From: evazion Date: Tue, 25 Jan 2022 12:43:55 -0600 Subject: [PATCH] forum: fix undelete option not appearing in menu. Fix the option to undelete forum posts not appearing in the context menu for Moderators. --- .../forum_post_component.html.erb | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/components/forum_post_component/forum_post_component.html.erb b/app/components/forum_post_component/forum_post_component.html.erb index cd1ce382f..0a8a251a9 100644 --- a/app/components/forum_post_component/forum_post_component.html.erb +++ b/app/components/forum_post_component/forum_post_component.html.erb @@ -43,18 +43,20 @@ <% end %> <% end %> <% end %> + <% end %> - <% if policy(forum_post).destroy? && !forum_post.is_original_post?(original_forum_post_id) %> - <% menu.item do %> - <% if forum_post.is_deleted? %> - <%= link_to undelete_forum_post_path(forum_post.id), method: :post, remote: true do %> - <%= undelete_icon %> Undelete - <% end %> - <% else %> - <%= link_to forum_post_path(forum_post.id), "data-confirm": "Are you sure you want to delete this forum post?", method: :delete, remote: true do %> - <%= delete_icon %> Delete - <% end %> - <% end %> + <% if forum_post.is_deleted? && policy(forum_post).undelete? && !forum_post.is_original_post?(original_forum_post_id) %> + <% menu.item do %> + <%= link_to undelete_forum_post_path(forum_post.id), method: :post, remote: true do %> + <%= undelete_icon %> Undelete + <% end %> + <% end %> + <% end %> + + <% if !forum_post.is_deleted? && policy(forum_post).destroy? && !forum_post.is_original_post?(original_forum_post_id) %> + <% menu.item do %> + <%= link_to forum_post_path(forum_post.id), "data-confirm": "Are you sure you want to delete this forum post?", method: :delete, remote: true do %> + <%= delete_icon %> Delete <% end %> <% end %> <% end %>