diff --git a/app/helpers/application_helper/button/db_refresh.rb b/app/helpers/application_helper/button/db_refresh.rb new file mode 100644 index 00000000000..9691a1dd919 --- /dev/null +++ b/app/helpers/application_helper/button/db_refresh.rb @@ -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 diff --git a/app/helpers/application_helper/toolbar/vmdb_table_center.rb b/app/helpers/application_helper/toolbar/vmdb_table_center.rb index 0dc72333762..e716db9f6e4 100644 --- a/app/helpers/application_helper/toolbar/vmdb_table_center.rb +++ b/app/helpers/application_helper/toolbar/vmdb_table_center.rb @@ -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 diff --git a/app/helpers/application_helper/toolbar/vmdb_tables_center.rb b/app/helpers/application_helper/toolbar/vmdb_tables_center.rb index b34c2ade5de..79a07614d60 100644 --- a/app/helpers/application_helper/toolbar/vmdb_tables_center.rb +++ b/app/helpers/application_helper/toolbar/vmdb_tables_center.rb @@ -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 diff --git a/app/helpers/application_helper/toolbar_builder.rb b/app/helpers/application_helper/toolbar_builder.rb index 049c51d1fe2..ac8a74c35bb 100644 --- a/app/helpers/application_helper/toolbar_builder.rb +++ b/app/helpers/application_helper/toolbar_builder.rb @@ -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 diff --git a/spec/helpers/application_helper/buttons/db_refresh_spec.rb b/spec/helpers/application_helper/buttons/db_refresh_spec.rb new file mode 100644 index 00000000000..60e29b5549c --- /dev/null +++ b/spec/helpers/application_helper/buttons/db_refresh_spec.rb @@ -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