-
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
Convert RBAC Features Tree to use TreeBuilder (2) #137
Convert RBAC Features Tree to use TreeBuilder (2) #137
Conversation
7856bfc
to
2f476e2
Compare
Summoning @ZitaNemeckova and @himdel |
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.
Looks great, just a few minor comments ...
end | ||
|
||
def x_get_tree_section_kids(parent, count_only = false) | ||
kids = parent.items.select do |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.
Isn't possible to write this as a one-liner with reject
?
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.
Shorter, but one line is awkward with the if kind_of?(Menu::Item)
.
count_only_or_objects(count_only, kids) | ||
end | ||
|
||
# FIXME: This is inefficient, but done to use MiqProductFeature objects rather than hashes |
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.
😄
app/presenters/tree_node/hash.rb
Outdated
@@ -10,7 +10,8 @@ class Hash < Node | |||
|
|||
set_attribute(:hide_checkbox) { @object.key?(:hideCheckbox) && @object[:hideCheckbox] ? true : nil } | |||
|
|||
set_attribute(:selected) { @object.key?(:select) && @object[:select] ? true : nil } | |||
# set_attribute(:selected) { @object.key?(:select) && @object[:select] ? true : nil } | |||
set_attribute(:selected) { @object[:select] if @object.key?(:select) } |
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.
This definitely needs to be tested against other trees using hash nodes & checkboxes ...
module TreeNode | ||
module Menu | ||
class Item < Node | ||
set_attribute(:key) { "#{@options[:node_id_prefix]}__#{@object.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.
Any particular reason for the __
instead of _
?
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.
Legacy. I still need to look into the keys that the controller expects to make updating work.
class Item < Node | ||
set_attribute(:key) { "#{@options[:node_id_prefix]}__#{@object.feature}" } | ||
|
||
set_attribute(:title) { _(details[: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.
I think it's way too dynamic for gettext - ping @mzazrivec
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.
This is a carry over of how it currently works: https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/ops_controller/rbac_tree.rb#L120
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.
Yes, using _(details[:name])
here is correct.
self_selected? || select_by_kids_selected | ||
end | ||
|
||
set_attribute(:no_click, true) |
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.
Not sure if this is necessary, see https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/presenters/tree_builder.rb#L124
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.
With this setting, clicking on a node will expand that part of the tree, without it clicking will try and load a page (I guess based on the key). Is there another setting I'm supposed to use for that?
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.
Set :onclick => nil
in set_locals_for_render
😉
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.
That seems to prevent it from trying to load a page, but it highlights the node instead of expanding it.
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.
OK
|
||
set_attribute(:no_click, true) | ||
|
||
set_attribute(:hide_checkbox, false) |
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.
Isn't this default? I mean if there are checkboxes, they're displayed if not said othetwise.
module Menu | ||
class Section < Node | ||
set_attribute(:key) do | ||
"#{@options[:node_id_prefix]}___tab_#{@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.
If you can add tab
as a prefix for this kind of object, then it'd be better to have that, use full_ids and not override the key in any of the nodes..
(that should give you xx-10r2_tab-net
)
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 to full ids, but forms from users, groups, and roles all seem to go through the same method. Probably should be fixed in a subsequent PR.
2e993cf
to
8419eb4
Compare
# Make sure tree_state doesn't hold on to old data between requests | ||
# | ||
unless @sb.fetch_path('trees', 'features_tree').nil? | ||
@sb['trees'].delete('features_tree') |
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.
@hayesr Maybe something like TreeState.new(sandbox).remove_tree(name)
in the constructor?
(mostly because we have the same thing here https://github.com/ManageIQ/manageiq-ui-classic/pull/15/files#diff-d10de31acbab60b307f4c0ea86b158c0R22 )
97c51bd
to
87fbe37
Compare
87fbe37
to
c7ca1d5
Compare
|
||
set_attribute(:tooltip) { _(details[:description]) || _(details[:name]) } | ||
|
||
set_attribute(:image, "100/feature_node") |
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.
missing .png
|
||
set_attribute(:title) { _(@object.name) } | ||
|
||
set_attribute(:image) { "100/feature_node" } |
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.
missing .png
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.
— but it works 🤷♂️
Fixed.
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.
Hehe, yeah, that's the magic of rails :-) which usually only breaks in production.. By making the first access to such an icon take about 2 minutes on a new appliance, became its not in the index and rails tries really hard to search for it :-)
app/presenters/tree_node/node.rb
Outdated
@@ -129,7 +129,7 @@ def to_h | |||
:checkable => checkable ? nil : false, | |||
} | |||
|
|||
node[:image] = if !image | |||
node[:image] = if !respond_to?(:image) || !image |
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 longer needed, Node has a default image
implementation
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.
This shouldn't be a change from my code. How'd this get here?
@hayesr could you please fix the red rubocop issues? |
Removed the child-counting methods from node builders and it seems to work well with |
@hayesr please rebase to fix bower issues in travis & there are still things that weren't fixed... |
Restart CI |
Bower hates me. |
Finally green! (Codeclimate doesn't like so many parameters in |
As I mentioned earlier there are still some unresolved issues:
Please fix them, and we can merge this 👍 |
This pull request is not mergeable. Please rebase and repush. |
the operative word here is "later" aka someday/maybe/never |
6ad047c
to
c495821
Compare
Checked commits hayesr/manageiq-ui-classic@4f46dae~...a90e7a0 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 app/presenters/menu/manager.rb
app/presenters/tree_builder_ops_rbac_features.rb
|
Ready for another look. |
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.
🥇 |
This is an alternative to #56 that makes more typical use of
x_get_*_kids
methods.Heads-up: this way is 7x slowerPerformance isn't bad using feature cache inMiqProductFeature
Still to figure out:
Addresses:
https://bugzilla.redhat.com/show_bug.cgi?id=1348623
https://bugzilla.redhat.com/show_bug.cgi?id=1411831
https://www.pivotaltracker.com/story/show/129518309
Related:
ManageIQ/manageiq#13577
ManageIQ/manageiq#13592
Go to Configuration > Access Control > Roles, pick a role - the tree is on the right, in the role detail.
/cc @zimdel @skateman