<div class="header">
  <div class="header-inner">
    <div class="options">
      <div class="dropdown">
        <%= link_to raw('<i class="fa fa-chevron-down"></i>'), 'javascript:void(0)', class: 'import-toggle', data: {toggle: 'collapse', target: '.import-box'} %>
      </div>
    </div>
    <h3>Import issues</h3>
  </div>
</div>

<%= content_tag :div, class: 'import-box collapse' do %>
  <% Dradis::Plugins::with_feature(:import).each do |plugin| %>
  <div>
    <h5><%= plugin.plugin_description %></h5>

    <% if Dradis::Plugins::Import::Filters[plugin.plugin_name] %>
      <% Dradis::Plugins::Import::Filters[plugin.plugin_name].each do |label, klass| %>
        <% next if label == :find_one_by_field %>

        <%= form_tag import_issues_path, class: 'form-search' do %>
          <%= hidden_field_tag :scope, plugin.plugin_name %>
          <%= hidden_field_tag :filter, label %>

          <div class="control-group input-append">
            <% query = @query if (@plugin == plugin.plugin_name) && (@filter == klass) %>
            <%= text_field_tag :query, query, class: 'span2 search-query', placeholder: label.to_s.humanize  %>
            <button type="submit" class="btn">Search</button>
          </div>
        <% end %>
      <% end %>
    <% else %>
    <p>This plugin doesn't define any import filters. Contact the plugin author.</p>
    <% end %>
  </div>
  <% end %>
<% end %>
