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
Prevent rendering User to Look Up form field twice and with same id #6565
Prevent rendering User to Look Up form field twice and with same id #6565
Conversation
@miq-bot add_label bug |
@martinpovolny @himdel Could you, please, review this? Thanks :) |
Before: user_id_ext_auth_form_group - show when httpd Now: user_id_ext_auth_form_group & user_id_form_group - merged, show the ext_auth variant when httpd We're losing the actual id (because the same form group can't have 2), but it's not used elsewhere 👍 (not tested yet) |
@himdel I am not sure if I should use Just to be clear, the div - 'the ext_auth variant' - as you've written, is now displayed no matter the authentication mode. The Retrieve button next to the field - this is what we really want to display if httpd (or not to display if no httpd). The field by itself should be there no matter the mode - I think this is the original logic and I tried to keep it, just to prevent the issues. |
So, LGTM, this works. But you can go one step further ;)... the Retrieve button is present and identical in both the So, what about... diff --git a/app/views/ops/_rbac_group_details.html.haml b/app/views/ops/_rbac_group_details.html.haml
index 51fd8d9d52..c50a872f17 100644
--- a/app/views/ops/_rbac_group_details.html.haml
+++ b/app/views/ops/_rbac_group_details.html.haml
@@ -124,7 +124,7 @@
%h3
= _("LDAP Group Look Up")
.form-horizontal
- .form-group#user_id_ext_auth_form_group
+ .form-group#user_id_form_group
%label.col-md-2.control-label
= _("User to Look Up")
.col-md-8
@@ -134,19 +134,6 @@
:class => "form-control",
"data-miq_observe" => {:interval => '.5',
:url => url}.to_json)
- - if mode == "httpd"
- .col-md-12{:align => "right", :valign => "bottom"}
- = link_to("Retrieve",
- {:action => "rbac_group_user_lookup",
- :button => "submit",
- :id => @edit[:group_id] || "new"},
- :class => "btn btn-primary",
- :alt => t = _("LDAP Group Lookup"),
- "data-miq_sparkle_on" => true,
- "data-miq_sparkle_off" => true,
- :remote => true,
- "data-method" => :post,
- :title => t)
- unless mode == "httpd"
.form-group#user_name_form_group
@@ -170,18 +157,19 @@
:class => "form-control",
"data-miq_observe" => {:interval => '.5',
:url => url}.to_json)
- .col-md-12{:align => "right", :valign => "bottom"}
- = link_to("Retrieve",
- {:action => "rbac_group_user_lookup",
- :button => "submit",
- :id => @edit[:group_id] || "new"},
- :class => "btn btn-primary",
- :alt => t = _("LDAP Group Lookup"),
- "data-miq_sparkle_on" => true,
- "data-miq_sparkle_off" => true,
- :remote => true,
- "data-method" => :post,
- :title => t)
+
+ .col-md-12{:align => "right", :valign => "bottom"}
+ = link_to("Retrieve",
+ {:action => "rbac_group_user_lookup",
+ :button => "submit",
+ :id => @edit[:group_id] || "new"},
+ :class => "btn btn-primary",
+ :alt => t = _("LDAP Group Lookup"),
+ "data-miq_sparkle_on" => true,
+ "data-miq_sparkle_off" => true,
+ :remote => true,
+ "data-method" => :post,
+ :title => t)
%hr
%h3 (on top of the current changes) |
d232c0b
to
23a5a41
Compare
Checked commit hstastna@23a5a41 with ruby 2.5.5, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
@himdel I've made suggested changes regarding the Retrieve button :) |
Issue: #2316
This PR solves the specific situation in LDAP user lookup form: DOM ID
"user"
was there twice. This was caused by ManageIQ/manageiq#4042. The exactly same field with the same id, that was already there, was added in the haml, together with the javascript for showing/hiding the divs with the appropriate fields. This (not the best) solution was implemented for displaying/hiding Retrieve button next to the field.Later, thanks to some cleanup in that area, this issue became obvious: the same field was rendered twice in the screen, all the divs were shown because the javascript was not executed - and this because
@edit
wasnil
- this all thanks to this change.This PR cares about:
if mode == "httpd"
Note that
mode
is already set here, no need to use the whole condition as here.unless mode == "httpd"
because of thisNote:
Adding
- if @edit
to the haml (added in the haml during the later cleanup) is not necessary because it's already there in the right place.