Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Favor complete ui strings over string concatenation #2765

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is intended? (does not look translation related)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, intended. In the code above, the record_type argument passed in would either
be _('VM') or _('Container Node'). Now that wouldn't really work in non-English locales,
would it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Thx!

@record.platform.downcase != 'windows'
else
true
Expand Down