<div id="folderItemTools">
  <%= render partial: 'shared/folder_tools' %>
</div>

<%# for users w/JS, email_btn and cite_btn below are replaced by shared/folder_tools %>
<%= button_tag(type: 'submit', class: 'btn btn-outline-secondary', id: 'cite_btn', name: 'commit', value: t('blacklight.tools.citation')) do %>
    <%= icon('fas', 'list-alt', aria: { hidden: true }) + ' ' + t('blacklight.tools.citation') %>
<% end %>
<%= button_tag(type: 'submit', class: 'btn btn-outline-secondary', id: 'email_btn', name: 'commit', value: t('blacklight.tools.email')) do %>
    <%= icon('far', 'envelope', aria: { hidden: true }) + ' ' + t('blacklight.tools.email') %>
<% end %>

<% if params[:controller] == 'bookmarks' || folder_belongs_to_user(@folder) %>
    <%= button_tag(type: 'submit', class: 'btn btn-outline-secondary', id: 'remove_btn', name: 'commit', value: t('blacklight.tools.remove')) do %>
        <%= icon('fas', 'times', aria: { hidden: true }) + ' ' + t('blacklight.tools.remove') %>
    <% end %>
<% end %>

<% if current_user && !current_user.folders.empty? %>
      <div class="btn-group folder-item-control" id="copy_folder_item_control">
        <button id="folder_item_copy_dropdown" class="btn btn-outline-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          <%= icon('fas', 'random', aria: { hidden: true }) + ' ' + t('blacklight.tools.copy_to') %>
        </button>
        <div class="dropdown-menu folder_copy_list" aria-labelledby="folder_item_copy_dropdown">
          <% unless params[:controller] == 'bookmarks' %>
              <div class="folder_copy_option dropdown-item">
                <%= button_tag(type: 'submit',
                               class: 'copy_btn',
                               name: 'commit',
                               value: t('blacklight.tools.copy_to') + ' ' + t('blacklight.bookmarks.title')) do %>
                    <%= t('blacklight.bookmarks.title') %>
                <% end %>
              </div>
          <% end %>
          <% current_user.folders.each do |folder| %>
              <% unless @folder && folder.id == @folder.id %>
                  <div class="folder_copy_option dropdown-item">
                    <%= button_tag(type: 'submit',
                                   class: 'copy_btn',
                                   name: 'commit',
                                   value: t('blacklight.tools.copy_to') + ' ' + folder.id.to_s) do %>
                        <%= folder.title %>
                    <% end %>
                  </div>
              <% end %>
          <% end %>
        </div>
      </div>
<% end %>

<%= hidden_field_tag(:per_page, params[:per_page]) if params[:per_page] %>
<%= hidden_field_tag(:sort, params[:sort]) if params[:sort] %>
<%= hidden_field_tag(:view, params[:view]) if params[:view] %>
<%= hidden_field_tag(:origin, params[:controller]) %>