<div class="modal is-with-backdrop" id="mod-tools-<%= post.id %>">
  <div class="modal--container">
    <div class="modal--header">
      <button class="button is-close-button modal--header-button" data-modal="#mod-tools-<%= post.id %>">&times;</button>
      Moderator Tools
    </div>
    <div class="modal--body">
      <% if post.answer? %>
        <details>
          <summary>Convert to comment</summary>
          <p>
            Converts this answer to a comment (or series of comments, if it's too long for one) on the post you specify.
          </p>
          <%= form_tag convert_to_comment_path(post), remote: true, class: 'js-convert-to-comment' do %>
            <div class="form-group">
              <%= label_tag :post_id, 'Post ID', class: 'form-element', for: "post_id_#{post.id}" %>
              <span class="form-caption">Enter the ID of the post on which this answer should become a comment.</span>
              <%= number_field_tag :post_id, nil, class: 'form-element', id: "post_id_#{post.id}" %>
            </div>

            <%= submit_tag 'Convert', class: 'button is-filled'  %>
          <% end %>
        </details>
      <% end %>
      <% if current_user&.has_privilege?('ChangeCategory') && (post.question? || post.article?) %>
        <details>
          <summary>Change category</summary>
          <p>
            Moves this post into another category that you specify. You must have permission to create posts there, and
            this post type must be allowed in the target category.
          </p>
          <%= form_tag change_category_path(post), remote: true, class: 'js-change-category' do %>
            <div class="form-group">
              <%= label_tag :target_id, 'Target Category', class: 'form-element', for: "target_id_#{post.id}" %>
              <span class="form-caption">Choose a category to move this post to.</span>
              <%= select_tag :target_id, options_for_select([]), include_blank: true,
                             class: 'form-element js-category-change-select', id: "target_id_#{post.id}" %>
            </div>

            <%= submit_tag 'Move', class: 'button is-filled' %>
          <% end %>
        </details>
      <% end %>
      <% if moderator? && !post.comments_disabled %>
        <details>
          <summary>Disable comments</summary>
          <p>
            Disallows comments by non-moderators. Should only be used rarely.
          </p>
          <%= form_tag post_comments_allowance_toggle_path(post), remote: true, class: 'js-toggle-comments' do %>
            <div class="form-group">
              <%= label_tag :delete_all_comments, 'Purge all comments?', class: 'form-element', for: "purge_comments_id_#{post.id}" %>
              <div class="form-caption">You can optionally remove all comments. You can undelete them manually later.</div>
              <%= check_box_tag :delete_all_comments, 'yes' %>
            </div>

            <%= submit_tag 'Disable', class: 'button is-filled' %>
          <% end %>
        </details>
      <% end %>
      <% if moderator? && post.comments_disabled %>
        <details>
          <summary>Enable comments</summary>
          <p>
            Allows comments again, after they have been previously disabled.
          </p>
          <%= form_tag post_comments_allowance_toggle_path(post), remote: true, class: 'js-toggle-comments' do %>
            <%= submit_tag 'Enable', class: 'button is-filled' %>
          <% end %>
        </details>
      <% end %>
      <% if moderator? %>
        <details>
          <summary>Feature post</summary>
          <p>
            You can feature this post by linking it in the sidebar. You can edit the link options later in the moderator tools.
          </p>
          <%= form_tag post_feature_url(post), remote: true, class: 'js-feature-post' do %>
            <%= submit_tag 'Feature post', class: 'button is-filled'  %>
          <% end %>
        </details>
      <% end %>
    </div>
  </div>
</div>