Skip to content

Commit

Permalink
Filter visible switches, lans, guest devices, and vms in the network …
Browse files Browse the repository at this point in the history
…tree

This adds filtering by tag for network lans, switches, and guest devices
And adds filtering by tag and tenant for vms

(changing rbac.filtered will add filtering by tenant for lans and others)
  • Loading branch information
kbrock committed Jan 8, 2024
1 parent cfabbe7 commit 491e2d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
9 changes: 3 additions & 6 deletions app/presenters/tree_builder_network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ def root_options
end

def x_get_tree_roots
@root.switches.empty? ? [] : count_only_or_objects(false, @root.switches)
Rbac.filtered(@root.switches)
end

def x_get_tree_switch_kids(parent, count_only)
objects = []
objects.concat(parent.guest_devices) unless parent.guest_devices.empty?
objects.concat(parent.lans) unless parent.lans.empty?
count_only_or_objects(count_only, objects)
count_only_or_objects_filtered(count_only, parent.guest_devices) + count_only_or_objects_filtered(count_only, parent.lans)
end

def x_get_tree_lan_kids(parent, count_only)
if parent.respond_to?("vms_and_templates")
if parent.respond_to?(:vms_and_templates)
count_only_or_objects_filtered(count_only, parent.vms_and_templates, "name")
else
count_only ? 0 : []
Expand Down
1 change: 1 addition & 0 deletions spec/presenters/tree_builder_network_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
describe TreeBuilderNetwork do
context 'TreeBuilderNetwork' do
before do
EvmSpecHelper.local_miq_server
role = MiqUserRole.find_by(:name => "EvmRole-operator")
@group = FactoryBot.create(:miq_group, :miq_user_role => role, :description => "Network Group")
login_as FactoryBot.create(:user, :userid => 'network_wilma', :miq_groups => [@group])
Expand Down

0 comments on commit 491e2d4

Please sign in to comment.