ActiveAdmin.register JamRuby::ArtifactUpdate, :as => 'Artifacts' do
  menu :label => 'Artifacts', :parent => 'Operations'

  config.sort_order = 'product,environment'
  #config.batch_actions = false
  #config.clear_action_items!
  #config.filters = false


  form :html => {:multipart => true} do |f|
    f.inputs "Details" do
      f.input :version, :hint => "Should match Jenkins build number of artifact"
      f.input :environment, :hint => "Typically just 'public'"
      f.input :product, :as => :select, :collection => JamRuby::ArtifactUpdate::PRODUCTS
    end
    f.inputs "Artifact Upload" do
      f.input :uri, :as => :file, :hint => "Upload the artifact from Jenkins"
    end

    f.actions
  end

  action_item  :only => [:show] do
    link_to('Send Client Update Notice', send_client_update_notice_admin_artifact_path(resource.id))
  end

  member_action :send_client_update_notice, :method => :get do
    resource.send_notice
    redirect_to :back
  end

  #collection_action :upload_artifact, :method => :post do
  #    # Do some CSV importing work here...
  #    redirect_to :action => :index, :notice => "CSV imported successfully!"
  #end
end
