-
Notifications
You must be signed in to change notification settings - Fork 356
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
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2b51370
Create mixin with methods that determine the active tree and tab
9af4dce
Refactor schedule_run_now button in Ops
630cc05
Refactor buttons in ops' diagnostics tree
af8a4e2
Edit GenericFeatureButton's feature retrieval
c4d4d2b
Refactor buttons in ops' rbac_tree
b277753
Refactor buttons in ops' vmdb_tree
34ea18f
Remove #hide_button_ops method
f38754d
Review response: Simplify rbac_tree button assignements
5587124
Review response: Rollback changes done to TenantEdit class and its un…
b318fc7
Review response: Add icon to schedule_run_now button
e87b26f
Review response: Set ScheduleRunNow parent to Basic
164ce76
Assign reload_server_tree button to its class
0cd906f
Review response: Rollback GenericFeatureButton#initialize implementation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
app/helpers/application_helper/button/rbac_common_feature_button.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,11 @@ | ||
class ApplicationHelper::Button::RbacCommonFeatureButton < ApplicationHelper::Button::GenericFeatureButton | ||
delegate :rbac_common_feature_for_buttons, :to => :@view_context | ||
|
||
def role_allows_feature? | ||
role_allows?(:feature => rbac_common_feature_for_buttons(@feature)) | ||
end | ||
|
||
def visible? | ||
true | ||
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,7 @@ | ||
class ApplicationHelper::Button::TenantAdd < ApplicationHelper::Button::GenericFeatureButton | ||
class ApplicationHelper::Button::TenantAdd < ApplicationHelper::Button::RbacCommonFeatureButton | ||
needs :@record | ||
delegate :role_allows?, :rbac_common_feature_for_buttons, :to => :@view_context | ||
|
||
def role_allows_feature? | ||
role_allows?(:feature => rbac_common_feature_for_buttons(self[:child_id])) | ||
end | ||
|
||
def visible? | ||
true | ||
[email protected]? | ||
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,5 @@ | ||
class ApplicationHelper::Button::TenantEdit < ApplicationHelper::Button::Basic | ||
needs :@record | ||
|
||
class ApplicationHelper::Button::TenantEdit < ApplicationHelper::Button::RbacCommonFeatureButton | ||
def disabled? | ||
@record.source | ||
@record.try!(:source) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need to modify this class, because it is not needed to add this to summary toolbar. |
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,8 @@ class ApplicationHelper::Toolbar::TenantsCenter < ApplicationHelper::Toolbar::Ba | |
N_('Edit the selected item'), | ||
:url_parms => "main_div", | ||
:enabled => false, | ||
:onwhen => "1"), | ||
:onwhen => "1", | ||
:klass => ApplicationHelper::Button::TenantEdit), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this class because you can use |
||
button( | ||
:rbac_tenant_delete, | ||
'pficon pficon-delete fa-lg', | ||
|
@@ -22,15 +23,17 @@ class ApplicationHelper::Toolbar::TenantsCenter < ApplicationHelper::Toolbar::Ba | |
:url_parms => "main_div", | ||
:confirm => N_("Delete all selected items and all of their children?"), | ||
:enabled => false, | ||
:onwhen => "1+"), | ||
:onwhen => "1+", | ||
:klass => ApplicationHelper::Button::RbacCommonFeatureButton), | ||
button( | ||
:rbac_tenant_manage_quotas, | ||
'pficon pficon-edit fa-lg', | ||
N_('Select a single item to manage quotas'), | ||
N_('Manage Quotas for the Selected Item'), | ||
:url_parms => "main_div", | ||
:enabled => false, | ||
:onwhen => "1"), | ||
:onwhen => "1", | ||
:klass => ApplicationHelper::Button::RbacCommonFeatureButton), | ||
] | ||
), | ||
]) | ||
|
@@ -52,7 +55,8 @@ class ApplicationHelper::Toolbar::TenantsCenter < ApplicationHelper::Toolbar::Ba | |
t, | ||
:url_parms => "main_div", | ||
:enabled => false, | ||
:onwhen => "1+"), | ||
:onwhen => "1+", | ||
:klass => ApplicationHelper::Button::RbacCommonFeatureButton), | ||
] | ||
), | ||
]) | ||
|
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
21 changes: 21 additions & 0 deletions
21
spec/helpers/application_helper/buttons/rbac_common_feature_button_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,21 @@ | ||
describe ApplicationHelper::Button::RbacCommonFeatureButton do | ||
let(:session) { Hash.new } | ||
let(:view_context) { setup_view_context_with_sandbox({}) } | ||
let(:button) { described_class.new(view_context, {}, {}, {:options => {:feature => feature}}) } | ||
|
||
before { login_as FactoryGirl.create(:user, :features => 'rbac_tenant_add') } | ||
|
||
describe '#role_allows_feature?' do | ||
subject { button.role_allows_feature? } | ||
%w(rbac_tenant_add rbac_project_add).each do |feature| | ||
context 'when user role allows feature' do | ||
let(:feature) { feature } | ||
it { expect(subject).to be_truthy } | ||
end | ||
end | ||
context 'when user role does not allow feature' do | ||
let(:feature) { 'not_allowed_feature' } | ||
it { expect(subject).to be_falsey } | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vecerek I was pretty confused at this point, because you check availability of a
@feature
for a role at a lot of buttons, where you don't even define the feature to check (in toolbar).After explanation, I've understood, that's why you've changed
feature
loading in previous commit af8a4e2, but still, it seems i bit wrong.Isn't it better to use
GenericFeatureButton
based class only for the two buttons, that therbac_common_feature_for_buttons
method checks?/cc @PanSpagetka
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it look confusing when you have button named
RbacCommonFeatureButton
and you intentionally don't set any feature. Also I think, that it will hide button, which probably isn't right.