ManageIQ/manageiq-ui-classic

View on GitHub
app/views/layouts/_form_buttons_verify.html.haml

Summary

Maintainability
Test Coverage
- valtype ||= "default"
- statuskey  = (valtype + "_verify_status").to_sym
- record ||= nil
- record_id ||= nil
- serialize ||= false
- if record
  - id = record.id.blank? ? "new" : record.id
- else
  - id = record_id ? record_id : nil

- if session[:host_items].present?
  - verify_title_on  = _("Validate the credentials by logging into the selected Host")
- else
  - verify_title_on ||= _("Validate the credentials by logging into the Server")

%div{:id => "#{valtype}_validate_buttons_on", :style => ("display:none" unless @edit[statuskey])}
  - if serialize
    = button_tag(_("Validate"),
                 :class   => "btn btn-primary btn-xs pull-right",
                 :alt     => verify_title_on,
                 :title   => verify_title_on,
                 :onclick => "miqAjaxButton('#{url_for_only_path(:action => validate_url,
                                                       :id     => id,
                                                       :button => "validate")}', true);")
  - else
    = link_to(_("Validate"),
              {:action => validate_url,
               :button => "validate",
               :type   => valtype,
               :id     => id},
              :class                 => "btn btn-primary btn-xs pull-right",
              :alt                   => verify_title_on,
              :title                 => verify_title_on,
              :id                    => "val",
              "data-miq_sparkle_on"  => true,
              "data-miq_sparkle_off" => true,
              :remote                => true,
              "data-method"          => :post)

%div{:id => "#{valtype}_validate_buttons_off", :style => ("display:none" if @edit[statuskey])}
  = button_tag(_("Validate"),
               :class    => "btn btn-primary disabled btn-xs pull-right",
               :disabled => true)