app/controllers/repository_controller.rb
# handle buttons pressed on the button bar
handle buttons pressed on the button bar
handle buttons pressed on the button bar
def button
    @edit = session[:edit]                          
    params[:display] = "vms" if @display == "vms"   
    if params[:pressed].starts_with?("vm_", 
                                     "miq_template_",
                                     "guest_")
      pfx = pfx_for_vm_button_pressed(params[:pressed])
      process_vm_buttons(pfx)
      return if ["#{pfx}_compare", "#{pfx}_tag", "#{pfx}_policy_sim", "#{pfx}_protect", "#{pfx}_right_size",
                 "#{pfx}_retire", "#{pfx}_ownership", "#{pfx}_reconfigure"].include?(params[:pressed]) &&
                @flash_array.nil? 
      unless ["#{pfx}_edit", "#{pfx}_miq_request_new", "#{pfx}_clone", "#{pfx}_migrate", "#{pfx}_publish"].include?(params[:pressed])
        @refresh_div = "main_div"
        @refresh_partial = "layouts/gtl"
        show
      end
    else                                        
      params[:page] = @current_page unless @current_page.nil? 
      @refresh_div = "main_div" 
      redirect_to :action => "new" if params[:pressed] == "new"
      deleterepos if params[:pressed] == "repository_delete"
      refreshrepos if params[:pressed] == "refresh"
      refreshrepos if params[:pressed] == "repository_refresh"
      tag(Repository) if params[:pressed] == "repository_tag"
      assign_policies(Repository) if params[:pressed] == "repository_protect"
      edit_record if params[:pressed] == "repository_edit"
      return if ["repository_tag", "repository_protect"].include?(params[:pressed]) &&
                @flash_array.nil? 
      unless @refresh_partial 
        add_flash(_("Button not yet implemented"), :error)
        @refresh_partial = "layouts/flash_msg"
        @refresh_div = "flash_msg_div"
      end
    end
    if !@flash_array.nil? && params[:pressed] == "delete" && @single_delete
      render :update do |page|
        page.redirect_to :action => 'show_list', :flash_msg => @flash_array[0][:message]  
      end
    elsif params[:pressed].ends_with?("_edit") || ["#{pfx}_miq_request_new", "#{pfx}_clone",
                                                   "#{pfx}_migrate", "#{pfx}_publish"].include?(params[:pressed])
      render_or_redirect_partial(pfx)
    else
      if @refresh_div == "main_div" && @lastaction == "show_list"
        replace_gtl_main_div
      else
        render_flash
      end
    end
  end
def button @edit = session [ :edit ] params [ :display ] = "vms" if @display == "vms" if params [ :pressed ] . starts_with? ( "vm_" , "miq_template_" , "guest_" ) pfx = pfx_for_vm_button_pressed ( params [ :pressed ] ) process_vm_buttons ( pfx ) return if [ "#{pfx}_compare" , "#{pfx}_tag" , "#{pfx}_policy_sim" , "#{pfx}_protect" , "#{pfx}_right_size" , "#{pfx}_retire" , "#{pfx}_ownership" , "#{pfx}_reconfigure" ] . include? ( params [ :pressed ] ) && @flash_array . nil? unless [ "#{pfx}_edit" , "#{pfx}_miq_request_new" , "#{pfx}_clone" , "#{pfx}_migrate" , "#{pfx}_publish" ] . include? ( params [ :pressed ] ) @refresh_div = "main_div" @refresh_partial = "layouts/gtl" show end else params [ :page ] = @current_page unless @current_page . nil? @refresh_div = "main_div" redirect_to :action => "new" if params [ :pressed ] == "new" deleterepos if params [ :pressed ] == "repository_delete" refreshrepos if params [ :pressed ] == "refresh" refreshrepos if params [ :pressed ] == "repository_refresh" tag ( Repository ) if params [ :pressed ] == "repository_tag" assign_policies ( Repository ) if params [ :pressed ] == "repository_protect" edit_record if params [ :pressed ] == "repository_edit" return if [ "repository_tag" , "repository_protect" ] . include? ( params [ :pressed ] ) && @flash_array . nil? unless @refresh_partial add_flash ( _ ( "Button not yet implemented" ) , :error ) @refresh_partial = "layouts/flash_msg" @refresh_div = "flash_msg_div" end end if ! @flash_array . nil? && params [ :pressed ] == "delete" && @single_delete render :update do | page | page . redirect_to :action => 'show_list' , :flash_msg => @flash_array [ 0 ] [ :message ] end elsif params [ :pressed ] . ends_with? ( "_edit" ) || [ "#{pfx}_miq_request_new" , "#{pfx}_clone" , "#{pfx}_migrate" , "#{pfx}_publish" ] . include? ( params [ :pressed ] ) render_or_redirect_partial ( pfx ) else if @refresh_div == "main_div" && @lastaction == "show_list" replace_gtl_main_div else render_flash end end end
handle buttons pressed on the button bar
handle buttons pressed on the button bar
# Restore @edit for adv search box # Were we displaying vms # Handle buttons from sub-items screen # Compare or tag screen is showing, so return # Handle Repo buttons # Save current page for list refresh # Default div for button.rjs to refresh #     scanrepos if params[:pressed] == "scan" # Tag screen showing, so return # if no button handler ran, show not implemented msg # redirect to build the retire screen