-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #417 from vecerek/toolbar_refactoring__ops
Toolbar refactoring: Ops
- Loading branch information
Showing
33 changed files
with
257 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
7 changes: 7 additions & 0 deletions
7
app/helpers/application_helper/button/diagnostics_audit_logs.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ApplicationHelper::Button::DiagnosticsAuditLogs < ApplicationHelper::Button::Basic | ||
include ApplicationHelper::Button::Mixins::ActiveContextMixin | ||
|
||
def visible? | ||
active_tree?(:diagnostics_tree) && active_tab?('diagnostics_audit_log') | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
app/helpers/application_helper/button/diagnostics_evm_logs.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ApplicationHelper::Button::DiagnosticsEvmLogs < ApplicationHelper::Button::Basic | ||
include ApplicationHelper::Button::Mixins::ActiveContextMixin | ||
|
||
def visible? | ||
active_tree?(:diagnostics_tree) && active_tab?('diagnostics_evm_log') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ApplicationHelper::Button::DiagnosticsLogs < ApplicationHelper::Button::CollectLogs | ||
include ApplicationHelper::Button::Mixins::ActiveContextMixin | ||
|
||
def visible? | ||
active_tree?(:diagnostics_tree) && active_tab?('diagnostics_collect_logs') | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
app/helpers/application_helper/button/diagnostics_production_logs.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ApplicationHelper::Button::DiagnosticsProductionLogs < ApplicationHelper::Button::Basic | ||
include ApplicationHelper::Button::Mixins::ActiveContextMixin | ||
|
||
def visible? | ||
active_tree?(:diagnostics_tree) && active_tab?('diagnostics_production_log') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ApplicationHelper::Button::DiagnosticsSummary < ApplicationHelper::Button::Basic | ||
include ApplicationHelper::Button::Mixins::ActiveContextMixin | ||
|
||
def visible? | ||
active_tree?(:diagnostics_tree) && active_tab?('diagnostics_summary') | ||
end | ||
end |
17 changes: 17 additions & 0 deletions
17
app/helpers/application_helper/button/mixins/active_context_mixin.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module ApplicationHelper::Button::Mixins::ActiveContextMixin | ||
def active_tree?(tree) | ||
if tree.kind_of?(Array) | ||
tree.include?(@view_context.x_active_tree) | ||
else | ||
tree == @view_context.x_active_tree | ||
end | ||
end | ||
|
||
def active_tab?(tab) | ||
if tab.kind_of?(Array) | ||
tab.include?(@view_context.active_tab) | ||
else | ||
tab == @view_context.active_tab | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
class ApplicationHelper::Button::RefreshWorkers < ApplicationHelper::Button::Basic | ||
needs :@record, :@sb | ||
include ApplicationHelper::Button::Mixins::ActiveContextMixin | ||
|
||
def visible? | ||
@view_context.x_active_tree == :diagnostics_tree && @sb[:active_tab] == 'diagnostics_workers' | ||
active_tree?(:diagnostics_tree) && active_tab?('diagnostics_workers') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ApplicationHelper::Button::ReloadServerTree < ApplicationHelper::Button::Basic | ||
include ApplicationHelper::Button::Mixins::ActiveContextMixin | ||
|
||
def visible? | ||
active_tree?(:diagnostics_tree) && active_tab?(%w(diagnostics_roles_servers diagnostics_servers_roles)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ApplicationHelper::Button::ScheduleRunNow < ApplicationHelper::Button::Basic | ||
include ApplicationHelper::Button::Mixins::ActiveContextMixin | ||
|
||
def visible? | ||
active_tree?(:settings_tree) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
class ApplicationHelper::Button::TenantAdd < ApplicationHelper::Button::GenericFeatureButton | ||
needs :@record | ||
delegate :role_allows?, :rbac_common_feature_for_buttons, :to => :@view_context | ||
delegate :rbac_common_feature_for_buttons, :to => :@view_context | ||
|
||
def role_allows_feature? | ||
role_allows?(:feature => rbac_common_feature_for_buttons(self[:child_id])) | ||
role_allows?(:feature => rbac_common_feature_for_buttons(@feature)) | ||
end | ||
|
||
def visible? | ||
true | ||
!@record.project? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ApplicationHelper::Button::ZoneLogDepotEdit < ApplicationHelper::Button::DiagnosticsLogs | ||
def visible? | ||
return false if active_tree?(:diagnostics_tree) && | ||
(active_tab?('diagnostics_roles_servers') || active_tab?('diagnostics_servers_roles')) | ||
super | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
spec/helpers/application_helper/buttons/db_refresh_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.