-
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
Conversation
2623819
to
33d903d
Compare
@vecerek Cannot apply the following label because they are not recognized: pending_core |
@vecerek Cannot apply the following label because they are not recognized: pending-core |
1 similar comment
@vecerek Cannot apply the following label because they are not recognized: pending-core |
9019e7c
to
6700090
Compare
- Use Hash#fetch, since the feature might not always be specified. Later, Hash#dig could be used.
6700090
to
34ea18f
Compare
@@ -23,7 +23,8 @@ class ApplicationHelper::Toolbar::MiqScheduleCenter < ApplicationHelper::Toolbar | |||
:schedule_run_now, |
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.
'fa fa-play-circle-o fa-lg',
missing here
@@ -0,0 +1,7 @@ | |||
class ApplicationHelper::Button::ScheduleRunNow < ApplicationHelper::Button::ButtonWithoutRbacCheck |
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 Hm, i know I've suggested to use ButtonWithoutRbacCheck
class, but now, when I'm trying the button, I'm getting back error message:
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
@@ -3,7 +3,8 @@ class ApplicationHelper::Button::GenericFeatureButton < ApplicationHelper::Butto | |||
|
|||
def initialize(view_context, view_binding, instance_data, props) | |||
super | |||
@feature = props[:options][:feature] | |||
# TODO: use #dig when ruby2.2 is no longer supported | |||
@feature = props.fetch(:options, {}).fetch(:feature, nil) |
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 Why not just
@feature = props.fetch_path(:options, :feature)
delegate :rbac_common_feature_for_buttons, :to => :@view_context | ||
|
||
def role_allows_feature? | ||
role_allows?(:feature => rbac_common_feature_for_buttons(@feature)) |
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 the rbac_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.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this class because you can use Basic
button.
def disabled? | ||
@record.source | ||
@record.try!(:source) |
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.
There is no need to modify this class, because it is not needed to add this to summary toolbar.
…necessary assignement in tenants_center toolbar
When ButtonWithoutRbacCheck has been the parent, an error message has been being thrown which stated: 'The user is not authorized for this task or item.'; even though the user has had an admin role.
@vecerek Please complete the description, at least add the related issues |
@@ -0,0 +1,7 @@ | |||
class ApplicationHelper::Button::ReloadServerTree < ApplicationHelper::Button::Basic |
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.
No button has been assigned to this class. The assignment needs to be added.
/cc @romanblanco
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.
@romanblanco just pushed the changes, could you check it in UI, please?
@@ -4,7 +4,7 @@ class ApplicationHelper::Button::GenericFeatureButton < ApplicationHelper::Butto | |||
def initialize(view_context, view_binding, instance_data, props) | |||
super | |||
# TODO: use #dig when ruby2.2 is no longer supported | |||
@feature = props.fetch(:options, {}).fetch(:feature, nil) | |||
@feature = props.fetch_path(:options, :feature) |
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 Please remove this prevention. As we discussed, we'd like to have it in a way, that if you have a button that should check for a feature, you should always set the feature in a toolbar.
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.
done, changes pushed
Once all the mentioned issues are fixed, it LGTM. Good job, @vecerek! 👍 |
All issues fixed. |
Also add the button property feature option in specs.
9cc0497
to
0cd906f
Compare
Checked commits vecerek/manageiq-ui-classic@2b51370~...0cd906f with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 app/helpers/application_helper/toolbar/diagnostics_region_center.rb
app/helpers/application_helper/toolbar/diagnostics_server_center.rb
app/helpers/application_helper/toolbar/diagnostics_zone_center.rb
app/helpers/application_helper/toolbar/miq_schedule_center.rb
app/helpers/application_helper/toolbar/miq_schedules_center.rb
app/helpers/application_helper/toolbar/vmdb_table_center.rb
app/helpers/application_helper/toolbar/vmdb_tables_center.rb
|
Links
Parent issue: ManageIQ/manageiq#6259
Related issue: ManageIQ/manageiq#6554
Pending (not anymore): ManageIQ/manageiq#13982
Pivotal Tracker: https://www.pivotaltracker.com/story/show/133670283