Skip to content

Commit

Permalink
Generic toolbar button for skip, disable and error message
Browse files Browse the repository at this point in the history
(transferred from ManageIQ/manageiq@5e9ecb1)
  • Loading branch information
PanSpagetka committed Aug 10, 2016
1 parent 4318639 commit a85cfb1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class ApplicationHelper::Button::GenericFeatureButtonWithDisable < ApplicationHelper::Button::GenericFeatureButton
needs_record

def calculate_properties
self[:enabled] = !(self[:title] = @error_message if disabled?)
end

def disabled?
<<<<<<< HEAD
!!(@error_message = @record.is_available_now_error_message(@feature))
=======
begin
begin
@error_message = @record.try(:unsupported_reason, @feature)
rescue NoMethodError
@error_message = @record.try(:is_available_now_error_message, @feature) if @error_message.nil?
end
rescue
@error_message = 'Feature is not supported.'
true
end
>>>>>>> 407f786... fixup
end
end
5 changes: 3 additions & 2 deletions app/helpers/application_helper/toolbar/x_vm_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ApplicationHelper::Toolbar::XVmCenter < ApplicationHelper::Toolbar::Basic
'product product-clone fa-lg',
t = N_('Clone this VM'),
t,
:klass => ApplicationHelper::Button::GenericFeatureButton,
:klass => ApplicationHelper::Button::GenericFeatureButton,
:options => {:feature => :clone}),
button(
:vm_publish,
Expand Down Expand Up @@ -187,7 +187,8 @@ class ApplicationHelper::Toolbar::XVmCenter < ApplicationHelper::Toolbar::Basic
N_('Power On'),
:image => "power_on",
:confirm => N_("Power On this VM?"),
:klass => ApplicationHelper::Button::VmStart),
:klass => ApplicationHelper::Button::GenericFeatureButtonWithDisable,
:options => {:feature => :start}),
button(
:vm_stop,
nil,
Expand Down

0 comments on commit a85cfb1

Please sign in to comment.