.block__header
  = @pagination

= if reverts_tag_changes?(@conn) do
  .block__header.block__header--light.block__header--sub
    a data-click-checkall=".tag-changes-form"
      i.fa.fa-check>
      ' Toggle all

= form_for :tag_changes, ~p"/tag_changes/revert", [class: "tag-changes-form"], fn _f ->
  .block__content
    table.table
      thead
        tr
          = if reverts_tag_changes?(@conn) do
            th Revert?
          th colspan=2 Image
          th Tag
          th Action
          th Timestamp
          th User
          th Retained?
          = if reverts_tag_changes?(@conn) do
            th Moderation

      tbody
        = for tag_change <- @tag_changes do
          tr
            = if reverts_tag_changes?(@conn) do
              td.center
                input type="checkbox" name="ids[]" value=tag_change.id

            td.center
              = link tag_change.image_id, to: ~p"/images/#{tag_change.image}"
            td.center
              = render PhilomenaWeb.ImageView, "_image_container.html", image: tag_change.image, size: :thumb_tiny, conn: @conn

            td
              = if tag_change.tag do
                = render PhilomenaWeb.TagView, "_tag.html", tag: tag_change.tag, conn: @conn
              - else
                = tag_change.tag_name_cache || "Unknown tag"

            = if tag_change.added do
              td.success Added
            - else
              td.danger Removed

            td
              = pretty_time(tag_change.created_at)

            td class=user_column_class(tag_change)
              => render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: tag_change, conn: @conn

              = if can?(@conn, :show, :ip_address) do
                => link_to_ip @conn, tag_change.ip
                => link_to_fingerprint @conn, tag_change.fingerprint

              = if staff?(tag_change) do
                br
                small
                  strong> Stop!
                  ' This user is a staff member.
                  br
                  ' Ask them before reverting their changes.
            = if tag_change_retained(tag_change) do
              td.success Yes
            - else
              td.danger No
            = if reverts_tag_changes?(@conn) do
              td
                a href=~p"/images/#{tag_change.image}/tag_changes/#{tag_change}" data-method="delete" data-confirm="Are you really, really sure?"
                  ' Delete from history

  .block__header
    = @pagination

  = if reverts_tag_changes?(@conn) do
    = submit "Revert selected", class: "button", data: [confirm: "Are you really, really sure?"]
