indentlabs/notebook

View on GitHub
app/views/share_comments/_show.html.erb

Summary

Maintainability
Test Coverage
<% if comment.from_op?(share) %>
  <div class="col s12 m10 l9">
    <div class="purple lighten-4 comment black-text">
<% else %>
  <div class="col s12 m10 offset-m2 l9 offset-l3">
    <div class="blue lighten-3 comment black-text">
<% end %>

    <%# Nested indents from above %>
    <%= clean_links simple_format ContentFormatterService.show(
      text:         comment.message,
      viewing_user: current_user
    ), class: 'black-text' %>

    <div class="metadata">
      <%= link_to comment.user, class: "#{User.text_color} text-darken-4" do %>
        <% if comment.user %>
          <%= image_tag comment.user.image_url(size=20), class: 'left circle avatar' %>
          <%= comment.user.display_name %>
        <% else %>
          <em>Deleted user</em>
        <% end %>
      <% end %>
      <span class="timestamp">
        <%= time_ago_in_words comment.created_at %> ago

        <% if user_signed_in? && (share.user_id == current_user.id || comment.user_id == current_user.id) %>
          <a class='dropdown-trigger right' href='#' data-target='dropdown-comment-<%= comment.id %>'>
            <i class="material-icons">more_vert</i>
          </a>
          <ul id='dropdown-comment-<%= comment.id %>' class='dropdown-content'>
            <li>
              <%= link_to comment, method: :delete do %>
                <i class="material-icons left">delete</i>
                Delete this comment
              <% end %>
            </li>
          </ul>
        <% end %>

      </span>
    </div>

  </div>
</div>