Skip to content

Commit

Permalink
Merge pull request #12559 from jzigmund/bz1389055-smartstate_analysis…
Browse files Browse the repository at this point in the history
…_missing

Fix missing Smart State Analysis button on Cloud Instances list view
  • Loading branch information
martinpovolny authored Dec 1, 2016
2 parents c239b69 + e63f2a0 commit fb15bf9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 deletions.
5 changes: 2 additions & 3 deletions app/helpers/application_helper/button/basic_image.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class ApplicationHelper::Button::BasicImage < ApplicationHelper::Button::Basic
def visible?
@sb.fetch_path(:trees, :vandt_tree, :active_node).blank? ||
(@sb[:trees][:vandt_tree][:active_node] != "xx-arch" &&
@sb[:trees][:vandt_tree][:active_node] != "xx-orph")
active_node = @view_context.x_node
active_node.blank? || (active_node != "xx-arch" && active_node != "xx-orph")
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ def calculate_properties
end

def visible?
return true if @display == "instances"
@record.supports_smartstate_analysis? && @record.has_proxy?
end

def disabled?
return false if @display == "instances"
!(@record.supports_smartstate_analysis? && @record.has_active_proxy?)
end
end
4 changes: 2 additions & 2 deletions app/helpers/application_helper/toolbar/vm_clouds_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class ApplicationHelper::Toolbar::VmCloudsCenter < ApplicationHelper::Toolbar::B
:url_parms => "main_div",
:confirm => N_("Perform SmartState Analysis on the selected items?"),
:enabled => false,
:onwhen => "1+",
:klass => ApplicationHelper::Button::VmInstanceTemplateScan),
:klass => ApplicationHelper::Button::BasicImage,
:onwhen => "1+"),
button(
:instance_compare,
'product product-compare fa-lg',
Expand Down
21 changes: 7 additions & 14 deletions spec/helpers/application_helper/buttons/basic_image_spec.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
describe ApplicationHelper::Button::BasicImage do
describe '#visible?' do
before do
@view_context = setup_view_context_with_sandbox({:trees => {:vandt_tree => {:active_node => "xx-arch"}},
:active_tree => :vandt_tree})
end
context "in list of archived VMs" do
before do
allow(ApplicationHelper).to receive(:get_record_cls).and_return(nil)
@sb = {:trees => {:vandt_tree => {:active_node => "xx-arch"}}}
end

it "will be skipped" do
view_context = setup_view_context_with_sandbox({})
button = described_class.new(view_context, {}, {'sb' => @sb}, {})
button = described_class.new(@view_context, {}, {}, {})
expect(button.visible?).to be_falsey
end
end

context "in list of orphaned VMs" do
before do
allow(ApplicationHelper).to receive(:get_record_cls).and_return(nil)
@sb = {:trees => {:vandt_tree => {:active_node => "xx-arch"}}}
end

it "will be skipped" do
view_context = setup_view_context_with_sandbox({})
button = described_class.new(view_context, {}, {'sb' => @sb}, {})
@view_context.x_node = "xx-orph"
button = described_class.new(@view_context, {}, {}, {})
expect(button.visible?).to be_falsey
end
end
Expand Down

0 comments on commit fb15bf9

Please sign in to comment.