sudara/alonetone

View on GitHub
app/views/admin/comments/_comment.html.erb

Summary

Maintainability
Test Coverage
<div data-controller="admin--comment" data-admin--comment-spam="<%= comment.is_spam? %>" data-admin--comment-deleted="<%= comment.soft_deleted? %>" data-admin--comment-user-deleted="<%= comment.commenter&.soft_deleted? %>">
  <div class="date_column"><%= comment.created_at.strftime("%b %d") %>, <%= comment.id %></div>
  <div class="user_column">
    <div class="avatar">
      <%= user_image(@user, variant: :card_avatar) %>
    </div>
    <div>
      <div>
        <% if comment.commenter %>
          <%= link_to "Comment By: #{comment&.commenter&.login}", admin_possibly_deleted_user_path(comment.commenter.login) %>
        <% else %>
          <%= "Comment By: #{comment&.commenter&.login}" %>
        <% end %>
      </div>
      <div><%= comment&.commenter&.email %></div>
      <div><%= comment.remote_ip %></div>
    </div>
  </div>
  <div class="text_column"><%= truncate(comment.body, length: 80) %></div>
  <div class="button_column">
    <div><%= button_to "Mark As Spam", spam_admin_comment_path(comment), method: :put, data: { 'admin-comment-target': 'spamButton', action: 'click->admin--comment#markAsSpam' } %></div>
    <div><%= button_to "Restore", unspam_admin_comment_path(comment), data: { 'admin--comment-target': 'restoreButton', action: 'click->admin--comment#markAsRestored' }, method: :put %></div>
  </div>
</div>