ManageIQ/manageiq-ui-classic

View on GitHub
app/helpers/application_helper/button/instance_disassociate_floating_ip.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class ApplicationHelper::Button::InstanceDisassociateFloatingIp < ApplicationHelper::Button::Basic
  def visible?
    @record.class.supports?(:disassociate_floating_ip)
  end

  def disabled?
    if !@record.supports?(:disassociate_floating_ip)
      @error_message = @record.unsupported_reason(:disassociate_floating_ip)
    elsif @record.number_of(:floating_ips).zero?
      @error_message = _("Instance \"%{name}\" does not have any associated Floating IPs") % { :name => @record.name }
    end
    @error_message.present?
  end
end