app/controllers/orchestration_stack_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] = @display if ["instances"].include?(@display)  
    params[:page] = @current_page if @current_page.nil?   
    if params[:pressed].starts_with?("instance_")        
      pfx = pfx_for_vm_button_pressed(params[:pressed])
      process_vm_buttons(pfx)
      return if ["#{pfx}_policy_sim", "#{pfx}_compare", "#{pfx}_tag",
                 "#{pfx}_retire", "#{pfx}_protect", "#{pfx}_ownership",
                 "#{pfx}_refresh", "#{pfx}_right_size",
                 "#{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 if @current_page.nil?                     
      @refresh_div = "main_div" 
      case params[:pressed]
      when "orchestration_stack_delete"
        orchestration_stack_delete
      when "orchestration_stack_retire"
        orchestration_stack_retire
      when "orchestration_stack_retire_now"
        orchestration_stack_retire_now
      when "orchestration_stack_tag"
        tag(OrchestrationStack)
      end
      return if %w(orchestration_stack_retire orchestration_stack_tag).include?(params[:pressed]) &&
                @flash_array.nil? 
    end
    if @flash_array.nil? && !@refresh_partial 
      add_flash(_("Button not yet implemented"), :error)
      @refresh_partial = "layouts/flash_msg"
      @refresh_div = "flash_msg_div"
    elsif @flash_array && @lastaction == "show"
      @orchestration_stack = @record = identify_record(params[:id])
      @refresh_partial = "layouts/flash_msg"
      @refresh_div = "flash_msg_div"
    end
    if !@flash_array.nil? && params[:pressed] == "orchestration_stack_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 ] = @display if [ "instances" ] . include? ( @display ) params [ :page ] = @current_page if @current_page . nil? if params [ :pressed ] . starts_with? ( "instance_" ) pfx = pfx_for_vm_button_pressed ( params [ :pressed ] ) process_vm_buttons ( pfx ) return if [ "#{pfx}_policy_sim" , "#{pfx}_compare" , "#{pfx}_tag" , "#{pfx}_retire" , "#{pfx}_protect" , "#{pfx}_ownership" , "#{pfx}_refresh" , "#{pfx}_right_size" , "#{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 if @current_page . nil? @refresh_div = "main_div" case params [ :pressed ] when "orchestration_stack_delete" orchestration_stack_delete when "orchestration_stack_retire" orchestration_stack_retire when "orchestration_stack_retire_now" orchestration_stack_retire_now when "orchestration_stack_tag" tag ( OrchestrationStack ) end return if %w( orchestration_stack_retire orchestration_stack_tag ) . include? ( params [ :pressed ] ) && @flash_array . nil? end if @flash_array . nil? && ! @refresh_partial add_flash ( _ ( "Button not yet implemented" ) , :error ) @refresh_partial = "layouts/flash_msg" @refresh_div = "flash_msg_div" elsif @flash_array && @lastaction == "show" @orchestration_stack = @record = identify_record ( params [ :id ] ) @refresh_partial = "layouts/flash_msg" @refresh_div = "flash_msg_div" end if ! @flash_array . nil? && params [ :pressed ] == "orchestration_stack_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/hosts/storages # Save current page for list refresh # Handle buttons from sub-items screen # Control transferred to another screen, so return # Handle VMs buttons # Save current page for list refresh # Default div for button.rjs to refresh # Tag screen showing, so return # if no button handler ran, show not implemented msg