Remove legacy "deleted commentable" view (#15052)
* Remove unneeded extra page * Update app/views/comments/index.html.erb Co-authored-by: Michael Kohl <citizen428@forem.com> * Update app/views/comments/index.html.erb Co-authored-by: Michael Kohl <citizen428@forem.com>
This commit is contained in:
parent
9faf136db1
commit
b900c8de92
7 changed files with 56 additions and 115 deletions
|
|
@ -36,8 +36,6 @@ class CommentsController < ApplicationController
|
|||
@commentable_type = @commentable.class.name if @commentable
|
||||
|
||||
set_surrogate_key_header "comments-for-#{@commentable.id}-#{@commentable_type}" if @commentable
|
||||
|
||||
render :deleted_commentable_comment unless @commentable
|
||||
end
|
||||
# rubocop:enable Metrics/CyclomaticComplexity
|
||||
# rubocop:enable Metrics/PerceivedComplexity
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
<%= "comment--too-deep" if comment.depth > 3 %>
|
||||
"
|
||||
data-comment-id="<%= comment.id %>"
|
||||
data-path="<%= commentable.path %>/comments/<%= comment.id_code_generated %>"
|
||||
data-path="<%= commentable&.path %>/comments/<%= comment.id_code_generated %>"
|
||||
data-comment-author-id="<%= comment_user_id_unless_deleted comment %>"
|
||||
data-content-user-id="<%= comment_user_id_unless_deleted comment %>">
|
||||
<%= render("comments/comment_proper",
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
<li><a href="<%= URL.comment(comment) %>" class="crayons-link crayons-link--block permalink-copybtn" aria-label="Copy link to <%= comment.user.name %>'s comment" data-no-instant><%= t("core.copy_link") %></a></li>
|
||||
<li class="comment-actions hidden" data-user-id="<%= comment.user_id %>" data-action="settings-button" data-path="<%= URL.comment(comment) %>/settings" aria-label="Go to <%= comment.user.name %>'s comment settings"></li>
|
||||
<% action = comment.hidden_by_commentable_user ? "Unhide" : "Hide" %>
|
||||
<li class="comment-actions hidden" data-action="hide-button" data-commentable-user-id="<%= commentable.user_id %>" data-user-id="<%= comment.user_id %>">
|
||||
<li class="comment-actions hidden" data-action="hide-button" data-commentable-user-id="<%= commentable&.user_id %>" data-user-id="<%= comment.user_id %>">
|
||||
<a href="#" class="crayons-link crayons-link--block hide-comment" data-hide-type="<%= action.downcase %>" data-comment-id="<%= comment.id %>" aria-label="<%= action %> <%= comment.user.name %>'s comment">
|
||||
<%= action %>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= unless comment.deleted
|
||||
<%= unless comment.deleted || commentable.nil?
|
||||
(render partial: "comments/comment_footer", locals: {
|
||||
comment: comment,
|
||||
commentable: commentable,
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
<div class="comments-container comments-dedicated-page-container">
|
||||
<h3>Comment from a deleted article or podcast</h3>
|
||||
<div class="single-comment-node root">
|
||||
<% @user ||= @root_comment.user %>
|
||||
<% if @root_comment.blank? || @root_comment.deleted %>
|
||||
<div class="inner-comment">
|
||||
<div class="body">
|
||||
[deleted]
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="inner-comment">
|
||||
<% decorated_comment = @root_comment.decorate %>
|
||||
|
||||
<% if decorated_comment.low_quality %>
|
||||
<div class="crayons-notice crayons-notice--warning low-quality-comment-marker">
|
||||
<%= image_tag(Images::Optimizer.call(Settings::General.mascot_image_url, width: 50, height: 50, crop: "imagga_scale"), class: "sloan", alt: "Sloan, the sloth mascot", loading: "lazy") %>
|
||||
Comment marked as low quality/non-constructive by the community. <a href="/code-of-conduct">View Code of Conduct</a>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="details <%= "low-quality-comment" if decorated_comment.low_quality %>">
|
||||
<a href="/<%= @user.username %>">
|
||||
<img class="profile-pic" src="<%= Images::Profile.call(@user.profile_image_url, length: 50) %>" alt="<%= @user.username %> profile image" />
|
||||
<span class="comment-username">
|
||||
<span class="comment-username-inner">
|
||||
<%= @user.name %>
|
||||
</span>
|
||||
</span>
|
||||
</a>
|
||||
<% if @user.twitter_username.present? %>
|
||||
<a href="https://twitter.com/<%= @user.twitter_username %>" rel="noopener noreferrer" target="_blank">
|
||||
<%= image_tag("twitter-logo.svg", class: "icon-img", alt: "twitter logo") %></a>
|
||||
<% end %>
|
||||
<% if @user.github_username.present? %>
|
||||
<a href="https://github.com/<%= @user.github_username %>" rel="noopener noreferrer" target="_blank">
|
||||
<%= image_tag("github-logo.svg", class: "icon-img", alt: "github logo") %>
|
||||
</a>
|
||||
<% end %>
|
||||
<%= render "comments/comment_date", decorated_comment: decorated_comment %>
|
||||
</div>
|
||||
<div
|
||||
class="body
|
||||
<%= "low-quality-comment" if decorated_comment.low_quality %>
|
||||
<%= "color-base-60" if @root_comment.decorate.low_quality %>">
|
||||
<%= sanitize @root_comment.processed_html %>
|
||||
<button class="reaction-button reacted" disabled>
|
||||
<img class="voted-heart" src="<%= asset_path("twemoji/heart.svg") %>" alt="Favorite heart button" />
|
||||
<span class="reactions-count"><%= @root_comment.reactions_count %></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<% if @root_comment.user_id == current_user&.id %>
|
||||
<span class="current-user-actions">
|
||||
<a href="<%= @root_comment.path %>/delete_confirm" class="edit-butt" rel="nofollow">DELETE</a>
|
||||
<a href="<%= @root_comment.path %>/edit" class="edit-butt" rel="nofollow">EDIT</a>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,43 +1,45 @@
|
|||
<%= javascript_packs_with_chunks_tag "postCommentsPage", defer: true %>
|
||||
<% if @root_comment.present? %>
|
||||
<% title("#{@root_comment.title} - #{community_name}") %>
|
||||
<% title("#{@root_comment.title}") %>
|
||||
<% else %>
|
||||
<% title("Discussion of #{@commentable.title} - #{community_name}") %>
|
||||
<% title("Discussion of #{@commentable.title}") %>
|
||||
<% end %>
|
||||
|
||||
<%= content_for :page_meta do %>
|
||||
<meta name="description" content="<%= @commentable.description || "An article from the community" %>">
|
||||
<%= meta_keywords_article %>
|
||||
<% if @commentable %>
|
||||
<%= content_for :page_meta do %>
|
||||
<meta name="description" content="<%= @commentable.description || "An article from the community" %>">
|
||||
<%= meta_keywords_article %>
|
||||
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:title" content="Discussion of <%= @commentable.title %>" />
|
||||
<meta property="og:description" content="<%= @commentable.description || "#{community_name} Comment" %>" />
|
||||
<meta property="og:site_name" content="<%= community_name %>" />
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:site" content="@<%= Settings::General.social_media_handles["twitter"] %>">
|
||||
<meta name="twitter:creator" content="@<%= @user.twitter_username %>">
|
||||
<meta name="twitter:title" content="<%= @commentable.title %>">
|
||||
<meta name="twitter:description" content="<%= @commentable.description || "#{community_name} Comment" %>">
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:title" content="Discussion of <%= @commentable.title %>" />
|
||||
<meta property="og:description" content="<%= @commentable.description || "#{community_name} Comment" %>" />
|
||||
<meta property="og:site_name" content="<%= community_name %>" />
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:site" content="@<%= Settings::General.social_media_handles["twitter"] %>">
|
||||
<meta name="twitter:creator" content="@<%= @user.twitter_username %>">
|
||||
<meta name="twitter:title" content="<%= @commentable.title %>">
|
||||
<meta name="twitter:description" content="<%= @commentable.description || "#{community_name} Comment" %>">
|
||||
|
||||
<% if @root_comment.present? %>
|
||||
<link rel="canonical" href="<%= app_url(@root_comment.path) %>" />
|
||||
<meta property="og:url" content="<%= app_url(@root_comment.path) %>" />
|
||||
<meta property="og:title" content="<%= truncate(strip_tags(@root_comment.processed_html), length: 50) %> — <%= community_name %>" />
|
||||
<meta name="twitter:title" content="<%= truncate(strip_tags(@root_comment.processed_html), length: 50) %> — <%= community_name %>">
|
||||
<meta property="og:image" content="<%= comment_social_image_url(@root_comment) %>" />
|
||||
<meta name="twitter:image" content="<%= comment_social_image_url(@root_comment) %>">
|
||||
<% if @root_comment.score < 0 || @commentable.score < 0 %>
|
||||
<meta name="googlebot" content="noindex">
|
||||
<meta name="googlebot" content="nofollow">
|
||||
<% end %>
|
||||
<% else %>
|
||||
<link rel="canonical" href="<%= app_url("#{@commentable.path}/comments") %>" />
|
||||
<meta property="og:url" content="<%= app_url("#{@commentable.path}/comments") %>" />
|
||||
<meta property="og:title" content="[Discussion] <%= @commentable.title %> — <%= community_name %>" />
|
||||
<meta name="twitter:title" content="[Discussion] <%= @commentable.title %> — <%= community_name %>">
|
||||
<% if @commentable.class.name == "Article" && @commentable.published %>
|
||||
<meta property="og:image" content="<%= article_social_image_url(@commentable) %>" />
|
||||
<meta name="twitter:image" content="<%= article_social_image_url(@commentable) %>">
|
||||
<% if @root_comment.present? %>
|
||||
<link rel="canonical" href="<%= app_url(@root_comment.path) %>" />
|
||||
<meta property="og:url" content="<%= app_url(@root_comment.path) %>" />
|
||||
<meta property="og:title" content="<%= truncate(strip_tags(@root_comment.processed_html), length: 50) %> — <%= community_name %>" />
|
||||
<meta name="twitter:title" content="<%= truncate(strip_tags(@root_comment.processed_html), length: 50) %> — <%= community_name %>">
|
||||
<meta property="og:image" content="<%= comment_social_image_url(@root_comment) %>" />
|
||||
<meta name="twitter:image" content="<%= comment_social_image_url(@root_comment) %>">
|
||||
<% if @root_comment.score < 0 || @commentable.score < 0 %>
|
||||
<meta name="googlebot" content="noindex">
|
||||
<meta name="googlebot" content="nofollow">
|
||||
<% end %>
|
||||
<% else %>
|
||||
<link rel="canonical" href="<%= app_url("#{@commentable.path}/comments") %>" />
|
||||
<meta property="og:url" content="<%= app_url("#{@commentable.path}/comments") %>" />
|
||||
<meta property="og:title" content="[Discussion] <%= @commentable.title %> — <%= community_name %>" />
|
||||
<meta name="twitter:title" content="[Discussion] <%= @commentable.title %> — <%= community_name %>">
|
||||
<% if @commentable.class.name == "Article" && @commentable.published %>
|
||||
<meta property="og:image" content="<%= article_social_image_url(@commentable) %>" />
|
||||
<meta name="twitter:image" content="<%= article_social_image_url(@commentable) %>">
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
@ -45,7 +47,7 @@
|
|||
<%= javascript_packs_with_chunks_tag "commentDropdowns", "followButtons", defer: true %>
|
||||
|
||||
<div class="crayons-layout crayons-layout--limited-l gap-0" data-follow-button-container="true">
|
||||
<% if @commentable.class.name == "Article" %>
|
||||
<% if @commentable && @commentable.class.name == "Article" %>
|
||||
<%= render "shared/payment_pointer", user: @commentable.user %>
|
||||
<span id="comment-article-indicator" data-article-id="<%= @commentable.id %>"></span>
|
||||
<% end %>
|
||||
|
|
@ -89,13 +91,17 @@
|
|||
<div id="response-templates-data" class="hidden"></div>
|
||||
<%= javascript_packs_with_chunks_tag "responseTemplates", "commentsDisplay", defer: true %>
|
||||
<header class="p-2 pb-4 m:p-6 m:pb-6 crayons-card crayons-card--secondary s:mx-2 m:mx-4 -mb-1 z-0">
|
||||
<h1 class="crayons-subtitle-1 mb-4">
|
||||
<span class="fw-normal color-base-60">Discussion on: </span>
|
||||
<%= @commentable.title %>
|
||||
</h1>
|
||||
<div class="flex">
|
||||
<a class="crayons-btn crayons-btn--outlined mr-2" href="<%= @commentable.path %>"><%= t("core.view") %> <%= t("core.post").downcase %></a>
|
||||
</div>
|
||||
<% if @commentable %>
|
||||
<h1 class="crayons-subtitle-1 mb-4">
|
||||
<span class="fw-normal color-base-60">Discussion on: </span>
|
||||
<%= @commentable.title %>
|
||||
</h1>
|
||||
<div class="flex">
|
||||
<a class="crayons-btn crayons-btn--outlined mr-2" href="<%= @commentable.path %>"><%= t("core.view") %> <%= t("core.post").downcase %></a>
|
||||
</div>
|
||||
<% else %>
|
||||
[Comment from a deleted post]
|
||||
<% end %>
|
||||
</header>
|
||||
<% end %>
|
||||
|
||||
|
|
@ -112,8 +118,8 @@
|
|||
<section
|
||||
class="crayons-card text-padding min-w-0 z-elevate"
|
||||
id="comments-container"
|
||||
data-commentable-id="<%= @commentable.id %>"
|
||||
data-commentable-type="<%= @commentable.class.name %>">
|
||||
data-commentable-id="<%= @commentable&.id %>"
|
||||
data-commentable-type="<%= @commentable&.class&.name %>">
|
||||
|
||||
<% unless @root_comment %>
|
||||
<%= render "form",
|
||||
|
|
@ -135,7 +141,7 @@
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<% if @commentable.any_comments_hidden %>
|
||||
<% if @commentable&.any_comments_hidden %>
|
||||
<p class="mb-2 pt-6 fs-s align-center color-base-60">
|
||||
Some comments have been hidden by the post's author - <a href="/faq#what-does-comment-hidden-by-post-author-mean">find out more</a>
|
||||
</p>
|
||||
|
|
@ -146,7 +152,7 @@
|
|||
<%= render "articles/conduct_and_abuse_actions", page: "comments_index" %>
|
||||
</div>
|
||||
|
||||
<% if has_vid?(@commentable) %>
|
||||
<% if @commentable && has_vid?(@commentable) %>
|
||||
<%= render "articles/fitvids" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ RSpec.describe "Comments", type: :request do
|
|||
article.destroy
|
||||
|
||||
get comment.path
|
||||
expect(response.body).to include("Comment from a deleted article or podcast")
|
||||
expect(response.body).to include("Comment from a deleted post")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -207,7 +207,7 @@ RSpec.describe "Comments", type: :request do
|
|||
podcast_episode.destroy
|
||||
|
||||
get podcast_comment.path
|
||||
expect(response.body).to include("Comment from a deleted article or podcast")
|
||||
expect(response.body).to include("Comment from a deleted post")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue