Skip to content

Commit

Permalink
Favor complete ui string over string concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
mzazrivec committed Nov 20, 2017
1 parent 705657d commit 59a982d
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions app/helpers/application_helper/button/cockpit_console.rb
Expand Up @@ -2,11 +2,22 @@ class ApplicationHelper::Button::CockpitConsole < ApplicationHelper::Button::Bas
needs :@record

def disabled?
canned_msg = _('The web-based console is not available because the')
@error_message = _("%{canned_msg} 'Cockpit' role is not enabled." % {:canned_msg => canned_msg}) unless MiqRegion.my_region.role_active?('cockpit_ws')
record_type = @record.respond_to?(:current_state) ? _('VM') : _('Container Node')
@error_message = _("%{canned_msg} %{record_type} is not powered on" % {:canned_msg => canned_msg, :record_type => record_type}) unless on?
@error_message = _("%{canned_msg} Windows platform is not supported" % {:canned_msg => canned_msg}) unless platform_supported?(record_type)
if !MiqRegion.my_region.role_active?('cockpit_ws')
@error_message = _("The web-based console is not available because the 'Cockpit' role is not enabled.")
end

if !on?
@error_message = if @record.respond_to?(:current_state)
_('The web-based console is not available because the VM is not powered on')
else
_('The web-based console is not available because the Container Node is not powered on')
end
end

if !platform_supported?
@error_message = _('The web-based console is not available because the Windows platform is not supported')
end

@error_message.present?
end

Expand All @@ -17,8 +28,8 @@ def on?
@record.ready_condition_status == 'True' if @record.respond_to?(:ready_condition_status) # Container status
end

def platform_supported?(record_type)
if record_type == 'VM'
def platform_supported?
if @record.respond_to?(:current_state)
@record.platform.downcase != 'windows'
else
true
Expand Down

0 comments on commit 59a982d

Please sign in to comment.