Skip to content

Commit

Permalink
Refactor buttons in ops' vmdb_tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Attila Vecerek committed Feb 23, 2017
1 parent c4d4d2b commit b277753
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
7 changes: 7 additions & 0 deletions app/helpers/application_helper/button/db_refresh.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ApplicationHelper::Button::DbRefresh < ApplicationHelper::Button::Basic
include ApplicationHelper::Button::Mixins::ActiveContextMixin

def visible?
active_tab?(%w(db_connections db_details db_indexes db_settings))
end
end
3 changes: 2 additions & 1 deletion app/helpers/application_helper/toolbar/vmdb_table_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class ApplicationHelper::Toolbar::VmdbTableCenter < ApplicationHelper::Toolbar::
:db_refresh,
'fa fa-repeat fa-lg',
N_('Reload Current Display'),
nil),
nil,
:klass => ApplicationHelper::Button::DbRefresh),
])
end
3 changes: 2 additions & 1 deletion app/helpers/application_helper/toolbar/vmdb_tables_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class ApplicationHelper::Toolbar::VmdbTablesCenter < ApplicationHelper::Toolbar:
:db_refresh,
'fa fa-repeat fa-lg',
N_('Reload Current Display'),
nil),
nil,
:klass => ApplicationHelper::Button::DbRefresh),
])
end
2 changes: 1 addition & 1 deletion app/helpers/application_helper/toolbar_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def hide_button_ops(id)
when :rbac_tree
return false
when :vmdb_tree
return !["db_connections", "db_details", "db_indexes", "db_settings"].include?(@sb[:active_tab])
return false
else
return true
end
Expand Down
18 changes: 18 additions & 0 deletions spec/helpers/application_helper/buttons/db_refresh_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
describe ApplicationHelper::Button::DbRefresh do
let(:view_context) { setup_view_context_with_sandbox(:active_tab => tab) }
let(:button) { described_class.new(view_context, {}, {}, {}) }

describe '#visible?' do
subject { button.visible? }
%w(db_details db_indexes db_settings db_connections).each do |tree|
context "when active_tree == #{tree}" do
let(:tab) { tree }
it { expect(subject).to be_truthy }
end
end
context 'when !active_tree.in?(%w(db_details db_indexes db_settings db_connections))' do
let(:tab) { 'something_else' }
it { expect(subject).to be_falsey }
end
end
end

0 comments on commit b277753

Please sign in to comment.