-
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
Disable <Choose a Role> option to prevent error while adding Group #5933
Disable <Choose a Role> option to prevent error while adding Group #5933
Conversation
@miq-bot add_label bug, ivanchuk/yes, hammer/yes |
a648843
to
d6ae9a7
Compare
@@ -70,8 +70,8 @@ | |||
= link_to(@group.miq_user_role.name, "#", params) | |||
- else | |||
= select_tag('group_role', | |||
options_for_select(@edit[:roles].sort, @edit[:new][:role]), | |||
:class => "selectpicker") | |||
options_for_select(@edit[:roles].sort, selected: @edit[:new][:role], disabled: ["<Choose a Role>", 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.
@hstastna use arrows instead of the colon for selected
and disabled
parameters
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 Done ;)
4c2426b
to
6e6cf95
Compare
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.
Now, Add button get's enabled only after setting Project/Tenant field, but submitting the form without setting Role in the dropdown throws an error:
[----] F, [2019-08-05T12:04:41.126740 #27616:2b18c50e5070] FATAL -- : Error caught: [ActiveRecord::RecordNotFound] Couldn't find MiqUser
Role with 'id'=<Choose a Role>
/home/rblanco/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.1.7/lib/active_record/relation/finder_methods.rb:343:in `rai
se_record_not_found_exception!'
/home/rblanco/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.1.7/lib/active_record/relation/finder_methods.rb:460:in `fin
d_one'
/home/rblanco/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.1.7/lib/active_record/relation/finder_methods.rb:440:in `fin
d_with_ids'
/home/rblanco/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.1.7/lib/active_record/relation/finder_methods.rb:66:in `find
'
/home/rblanco/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.1.7/lib/active_record/querying.rb:3:in `find'
/home/rblanco/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.1.7/lib/active_record/core.rb:178:in `find'
/home/rblanco/devel/manageiq-ui-classic/app/controllers/ops_controller/ops_rbac.rb:1225:in `rbac_group_set_record_vars'
/home/rblanco/devel/manageiq-ui-classic/app/controllers/ops_controller/ops_rbac.rb:673:in `rbac_edit_save_or_add'
/home/rblanco/devel/manageiq-ui-classic/app/controllers/ops_controller/ops_rbac.rb:92:in `rbac_group_edit'
The Add button should be enabled after setting both Project/Tenant and Role fields.
Also "Description can't be blank" error message shows up if you skip the Description, so even this field should probably affect Add button, to prevent the error message.
@@ -1226,7 +1222,7 @@ module OpsController::OpsRbac
# Set group record variables to new values
def rbac_group_set_record_vars(group)
- role = MiqUserRole.find(@edit[:new][:role])
+ role = MiqUserRole.find(@edit[:new][:role].second) if @edit[:new][:role].second.present?
group.description = @edit[:new][:description]
group.miq_user_role = role
group.tenant = Tenant.find(@edit[:new][:group_tenant]) if @edit[:new][:group_tenant]
makes it available to submit the form without Role.
6e6cf95
to
0efaef0
Compare
@romanblanco So do you think that Add button should be enabled after setting Project/Tenant, Role AND Description (everything in Group Information section)? Thank you. |
47ee19c
to
5025fcc
Compare
I think we don't want to submit the form without Role. I was told that Name, Role and Project or Tenant are required to specify for adding new Group. |
it yells if Description is missing and fails if Role is missing, I think yes. |
@romanblanco This is the logic which allows Add button to be enabled only if some Role and Tenant is set. I can add the logic also for the Name there. But I am not sure if we want this in this PR. What do you think about it? Because it's little bit different issue (Add/Save button also does not respond properly for editing a Group). And this PR should be mainly about fixing the BZ :) |
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.
LGTM 👍
@@ -69,9 +69,11 @@ | |||
%i.ff.ff-user-role{params} | |||
= link_to(@group.miq_user_role.name, "#", params) | |||
- else | |||
- disabled_item = ["<Choose a Role>", nil] | |||
- selected_item = @edit[:new][:role] ? @edit[:new][:role] : disabled_item |
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.
Perhaps shorter:
- selected_item = @edit[:new][:role] || disabled_item
5025fcc
to
bd6a93c
Compare
I've created an issue regarding Add/Save button ;) |
bd6a93c
to
029a9a0
Compare
Checked commits hstastna/manageiq-ui-classic@fc0c980~...029a9a0 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
Disable <Choose a Role> option to prevent error while adding Group (cherry picked from commit 8538572) https://bugzilla.redhat.com/show_bug.cgi?id=1730402
Ivanchuk backport details:
|
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1730402
Unexpected error occurs if we choose < Choose a Role > option in the drop down for specifying some Role while adding a new Group (after we had some Role already chosen). With disabling this option, we prevent occurring errors and we also bring more consistency because it is not possible to choose <Choose a Project/Tenant> option, too, for specifying a Project or Tenant.
With disabling option, we also prevent saving group with in the drop down.
Note:
Name, Role and Project or Tenant are required to specify for adding new Group.
Before:
After: