<div id="c-artist-commentary-versions">
  <div id="a-index">
    <h1>Artist Commentary Changes</h1>

    <%= render "posts/partials/common/inline_blacklist" %>

    <table width="100%" class="striped">
      <thead>
        <tr>
          <th width="5%">Post</th>
          <th>Original</th>
          <th>Translated</th>
          <% if CurrentUser.is_moderator? %>
            <th width="10%">IP Address</th>
          <% end %>
          <th width="10%">Edited By</th>
          <th width="10%">Date</th>
          <% if CurrentUser.is_member? %>
            <th width="7%"></th>
          <% end %>
        </tr>
      </thead>
      <tbody>
        <% @commentary_versions.each do |commentary_version| %>
          <tr>
            <td>
              <% if params.dig(:search, :post_id).present? %>
                <%= link_to commentary_version.post_id, post_path(commentary_version.post_id) %>
              <% else %>
                <%= PostPresenter.preview(commentary_version.post, :tags => "status:any") %>
              <% end %>
            </td>
            <td>
              <h3><%= h(commentary_version.original_title) %></h3>
              <div class="prose">
                <%= format_text(commentary_version.original_description, :disable_mentions => true) %>
              </div>
            </td>
            <td>
              <h3><%= h(commentary_version.translated_title) %></h3>
              <div class="prose">
                <%= format_text(commentary_version.translated_description, :disable_mentions => true) %>
              </div>
            </td>
            <% if CurrentUser.is_moderator? %>
              <td>
                <%= link_to_ip commentary_version.updater_ip_addr %>
              </td>
            <% end %>
            <td><%= link_to_user commentary_version.updater %></td>
            <td><%= compact_time commentary_version.updated_at %></td>
            <% if CurrentUser.is_member? %>
              <td>
                <%= link_to "Revert to", revert_artist_commentary_path(commentary_version.post_id, :version_id => commentary_version.id), :remote => true, :method => :put, :data => {:confirm => "Are you sure you want to revert to this version?"} %>
              </td>
            <% end %>
          </tr>
        <% end %>
      </tbody>
    </table>

    <%= numbered_paginator(@commentary_versions) %>

    <%= render "artist_commentaries/secondary_links" %>
  </div>
</div>

<% content_for(:page_title) do %>
  Artist Commentary Versions - <%= Danbooru.config.app_name %>
<% end %>
