-
Notifications
You must be signed in to change notification settings - Fork 898
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
Make created filters in Datastores visible and fix commiting filters #13140
Make created filters in Datastores visible and fix commiting filters #13140
Conversation
when "global" # Global filters | ||
objects.visible_to_all | ||
when "my" # My filters | ||
objects.where(:search_type => "user", :search_key => User.current_user.userid) |
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.
what about to move this to model a method (app/models/miq_search.rb
) ?
return count_only ? 0 : [] if object[:id] != "global" | ||
objects = MiqSearch.where(:db => options[:leaf]).visible_to_all | ||
objects = MiqSearch.where(:db => options[:leaf]) | ||
objects = case object[:id] |
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.
and you can use
objects = object[:id] == 'global' ? objects.visible_to_all : objects.your_new_method_from_comment_below
what do you think ?
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 changed app/presenters/tree_builder_storage.rb like that because it needs the same functionality as in https://github.com/ManageIQ/manageiq/blob/master/app/presenters/tree_builder_vms_filter.rb#L28
which works well and it is well understandable what's going on there.
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.
nice, then you can move this code to method in app/models/miq_search.rb
to avoid duplicating code.
and you can do it in follow up PR for tree_builder_vms_filter.rb
objects = MiqSearch.where(:db => options[:leaf])
objects = case object[:id]
when "global" # Global filters
objects.visible_to_all
when "my" # My filters
objects.where(:search_type => "user", :search_key => User.current_user.userid)
end
what do you think ?
@miq-bot add_label ui, bug |
@@ -307,11 +307,11 @@ def adv_search_button | |||
{:model => ui_lookup(:model => @edit[@expkey][:exp_model]), | |||
:name => @edit[:new_search_name]}) | |||
@edit[@expkey].select_filter(s) | |||
@edit[:new_search_name] = @edit[:adv_search_name] = @edit[@expkey][:exp_last_loaded][:description] | |||
@edit[:new_search_name] = @edit[@expkey][:exp_model] != "Storage" ? @edit[:adv_search_name] = @edit[@expkey][:exp_last_loaded][:description] : @edit[:new_search_name] |
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.
in else leg you are assigning same variable (@edit[:new_search_name]
) ?
@edit[:new_search_name] = @edit[:adv_search_name] = @edit[@expkey][:exp_last_loaded][:description] unless @edit[@expkey][:exp_model] == "Storage"
does it cover you intention ?
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 believe this can be solved by some other (and hopefully better) solutions. If you look at the original line and test it, the result will be that @edit[:new_search_name]
will be nil
which is not good. I decided to do it like that to leave it as it was for other cases (I mean if the condition is true) because hopefully it was a reason for how it was like that for so long.
For our case @edit[:new_search_name]
shouldn't be changed there. Maybe somebody could test it if it could be changed generally (I mean not just for Datastores). I didn't want to break functionality in other places with this. Any ideas how to make it better?
Fix a little typo in adv_search_button method regarding a proper saving of a new created filter using advanced search panel.
b2bb1ea
to
4d61385
Compare
fixing https://bugzilla.redhat.com/show_bug.cgi?id=1398748 https://bugzilla.redhat.com/show_bug.cgi?id=1382768 Make created filters (not global) in Compute -> Infrastructure -> -> Datastores visible under My Filters in accordion.
4d61385
to
3aaad73
Compare
fixing https://bugzilla.redhat.com/show_bug.cgi?id=1398748 https://bugzilla.redhat.com/show_bug.cgi?id=1382768 Display a new filter (not global) in Compute -> Infrastructure -> -> Datastores in My Filters in accordion right after creating it, no need to refresh the page to see the new filter there.
Fix commiting a new filter in advanced search panel which is related to its creating and saving because it did not work, button to 'Commit expression element changes' did not work properly. Also make button for discarding expression element changes work.
3aaad73
to
6e190df
Compare
Checked commits hstastna/manageiq@46e28bf~...6e190df with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 app/controllers/application_controller/filter.rb
app/views/layouts/exp_atom/_editor.html.haml |
depends on ManageIQ#13140 Refactoring code of x_get_tree_custom_kids method as the same code needs to be in the method in tree_builder_vms_filter.rb and in tree_builder_storage.rb; moving the code to new methods in miq_search.rb.
@hstastna after i saved a filter in Datastores accordion that worked and refreshed the tree to show the newly added filter in it, but when i tried to add a new filter Datastore Clusters accordion, after i save the filter it blanks out the whole tree in the left accordion, see screenshot below: |
"data-method" => :post, | ||
:title => t) | ||
|
||
- t = _('Commit expression element changes') |
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.
@epwinchell can you review this change
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 Can you replace the link_to(image_tag for each as I have below? That will give us the styling we need.
%button
..%i.fa.fa-check
%button
.. %i.pficon.pficon-close
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.
@epwinchell could you please test it and give me an exact and working example?
Because I probably don't know how you mean it.
I mean, wit the code around, not just with "..."
It just does not work as simply as you mentioned. I tried it in many ways, without success. Some of my colleagues tried it, too, and also without success.
Originally, the problem was button
element.
I know that styling is important, but as I think, more important is if the button works properly.
So I removed the button element and it worked perfectly. Adding some classes was not a problem, it was possible to add them very easily to my original solution.I know that you would like to see nicer solution but my solution worked comparing to the "styling we need". This all makes me to ask: is really button element required to use there? Why? We survived to these days without it.. (I mean, without working buttons there..) If yes, how would you put there all the options to make it work properly and using button element?
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 Here's a working example. If you get stuck with these in the future, please ping me or @h-kataria for help.
%button.btn.btn-default{:title => t,
"data-miq_sparkle_on" => true,
:remote => true,
"data-method" => :post,
:onclick => "miqAjaxButton('#{url_for(:action => 'exp_button', :pressed => 'commit')}');"}
%i.fa.fa-lg.fa-check
- t = _("Discard expression element changes")
%button.btn.btn-default{:title => t,
"data-miq_sparkle_on" => true,
:remote => true,
"data-method" => :post,
:onclick => "miqAjaxButton('#{url_for(:action => 'exp_button', :pressed => 'discard')}');"}
%i.fa-lg.pficon.pficon-close
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 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.
Thank you very much!
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.
👍 For fixing broken buttons!!!
This pr fixes broken However, the I vote for merging this pr early, so we have at least something working. |
<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush. |
This PR has conflicts because of UI split, I am closing this PR and creating the new one and better: ManageIQ/manageiq-ui-classic#98 |
fixing
https://bugzilla.redhat.com/show_bug.cgi?id=1398748
https://bugzilla.redhat.com/show_bug.cgi?id=1382768
Make created filters (not global) in Compute -> Infrastructure -> Datastores
visible under My Filters in accordion, no need to refresh the page
after creating a new filter.
Fix commiting a new filter which is related to its creating and saving.
Commiting filters was broken by
#12998
Before:
After:
No need to refresh the page after creating a new filter: