Skip to content

Commit

Permalink
Merge pull request #6351 from hstastna/RemoveTag_TopologyView
Browse files Browse the repository at this point in the history
Remove Tags from Network Topology View and others

(cherry picked from commit 3a97fac)

https://bugzilla.redhat.com/show_bug.cgi?id=1529718
  • Loading branch information
Martin Povolny authored and simaishi committed May 12, 2020
1 parent dc0ddae commit f3f7822
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 98 deletions.
Expand Up @@ -123,7 +123,6 @@ angular.module('ManageIQ').controller('cloudTopologyController', ['$scope', 'top
case 'CloudManager':
return { x: -20, y: -20, r: 28 };
case 'AvailabilityZone':
case 'Tag':
return { x: defaultDimensions.x, y: defaultDimensions.y, r: 13 };
case 'CloudTenant':
return { x: defaultDimensions.x, y: defaultDimensions.y, r: 19 };
Expand Down
Expand Up @@ -125,8 +125,6 @@ angular.module('ManageIQ').controller('infraTopologyController', ['$scope', 'top
return { x: defaultDimensions.x, y: defaultDimensions.y, r: defaultDimensions.r };
case 'Host':
return { x: defaultDimensions.x, y: defaultDimensions.y, r: defaultDimensions.r };
case 'Tag':
return { x: defaultDimensions.x, y: defaultDimensions.y, r: 13 };
default:
return defaultDimensions;
}
Expand Down
Expand Up @@ -122,7 +122,6 @@ angular.module('ManageIQ').controller('networkTopologyController', ['$scope', 't
case 'NetworkManager':
return { x: -20, y: -20, r: 28 };
case 'FloatingIp':
case 'Tag':
return { x: defaultDimensions.x, y: defaultDimensions.y, r: 13 };
case 'NetworkRouter':
return { x: defaultDimensions.x, y: defaultDimensions.y, r: defaultDimensions.r };
Expand Down
Expand Up @@ -125,8 +125,6 @@ angular.module('ManageIQ').controller('physicalInfraTopologyController', ['$scop
return { x: defaultDimensions.x, y: defaultDimensions.y, r: defaultDimensions.r };
case 'Host':
return { x: defaultDimensions.x, y: defaultDimensions.y, r: defaultDimensions.r };
case 'Tag':
return { x: defaultDimensions.x, y: defaultDimensions.y, r: 13 };
default:
return defaultDimensions;
}
Expand Down
18 changes: 3 additions & 15 deletions app/assets/javascripts/services/topology_service.js
Expand Up @@ -6,13 +6,6 @@ ManageIQ.angular.app.service('topologyService', ['$location', '$http', 'miqServi
__('Status: ') + d.item.status,
];

if (d.item.kind === 'Tag') {
status = [
d.item.name,
__('Type: ') + d.item.display_kind,
];
}

if (d.item.kind === 'Host' || d.item.kind === 'Vm') {
status.push(__('Provider: ') + d.item.provider);
}
Expand Down Expand Up @@ -60,11 +53,9 @@ ManageIQ.angular.app.service('topologyService', ['$location', '$http', 'miqServi
.style('top', mousePosition[1] + 'px');
popup.append('h5').text('Actions on ' + data.item.display_kind);

if (data.item.kind !== 'Tag') {
popup.append('p').text(__('Go to summary page')).on('click', function() {
vm.dblclick(data);
});
}
popup.append('p').text(__('Go to summary page')).on('click', function() {
vm.dblclick(data);
});

var canvasSize = [
canvas.node().offsetWidth,
Expand All @@ -90,9 +81,6 @@ ManageIQ.angular.app.service('topologyService', ['$location', '$http', 'miqServi
};

vm.dblclick = function dblclick(d) {
if (d.item.kind === 'Tag') {
return false;
}
$window.location.assign(topologyService.geturl(d));
};

Expand Down
7 changes: 3 additions & 4 deletions app/services/cloud_topology_service.rb
Expand Up @@ -2,12 +2,11 @@ class CloudTopologyService < TopologyService
@provider_class = ManageIQ::Providers::CloudManager

@included_relations = [
:writable_classification_tags,
:availability_zones => [:writable_classification_tags, :vms => :writable_classification_tags],
:cloud_tenants => [:writable_classification_tags, :vms => :writable_classification_tags],
:availability_zones => [:vms => nil],
:cloud_tenants => [:vms => nil],
]

@kinds = %i[CloudManager AvailabilityZone CloudTenant Vm Tag]
@kinds = %i[CloudManager AvailabilityZone CloudTenant Vm]

def entity_display_type(entity)
if entity.kind_of?(ManageIQ::Providers::CloudManager)
Expand Down
10 changes: 3 additions & 7 deletions app/services/infra_topology_service.rb
Expand Up @@ -2,21 +2,17 @@ class InfraTopologyService < TopologyService
@provider_class = ManageIQ::Providers::InfraManager

@included_relations = [
:writable_classification_tags,
:ems_clusters => [
:writable_classification_tags,
:hosts => [
:writable_classification_tags,
:vms => :writable_classification_tags
:vms => nil
]
],
:clusterless_hosts => [
:writable_classification_tags,
:vms => :writable_classification_tags
:vms => nil
],
]

@kinds = %i[InfraManager EmsCluster Host Vm Tag]
@kinds = %i[InfraManager EmsCluster Host Vm]

def entity_type(entity)
if entity.kind_of?(Host)
Expand Down
16 changes: 6 additions & 10 deletions app/services/network_topology_service.rb
Expand Up @@ -2,24 +2,20 @@ class NetworkTopologyService < TopologyService
@provider_class = ManageIQ::Providers::NetworkManager

@included_relations = [
:writable_classification_tags,
:availability_zones => [
:vms => [
:writable_classification_tags,
:floating_ips => :writable_classification_tags,
:cloud_tenant => :writable_classification_tags,
:security_groups => :writable_classification_tags,
:floating_ips => nil,
:cloud_tenant => nil,
:security_groups => nil,
]
],
:cloud_subnets => [
:parent_cloud_subnet,
:writable_classification_tags,
:vms,
:cloud_network => :writable_classification_tags,
:cloud_network => nil,
:network_router => [
:writable_classification_tags,
:cloud_network => [
:floating_ips => :writable_classification_tags
:floating_ips => nil
]
]
],
Expand All @@ -35,7 +31,7 @@ class NetworkTopologyService < TopologyService
]
]

@kinds = %i[NetworkRouter CloudSubnet Vm NetworkManager FloatingIp CloudNetwork NetworkPort CloudTenant SecurityGroup LoadBalancer Tag AvailabilityZone]
@kinds = %i[NetworkRouter CloudSubnet Vm NetworkManager FloatingIp CloudNetwork NetworkPort CloudTenant SecurityGroup LoadBalancer AvailabilityZone]

def entity_type(entity)
if entity.kind_of?(CloudNetwork) || entity.kind_of?(CloudSubnet)
Expand Down
10 changes: 2 additions & 8 deletions app/services/physical_infra_topology_service.rb
Expand Up @@ -3,31 +3,25 @@ class PhysicalInfraTopologyService < TopologyService

# Keep it in a 'topological order' e.g: racks, chassis, servers
@included_relations = [
:writable_classification_tags,
:physical_racks => %i[
writable_classification_tags
physical_chassis
physical_servers
],
:physical_chassis => %i[
writable_classification_tags
child_physical_chassis
physical_servers
],
:physical_servers => [
:writable_classification_tags,
:physical_switches,
:host => [
:writable_classification_tags,
:vms => :writable_classification_tags
:vms => nil
]
],
:physical_switches => [
:writable_classification_tags
],
]

@kinds = %i[PhysicalInfraManager PhysicalRack PhysicalChassis PhysicalServer Host Vm Tag PhysicalSwitch]
@kinds = %i[PhysicalInfraManager PhysicalRack PhysicalChassis PhysicalServer Host Vm PhysicalSwitch]
@filter_properties = %i[kind status]

# This priority mapping controls what connections will be present in the
Expand Down
7 changes: 1 addition & 6 deletions app/services/topology_service.rb
Expand Up @@ -42,12 +42,7 @@ def entity_id(entity)
end

def entity_name(entity)
if entity.kind_of?(Tag)
cls = entity.classification
[cls.parent, cls].map(&:description).join(': ')
else
entity.name
end
entity.name
end

# If needed, implemented this on its subclasses
Expand Down
4 changes: 0 additions & 4 deletions app/views/cloud_topology/show.html.haml
Expand Up @@ -15,10 +15,6 @@
%label
%i.pficon.pficon-cloud-tenant
= _("Cloud Tenants")
%kubernetes-topology-icon{tooltip_options, :kind => "Tag"}
%label
%i.fa.fa-tag
= _("Tags")

.alert.alert-info.alert-dismissable
%button.close{"aria-hidden" => "true", "data-dismiss" => "alert", :type => "button"}
Expand Down
4 changes: 0 additions & 4 deletions app/views/infra_topology/show.html.haml
Expand Up @@ -15,10 +15,6 @@
%label
%i.pficon.pficon-cluster
= _("Clusters")
%kubernetes-topology-icon{tooltipOptions, :kind => "Tag"}
%label
%i.fa.fa-tag
= _("Tags")

.alert.alert-info.alert-dismissable
%button.close{"aria-hidden" => "true", "data-dismiss" => "alert", :type => "button"}
Expand Down
4 changes: 0 additions & 4 deletions app/views/network_topology/show.html.haml
Expand Up @@ -35,10 +35,6 @@
%label
%i.pficon.pficon-cloud-tenant
= _("Cloud Tenants")
%kubernetes-topology-icon{tooltipOptions, :kind => "Tag"}
%label
%i.fa.fa-tag
= _("Tags")

.alert.alert-info.alert-dismissable
%button.close{"aria-hidden" => "true", "data-dismiss" => "alert", :type => "button"}
Expand Down
4 changes: 0 additions & 4 deletions app/views/physical_infra_topology/show.html.haml
Expand Up @@ -28,10 +28,6 @@
%label
%i.pficon.pficon-virtual-machine
= _("VMs")
%kubernetes-topology-filter{tooltipOptions, "filter-property" => "kind", "filter-value" => "Tag"}
%label
%i.fa.fa-tag
= _("Tags")
.topology-filter-group
%label#health_state
= _("Health State: ")
Expand Down
37 changes: 11 additions & 26 deletions spec/services/topology_service_spec.rb
@@ -1,5 +1,6 @@
describe TopologyService do
let(:provider_class) { double }

before do
described_class.instance_variable_set(:@provider_class, provider_class)
allow(provider_class).to receive(:all)
Expand Down Expand Up @@ -35,6 +36,7 @@

describe '#build_kinds' do
let(:kinds) { %i(Host Vm) }

it 'returns with hash where the keys are kinds' do
described_class.instance_variable_set(:@kinds, kinds)

Expand Down Expand Up @@ -73,27 +75,22 @@

describe '#map_to_graph' do
let(:provider) { FactoryBot.create(:ext_management_system) }
let(:tag) { FactoryBot.create(:tag) }
let(:vm) { FactoryBot.create(:vm, :ext_management_system => provider, :tags => [tag]) }
let(:graph) { {:vms => {:tags => nil}} }
let(:vm) { FactoryBot.create(:vm, :ext_management_system => provider) }
let(:graph) { {:vms => nil} }

before do
allow(subject).to receive(:build_entity_data) { |input| input }
end
before { allow(subject).to receive(:build_entity_data) { |input| input } }

it 'calls the graph items as methods recursively' do
expect(provider).to receive(:vms).and_return([vm])
expect(vm).to receive(:tags).and_return([tag])
subject.map_to_graph([provider], graph)
end

it 'returns with the list of objects and the links between' do
allow(provider).to receive(:vms).and_return([vm])
allow(vm).to receive(:tags).and_return([tag])
output = subject.map_to_graph([provider], graph)

expect(output.first.values).to eq([provider, vm, tag])
expect(output.last.length).to eq(2)
expect(output.first.values).to eq([provider, vm])
expect(output.last.length).to eq(1)
end
end

Expand All @@ -102,6 +99,7 @@

context 'input is a symbol' do
let(:input) { :sym }

it 'returns with Input => nil' do
expect(output).to have_key(input.capitalize)
expect(output[input.capitalize]).to be_nil
Expand Down Expand Up @@ -132,23 +130,10 @@

describe '#entity_name' do
let(:name) { subject.send(:entity_name, entity) }
let(:entity) { FactoryBot.create(:vm_vmware) }

context 'entity is not a tag' do
let(:entity) { FactoryBot.create(:vm_vmware) }

it 'returns with the name of the entity' do
expect(name).to eq(entity.name)
end
end

context 'entity is a tag' do
let(:parent_cls) { FactoryBot.create(:classification, :description => 'foo') }
let(:cls) { FactoryBot.create(:classification_tag, :parent => parent_cls, :description => 'bar') }
let(:entity) { cls.tag }

it 'returns with the parent and the child classification description' do
expect(name).to eq('foo: bar')
end
it 'returns with the name of the entity' do
expect(name).to eq(entity.name)
end
end
end

0 comments on commit f3f7822

Please sign in to comment.