Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolbar refactoring: Ops #417

Merged
merged 13 commits into from
Feb 24, 2017
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
7 changes: 7 additions & 0 deletions app/helpers/application_helper/button/schedule_run_now.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ApplicationHelper::Button::ScheduleRunNow < ApplicationHelper::Button::ButtonWithoutRbacCheck
Copy link
Member

@romanblanco romanblanco Feb 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vecerek Hm, i know I've suggested to use ButtonWithoutRbacCheck class, but now, when I'm trying the button, I'm getting back error message:

screenshot from 2017-02-23 15-18-33

So, the buttons parent class probably should be Basic, as it was apparently disabled for me for a reason, and the only strange thing to me, is that the OOTB admin user does not have rights to use this feature.

Seems like other issue to me.

cc/ @dclarizio

include ApplicationHelper::Button::Mixins::ActiveContextMixin

def visible?
active_tree?(:settings_tree)
end
end
Original file line number Diff line number Diff line change
@@ -23,7 +23,8 @@ class ApplicationHelper::Toolbar::MiqScheduleCenter < ApplicationHelper::Toolbar
:schedule_run_now,
Copy link
Member

@romanblanco romanblanco Feb 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'fa fa-play-circle-o fa-lg', missing here

'collect',
t = N_('Queue up this Schedule to run now'),
t),
t,
:klass => ApplicationHelper::Button::ScheduleRunNow),
]
),
])
Original file line number Diff line number Diff line change
@@ -52,7 +52,8 @@ class ApplicationHelper::Toolbar::MiqSchedulesCenter < ApplicationHelper::Toolba
t,
:url_parms => "main_div",
:enabled => false,
:onwhen => "1+"),
:onwhen => "1+",
:klass => ApplicationHelper::Button::ScheduleRunNow),
]
),
])
2 changes: 1 addition & 1 deletion app/helpers/application_helper/toolbar_builder.rb
Original file line number Diff line number Diff line change
@@ -367,7 +367,7 @@ def get_image(img, b_name)
def hide_button_ops(id)
case x_active_tree
when :settings_tree
return ["schedule_run_now"].include?(id)
return false
when :diagnostics_tree
case @sb[:active_tab]
when "diagnostics_audit_log"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe ApplicationHelper::Button::ScheduleRunNow do
let(:view_context) { setup_view_context_with_sandbox(:active_tree => tree) }
let(:button) { described_class.new(view_context, {}, {}, {}) }

describe '#visible?' do
subject { button.visible? }
context 'when active_tree != settings_tree' do
let(:tree) { :not_settings_tree }
it { expect(subject).to be_falsey }
end
context 'when active_tree == settings_tree' do
let(:tree) { :settings_tree }
it { expect(subject).to be_truthy }
end
end
end