ManageIQ/manageiq-ui-classic

View on GitHub
app/views/miq_request/_prov_dialog_cloud_quota.html.haml

Summary

Maintainability
Test Coverage
-# wf       The workflow object currently in use
-# dialog   The name (symbol) of the selected dialog
-# prefix   view prefix
-# keys     field keys

- if @edit && @edit.fetch_path(:new, :cloud_tenant) && @edit.fetch_path(:new, :instance_type)
  - cloud_tenant_name = @edit[:new][:cloud_tenant][1]
  - cloud_tenant_id   = @edit[:new][:cloud_tenant][0]
  - instance_type     = @edit[:new][:instance_type][1]
  - placement_auto    = @edit[:new][:placement_auto][0]
  -# [:service, :quota_name, "label"]
  - quotas = [[:compute, :instances, _("instances")], [:compute, :cores, _("vcpus")], [:compute, :ram, _("(MB) memory")]]
  - quotas = quotas.each_with_object({}) { |q, h| h[q[2]] = lookup_quota(cloud_tenant_id, q[0], q[1]) }

#cloud_quota
  %p{:class => "legend"}
    = _("Cloud Quota")
  - if placement_auto
    = _("Cloud Tenant:")
    %strong
      = _("Automatic Placement")
  - elsif cloud_tenant_name
    = _("Cloud Tenant:")
    %strong
      = cloud_tenant_name
  - else
    = _("Please select a Cloud Tenant from the Environment Tab")
  %br
  - if instance_type
    = _("Instance Type:")
    %strong
      = instance_type
    %br
    - quotas.each do |label, quota|
      - if quota
        #{quota.value - quota.used} #{label} #{_('available')}
        %br
  - else
    = _("Please select an Instance Type from above")
  %br